simple_malloc.h 839 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. Simple malloc function. 2013.09.01, Gaia
  3. */
  4. #include <Asmdef.h>
  5. #include <rom_def.h>
  6. #include <stdio.h>
  7. #include <asm/types.h>
  8. struct slob_block {
  9. int units;
  10. struct slob_block *next;
  11. #if PATCH_CACHE_LINE_ALIGNMENT //dual cpu cache wb issue, fix 4k alignment
  12. #if (CONFIG_DRAMSIZE == 64)
  13. int stuff[254]; //2014.01.24, 1k alignment for 64M tight memory
  14. #else
  15. int stuff[1022];
  16. #endif
  17. #endif
  18. };
  19. typedef struct slob_block slob_t;
  20. #define SLOB_UNIT sizeof(slob_t)
  21. #define SLOB_UNITS(size) (((size) + SLOB_UNIT - 1)/SLOB_UNIT)
  22. extern void slob_free(const void *block, int size);
  23. #define free(block) slob_free(block, 0)
  24. extern void *smalloc(size_t size, int align);
  25. #define malloc(size) smalloc(size, 0)
  26. #define memalign(align, size) smalloc(size, align)
  27. #define uncached(addr) (void *)(((u32)addr & 0x1ffffff)|0xa0000000)