00001 00038 #include <assert.h> 00039 #include <malloc.h> 00040 #include <physmem.h> 00041 #include <string.h> 00042 #include <types.h> 00043 00044 /* Sanity check */ 00045 #ifndef MALLOC_SIMPLE_H_INCLUDED 00046 # error malloc() header does not match implementation 00047 #endif 00048 00052 void *malloc(size_t size) 00053 { 00054 phys_addr_t addr; 00055 00056 assert(size > 0); 00057 00058 addr = physmem_alloc_low(&cpu_sram_pool, size, 2); 00059 if (addr == PHYSMEM_ALLOC_ERR) 00060 return NULL; 00061 00062 return physmem_map(addr, size, PHYS_MAP_WRBUF | PHYS_MAP_WRBACK); 00063 } 00064 00068 void *zalloc(size_t size) 00069 { 00070 void *p; 00071 00072 p = malloc(size); 00073 if (p) 00074 memset(p, 0, size); 00075 00076 return p; 00077 }
1.6.3