From 11501f6f0c82712ea5f172f9177f2375c87d06e9 Mon Sep 17 00:00:00 2001 From: Nathan Lee Date: Sun, 30 Aug 2026 22:46:22 -0500 Subject: add buddy allocator and remove the old freelist allocator - todo later: add other allocators (vmalloc + multi-page allocator) - todo later: initialize memory pages - the current kmalloc will not work anyways --- include/sys/mem.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/sys/mem.h b/include/sys/mem.h index e5637f6..0cc509f 100644 --- a/include/sys/mem.h +++ b/include/sys/mem.h @@ -1,19 +1,22 @@ #pragma once #include +#define PAGE_SIZE 4096 +#define EHEAP_SIZE (512 * 1024) + struct mem_info { void* start; size_t size; }; -enum PageStatus { - MEMPAGE_FREE, MEMPAGE_USED +enum AllocationType { + MEMPAGE_FREEPAGE, MEMPAGE_ROUNDPAGE, MEMPAGE_VIRTUAL }; -struct page { - struct page* next; +struct free_list { + struct free_list *next; + struct free_list *prev; size_t size; - enum PageStatus status; }; struct mmio_device_meta { @@ -22,10 +25,9 @@ struct mmio_device_meta { size_t size; }; -void* kmalloc(size_t size); void* kemalloc(size_t size); -void* kzalloc(size_t size); -void kfree(void* ptr); -void km_init(struct mem_info *info); +void* kmalloc(size_t size, enum AllocationType type); +void* kzalloc(size_t size, enum AllocationType type); +void kfree(void* ptr); -- cgit v1.2.3