diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2024-05-22 13:00:41 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2024-05-22 13:00:41 -0400 |
commit | ace65b453151845bc361f21f3e5b651c35f9f126 (patch) | |
tree | 262ebd29b0ca1d8584f0b6f1efa7a00d9f4f3e43 /memory/bump.c | |
parent | f004c1ade8d617a82cea2fe249434cccb47a2358 (diff) | |
download | jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.gz jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.bz2 jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.zip |
Diffstat (limited to 'memory/bump.c')
-rw-r--r-- | memory/bump.c | 33 |
1 files changed, 33 insertions, 0 deletions
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; +} |