X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/47c4e0c19ae8526b14ce4e0d7b243f7a4dc6fafd..bffa3430fbbaaad29bec0b5bee9c1f0bfc7fd068:/lunaix-os/arch/x86/boot/bootmem.c diff --git a/lunaix-os/arch/x86/boot/bootmem.c b/lunaix-os/arch/x86/boot/bootmem.c new file mode 100644 index 0000000..3885118 --- /dev/null +++ b/lunaix-os/arch/x86/boot/bootmem.c @@ -0,0 +1,33 @@ +#include +#include +#include + +#define BOOTMEM_SIZE (4 * 4096) + +static reclaimable char bootmem_pool[BOOTMEM_SIZE]; +static unsigned int pos; + +void* +bootmem_alloc(unsigned int size) +{ + ptr_t res; + + res = __ptr(bootmem_pool) + pos; + + size = ROUNDUP(size, 4); + pos += size; + + if (pos >= BOOTMEM_SIZE) { + asm ("ud2"); + unreachable; + } + + return (void*)res; +} + +void +bootmem_free(void* ptr) +{ + // not need to support, as they are all one-shot + return; +} \ No newline at end of file