/SPARTAN/trunk/include/mm/frame.h |
---|
52,7 → 52,7 |
struct frame { |
count_t refcount; /**< when == 0, the frame is in free list */ |
link_t link; /**< link to zone free list when refcount == 0 */ |
} __attribute__ ((packed)); |
}; |
extern spinlock_t zone_head_lock; /**< this lock protects zone_head list */ |
extern link_t zone_head; /**< list of all zones in the system */ |
/SPARTAN/trunk/include/mm/heap.h |
---|
32,6 → 32,9 |
#include <arch/types.h> |
#include <typedefs.h> |
#define malloc(size) early_malloc(size) |
#define free(ptr) early_free(ptr) |
struct chunk { |
int used; |
struct chunk *next; |
40,9 → 43,9 |
__native data[0]; |
}; |
extern void heap_init(__address heap, size_t size); |
extern void early_heap_init(__address heap, size_t size); |
extern void *malloc(size_t size); |
extern void free(void *ptr); |
extern void *early_malloc(size_t size); |
extern void early_free(void *ptr); |
#endif |
/SPARTAN/trunk/src/main/main.c |
---|
147,7 → 147,7 |
the_initialize(THE); |
arch_pre_mm_init(); |
heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, heap_size + heap_delta); |
early_heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, heap_size + heap_delta); |
frame_init(); |
page_init(); |
tlb_init(); |
/SPARTAN/trunk/src/mm/frame.c |
---|
298,7 → 298,7 |
cnt = size / FRAME_SIZE; |
z = (zone_t *) malloc(sizeof(zone_t)); |
z = (zone_t *) early_malloc(sizeof(zone_t)); |
if (z) { |
link_initialize(&z->link); |
spinlock_initialize(&z->lock); |
311,7 → 311,7 |
z->busy_count = 0; |
z->frames = (frame_t *) malloc(cnt * sizeof(frame_t)); |
z->frames = (frame_t *) early_malloc(cnt * sizeof(frame_t)); |
if (!z->frames) { |
free(z); |
return NULL; |
/SPARTAN/trunk/src/mm/heap.c |
---|
44,7 → 44,7 |
static chunk_t *chunk0; |
static spinlock_t heaplock; |
void heap_init(__address heap, size_t size) |
void early_heap_init(__address heap, size_t size) |
{ |
spinlock_initialize(&heaplock); |
memsetb(heap, size, 0); |
58,7 → 58,7 |
/* |
* Uses first-fit algorithm. |
*/ |
void *malloc(size_t size) |
void *early_malloc(size_t size) |
{ |
pri_t pri; |
chunk_t *x, *y, *z; |
114,7 → 114,7 |
return NULL; |
} |
void free(void *ptr) |
void early_free(void *ptr) |
{ |
pri_t pri; |
chunk_t *x, *y, *z; |