aboutsummaryrefslogtreecommitdiffstats
path: root/roms/qboot/malloc.c
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/qboot/malloc.c
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/qboot/malloc.c')
-rw-r--r--roms/qboot/malloc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/roms/qboot/malloc.c b/roms/qboot/malloc.c
new file mode 100644
index 000000000..bd0ac0f23
--- /dev/null
+++ b/roms/qboot/malloc.c
@@ -0,0 +1,21 @@
+#include <stdint.h>
+#include "string.h"
+#include "bios.h"
+
+static uint8_t *fseg_base = &edata;
+static uint8_t *malloc_top = &stext;
+
+void *malloc_align(int n, int align)
+{
+ malloc_top = (uint8_t *) ((uintptr_t)(malloc_top - n) & -align);
+ return malloc_top;
+}
+
+void *malloc_fseg_align(int n, int align)
+{
+ void *p;
+ fseg_base = (uint8_t *) (((uintptr_t)fseg_base + align - 1) & -align);
+ p = fseg_base;
+ fseg_base += n;
+ return p;
+}