Mercurial > lcfOS
diff cos/kernel/malloc.c @ 28:47b7df514243
Moved Makefiles
author | windel |
---|---|
date | Wed, 28 Dec 2011 13:38:43 +0100 |
parents | dcce92b1efbc |
children | 7e3bdcb391dc |
line wrap: on
line diff
--- a/cos/kernel/malloc.c Tue Dec 27 18:59:02 2011 +0100 +++ b/cos/kernel/malloc.c Wed Dec 28 13:38:43 2011 +0100 @@ -1,5 +1,32 @@ #include "kernel.h" +// ================= Placement malloc: +extern uint64_t end; +uint64_t placement_address = (uint64_t)&end; + +void* kmalloc_int(uint64_t size) +{ + uint64_t tmp = placement_address; + placement_address += size; + return (void*)tmp; +} + +void* kmalloc_aligned_int(uint64_t size) +{ + if ( (placement_address | 0xFFF) != 0 ) + { + placement_address &= ~(0xFFF); + placement_address += 0x1000; + } + uint64_t tmp = placement_address; + placement_address += size; + return (void*)tmp; +} + + +// ================= Other malloc +// TODO: move this to user space? + #define HEAP_MAGIC 0xc0ffee #define HEAP_START 0x400000 #define HEAP_SIZE 0x200000 @@ -17,6 +44,7 @@ of the kernel into smaller parts. The heap is located at: 0x */ + static heap_t* kernel_heap = (heap_t*) 0x400000; // 4 MB - 6 MB is heap /* Allocates 'size' bytes and returns the pointer if succesfull. Kernelpanic in case of failure..