From 353647418912b5b6b94473b15bee312ddc4d64a9 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 22:05:35 +0100 Subject: kernel: move /mem/alloc to /malloc and linker.ld to arch/amd64/ --- src/kernel/malloc.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/kernel/malloc.h (limited to 'src/kernel/malloc.h') diff --git a/src/kernel/malloc.h b/src/kernel/malloc.h new file mode 100644 index 0000000..671a468 --- /dev/null +++ b/src/kernel/malloc.h @@ -0,0 +1,29 @@ +#pragma once +#include +#include +#include + +extern struct malloc_hdr *malloc_last; + +void mem_init(void *memtop); +void mem_reserve(void *addr, size_t len); +void mem_debugprint(void); + +// allocates `pages` consecutive pages +// TODO deprecate +void *page_alloc(size_t pages); +// zeroes the allocated pages +void *page_zalloc(size_t pages); + +// frees `pages` consecutive pages starting from *first +void page_free(void *first, size_t pages); + +void kmalloc_sanity(const void *addr); +void *kmalloc(size_t len); +void kfree(void *ptr); + +static inline void *kzalloc(size_t len) { + void *b = kmalloc(len); + memset(b, 0, len); + return b; +} -- cgit v1.2.3