summaryrefslogtreecommitdiffstats
path: root/src/core/malloc.c
diff options
context:
space:
mode:
authorMichael Brown2007-07-04 00:09:56 +0200
committerMichael Brown2007-07-04 00:09:56 +0200
commit89349d7fad252f0b36be4a764369e6dd40a2e692 (patch)
tree72b112d6152fadee77673994f1e92b82a9c506e8 /src/core/malloc.c
parentAdded missing line to set return status code. (diff)
downloadipxe-89349d7fad252f0b36be4a764369e6dd40a2e692.tar.gz
ipxe-89349d7fad252f0b36be4a764369e6dd40a2e692.tar.xz
ipxe-89349d7fad252f0b36be4a764369e6dd40a2e692.zip
Separated out initialisation functions from startup/shutdown functions.
Diffstat (limited to 'src/core/malloc.c')
-rw-r--r--src/core/malloc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/malloc.c b/src/core/malloc.c
index bf94592c..2d892f42 100644
--- a/src/core/malloc.c
+++ b/src/core/malloc.c
@@ -22,6 +22,7 @@
#include <strings.h>
#include <io.h>
#include <gpxe/list.h>
+#include <gpxe/init.h>
#include <gpxe/malloc.h>
/** @file
@@ -73,6 +74,16 @@ static LIST_HEAD ( free_blocks );
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
*
* @v size Requested size
@@ -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>
/**