File: init.c

package info (click to toggle)
syslinux 2%3A4.02%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 23,804 kB
  • ctags: 71,027
  • sloc: ansic: 270,621; pascal: 9,631; asm: 9,089; perl: 3,492; makefile: 1,588; sh: 511; python: 266; xml: 39
file content (38 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "malloc.h"

struct free_arena_header __malloc_head[NHEAP];

static __hugebss char main_heap[128 << 10];
extern char __lowmem_heap[];

void mem_init(void)
{
    struct free_arena_header *fp;
    int i;
    uint16_t *bios_free_mem = (uint16_t *)0x413;

    /* Initialize the head nodes */

    fp = &__malloc_head[0];
    for (i = 0 ; i < NHEAP ; i++) {
	fp->a.next = fp->a.prev = fp->next_free = fp->prev_free = fp;
	fp->a.attrs = ARENA_TYPE_HEAD | (i << ARENA_HEAP_POS);
	fp->a.tag = MALLOC_HEAD;
	fp++;
    }

    /* Initialize the main heap */
    fp = (struct free_arena_header *)main_heap;
    fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
    ARENA_SIZE_SET(fp->a.attrs, sizeof main_heap);
    __inject_free_block(fp);

    /* Initialize the lowmem heap */
    fp = (struct free_arena_header *)__lowmem_heap;
    fp->a.attrs = ARENA_TYPE_USED | (HEAP_LOWMEM << ARENA_HEAP_POS);
    ARENA_SIZE_SET(fp->a.attrs, (*bios_free_mem << 10) - (uintptr_t)fp);
    __inject_free_block(fp);
}