Small kernel heap for VMM internals, kmalloc/kfree
This commit is contained in:
26
src/mem/heap/kheap.h
Normal file
26
src/mem/heap/kheap.h
Normal 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
|
||||
Reference in New Issue
Block a user