summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNathan Lee <me@nwlee.tech>2026-08-30 22:46:22 -0500
committerNathan Lee <me@nwlee.tech>2026-08-30 22:46:22 -0500
commit11501f6f0c82712ea5f172f9177f2375c87d06e9 (patch)
tree681d22d421d9136002c8d9f385705df81d5c82aa /include
parentdd825ef769c107d86b80ede076e90cca3cf303b2 (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/sys/mem.h20
1 files changed, 11 insertions, 9 deletions
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 <sys/stddef.h>
+#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);