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

View File

@@ -12,6 +12,8 @@
#include "io/kbd/ps2.h"
#include "mem/paging/pmm.h"
#include "mem/paging/paging.h"
#include "mem/paging/vmm.h"
#include "mem/heap/kheap.h"
// Limine version used
__attribute__((used, section(".limine_requests")))
@@ -53,8 +55,8 @@ static volatile LIMINE_REQUESTS_END_MARKER;
struct limine_framebuffer* framebuffer;
// Panic
static void hcf()
// Panic (should dump registers etc. in the future)
void hcf()
{
for (;;)
{
@@ -92,7 +94,18 @@ void kmain()
SET_INTERRUPTS;
pmm_init(memmap_request.response, hhdm_request.response);
// Remap kernel , HHDM and framebuffer
paging_init(kerneladdr_request.response, framebuffer);
kheap_init();
void* ptr = kmalloc(10); DEBUG("(KMALLOC TEST) Allocated 10 bytes at 0x%p", ptr);
void* ptr2 = kmalloc(200); DEBUG("(KMALLOC TEST) Allocated 200 bytes at 0x%p", ptr2);
kfree(ptr);
void* ptr3 = kmalloc(5); DEBUG("(KMALLOC TEST) Allocated 5 bytes at 0x%p", ptr3);
vmm_init();
keyboard_init(FR);