X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/bffa3430fbbaaad29bec0b5bee9c1f0bfc7fd068..34f6af4f61e0eec9c96113e07f140b609b4113c8:/lunaix-os/arch/generic/bootmem.c diff --git a/lunaix-os/arch/generic/bootmem.c b/lunaix-os/arch/generic/bootmem.c new file mode 100644 index 0000000..9c067a2 --- /dev/null +++ b/lunaix-os/arch/generic/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; + +_default void* +bootmem_alloc(unsigned int size) +{ + ptr_t res; + + res = __ptr(bootmem_pool) + pos; + + size = ROUNDUP(size, 4); + pos += size; + + if (pos >= BOOTMEM_SIZE) { + spin(); + unreachable; + } + + return (void*)res; +} + +_default void +bootmem_free(void* ptr) +{ + // not need to support, as they are all one-shot + return; +} \ No newline at end of file