From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- memory/bump.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 memory/bump.c (limited to 'memory/bump.c') diff --git a/memory/bump.c b/memory/bump.c new file mode 100644 index 0000000..a6b0228 --- /dev/null +++ b/memory/bump.c @@ -0,0 +1,33 @@ +#include "bump.h" +#include "memory.h" + +static void *s_next_free; + +void* +bump_where(void) +{ + return s_next_free; +} + +void *bump_alloc(size_t size) +{ + void *ret = s_next_free; + s_next_free = (void*)((uintptr_t)s_next_free + size); + vm_ensure( + (uintptr_t)ret, + (uintptr_t)s_next_free, + (page_flags_t) { + .present = true, + .writeable = true, + .useraccess = false, + .executable = false + }); + return ret; +} + +void +bump_setup(void) +{ + extern void *_kernel_end; + s_next_free = (void*)&_kernel_end; +} -- cgit v1.2.1