Small kernel heap for VMM internals, kmalloc/kfree

This commit is contained in:
2026-01-03 13:48:10 +01:00
parent c065df6ff3
commit e18b73c8a0
11 changed files with 322 additions and 30 deletions

26
src/mem/heap/kheap.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef KHEAP_H
#define KHEAP_H
// We need some kind of simple kernel heap to make our linked list
// for the VMM, as we need "malloc" and "free" for that data structure.
// When the kernel heap is ready, we can alloc our VM object linked list
// and then continue working on the VMM.
// 16MB should be enough for some linked lists
#define KHEAP_SIZE (16*1024*1024)
#include <stdbool.h>
#include <stddef.h>
struct heap_block_t
{
size_t size;
bool free;
struct heap_block_t* next;
};
void kheap_init();
void* kmalloc(size_t size);
void kfree(void* ptr);
#endif