diff options
author | Danny Holman <dholman@gymli.org> | 2024-03-28 21:55:33 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-03-28 21:55:33 -0500 |
commit | 3b66779d9a8325c77c6cfbf1565885f98da5378f (patch) | |
tree | 38a1359cbaa1357479a8d57b7c206b190012e783 /include/kernel/kmalloc.h | |
parent | arch: i386: kernel: add mostly finished PFA and paging system (diff) | |
download | box-3b66779d9a8325c77c6cfbf1565885f98da5378f.tar.gz box-3b66779d9a8325c77c6cfbf1565885f98da5378f.tar.zst box-3b66779d9a8325c77c6cfbf1565885f98da5378f.zip |
arch: i386: kernel: implement a kmalloc function
Add a basic kmalloc implementation. This allows the kernel to allocate
blocks smaller than a whole page.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to '')
-rw-r--r-- | include/kernel/kmalloc.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/kernel/kmalloc.h b/include/kernel/kmalloc.h new file mode 100644 index 0000000..d8debd1 --- /dev/null +++ b/include/kernel/kmalloc.h @@ -0,0 +1,18 @@ +#ifndef KERNEL_KMALLOC_H +#define KERNEL_KMALLOC_H + +#include <stdint.h> +#include <stddef.h> + +struct mem_block { + uintptr_t start; + size_t size; + int alloc; + struct mem_block *next; +}; + +void kmalloc_init(void); +void* kmalloc(size_t sz); +void kfree(void *ptr); + +#endif |