Merge branch 'master' into isa/arm64
[lunaix-os.git] / lunaix-os / arch / aarch64 / boot / mem.c
1 #include "init.h"
2 #include <lunaix/sections.h>
3 #include <lunaix/spike.h>
4
5 #define BOOTMEM_SIZE   (4 * 4096)
6
7 static reclaimable char bootmem_pool[BOOTMEM_SIZE];
8 static unsigned int pos;
9
10 void*
11 bootmem_alloc(unsigned int size)
12 {
13     ptr_t res;
14
15     res = __ptr(bootmem_pool) + pos;
16     
17     size = ROUNDUP(size, 4);
18     pos += size;
19
20     if (pos >= BOOTMEM_SIZE) {
21         spin();
22     }
23
24     return (void*)res;
25 }
26
27 void
28 bootmem_free(void* ptr)
29 {
30     // not need to support, as they are all one-shot
31     return;
32 }