aboutsummaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-05-21 10:26:49 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-05-21 11:44:57 +0200
commitfa9ea2e622eb105fb77f1f09e3194bfc05db7c5e (patch)
treebe8d9bd2dd39fb6cd6c090f8c7bbbf1d43a39f90 /malloc.c
parentbd363b8030716a759823d8828690e49ad4d25f96 (diff)
downloadqboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.zip
qboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.tar.gz
qboot-fa9ea2e622eb105fb77f1f09e3194bfc05db7c5e.tar.bz2
add malloc
Allocate the e820 map in the E-segment. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/malloc.c b/malloc.c
new file mode 100644
index 0000000..3ab95ed
--- /dev/null
+++ b/malloc.c
@@ -0,0 +1,21 @@
+#include <inttypes.h>
+#include "string.h"
+
+extern uint8_t edata;
+static uint8_t *fseg_base = &edata;
+
+extern uint8_t stext;
+static uint8_t *malloc_top = &stext;
+
+void *malloc(int n)
+{
+ malloc_top -= (n + 15) & -16;
+ return malloc_top;
+}
+
+void *malloc_fseg(int n)
+{
+ void *p = fseg_base;
+ fseg_base += (n + 15) & -16;
+ return p;
+}