summaryrefslogtreecommitdiffstats
path: root/src/core/malloc.c
diff options
context:
space:
mode:
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 bf94592cc..2d892f42d 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>
/**