diff options
author | Danny Holman <dholman@gymli.org> | 2024-02-16 12:53:20 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-02-16 12:53:20 -0600 |
commit | 67dba16e46cd0f3f204feae3dc0a95a8c3262ff7 (patch) | |
tree | 28c1107a6a1d8e28fb5230c95e97edbd96795fda /kernel | |
parent | c95f8d146849ac1a5a0eb550e08b6010ae7234aa (diff) |
kernel: mem: kmalloc should not call page allocation
Strip the code calling for the memory manager to allocate pages to
kmalloc. The function should just return a raw pointer while a page
fault will allocate the required memory.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/mem.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/kernel/mem.c b/kernel/mem.c index e2f1889..e977f6a 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -1,22 +1,14 @@ #include <kernel/mem.h> -#include <kernel/alloc.h> #include <kernel/paging.h> -extern uint32_t _kernel_end; -static uint32_t *heap_start = &_kernel_end; -static uint32_t *heap_end = &_kernel_end; - -int _alloc_new_page(void) { - uint32_t paddr = pfa_alloc_frame(); - if (paddr == 0xFFFFFFFF) - return -1; - map_page(paddr, heap_end, 0x003); -} +extern uintptr_t _kernel_end; +static uintptr_t heap_start = (uintptr_t)&_kernel_end; +static uintptr_t heap_end = (uintptr_t)&_kernel_end; void* kmalloc(size_t sz) { - void *ret = heap_end; + void *tmp = heap_end; heap_end += sz; - return ret; + return tmp; } void kfree(void *ptr) { |