#include "headers/kheap.h" #include #include // end is defined in the linker extern uint32_t end; uint32_t placement_address = (uint32_t)&end; uint32_t kmalloc(size_t sz, int align, uint32_t *phys) { if( align == 1 && (placement_address & 0xFFFFF000)) // if not page aligned { placement_address &= 0xFFFFF000; placement_address += 0x1000; } if(phys) { *phys = placement_address; } uint32_t tmp = placement_address; placement_address += sz; return tmp; } uint32_t kmalloc_a(size_t sz) { return kmalloc(sz,1,0); } uint32_t kmalloc_p(size_t sz, uint32_t *phys) { return kmalloc(sz,0,phys); } uint32_t kmalloc_ap(size_t sz, uint32_t *phys) { return kmalloc(sz,1,phys); }