Releasing debian version 4.04+dfsg-9.
[syslinux-debian/hramrach.git] / core / mem / init.c
blob487bbb3fdadd88f5d01a2fe1dc494311fb86c149
1 #include <stdlib.h>
2 #include <errno.h>
3 #include <string.h>
4 #include "malloc.h"
6 struct free_arena_header __malloc_head[NHEAP];
8 static __hugebss char main_heap[128 << 10];
9 extern char __lowmem_heap[];
11 void mem_init(void)
13 struct free_arena_header *fp;
14 int i;
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;
24 fp++;
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);