6 struct free_arena_header __malloc_head
[NHEAP
];
8 static __hugebss
char main_heap
[128 << 10];
9 extern char __lowmem_heap
[];
13 struct free_arena_header
*fp
;
15 uint16_t *bios_free_mem
= (uint16_t *)0x413;
17 /* Initialize the head nodes */
19 fp
= &__malloc_head
[0];
20 for (i
= 0 ; i
< NHEAP
; i
++) {
21 fp
->a
.next
= fp
->a
.prev
= fp
->next_free
= fp
->prev_free
= fp
;
22 fp
->a
.attrs
= ARENA_TYPE_HEAD
| (i
<< ARENA_HEAP_POS
);
23 fp
->a
.tag
= MALLOC_HEAD
;
27 /* Initialize the main heap */
28 fp
= (struct free_arena_header
*)main_heap
;
29 fp
->a
.attrs
= ARENA_TYPE_USED
| (HEAP_MAIN
<< ARENA_HEAP_POS
);
30 ARENA_SIZE_SET(fp
->a
.attrs
, sizeof main_heap
);
31 __inject_free_block(fp
);
33 /* Initialize the lowmem heap */
34 fp
= (struct free_arena_header
*)__lowmem_heap
;
35 fp
->a
.attrs
= ARENA_TYPE_USED
| (HEAP_LOWMEM
<< ARENA_HEAP_POS
);
36 ARENA_SIZE_SET(fp
->a
.attrs
, (*bios_free_mem
<< 10) - (uintptr_t)fp
);
37 __inject_free_block(fp
);