Separated out initialisation functions from startup/shutdown functions.

This commit is contained in:
Michael Brown
2007-07-03 23:09:56 +01:00
parent a5f33ea283
commit 89349d7fad
23 changed files with 241 additions and 196 deletions

View File

@@ -22,6 +22,7 @@
#include <strings.h>
#include <io.h>
#include <gpxe/list.h>
#include <gpxe/init.h>
#include <gpxe/malloc.h>
/** @file
@@ -72,6 +73,16 @@ static LIST_HEAD ( free_blocks );
/** Total amount of free memory */
size_t freemem;
/**
* Heap size
*
* Currently fixed at 128kB.
*/
#define HEAP_SIZE ( 128 * 1024 )
/** The heap itself */
static char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) )));
/**
* Allocate a memory block
*
@@ -342,6 +353,19 @@ void mpopulate ( void *start, size_t len ) {
free_memblock ( start, ( len & ~( MIN_MEMBLOCK_SIZE - 1 ) ) );
}
/**
* Initialise the heap
*
*/
static void init_heap ( void ) {
mpopulate ( heap, sizeof ( heap ) );
}
/** Memory allocator initialisation function */
struct init_fn heap_init_fn __init_fn ( INIT_EARLY ) = {
.initialise = init_heap,
};
#if 0
#include <stdio.h>
/**