diff options
Diffstat (limited to 'src/kernel/memory')
-rw-r--r-- | src/kernel/memory/alloc.c | 10 | ||||
-rw-r--r-- | src/kernel/memory/paging.c | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/kernel/memory/alloc.c b/src/kernel/memory/alloc.c index f03c0f5..098eb75 100644 --- a/src/kernel/memory/alloc.c +++ b/src/kernel/memory/alloc.c @@ -5,6 +5,7 @@ #include <kernel/system.h> #include <kernel/lib/lib.h> +extern uint32_t end; uint32_t placement_address; struct heap_header *kheap = NULL; @@ -12,7 +13,8 @@ struct heap_header *uheap = NULL; void kheap_init() { - placement_address = &ASM_KERNEL_END; + end = &end; + placement_address = end; kheap = (struct heap_header *)fmalloc(KHEAP_SIZE); init_heap(kheap, KHEAP_SIZE); @@ -24,7 +26,7 @@ void kheap_init() void *fmalloc(uint32_t size) { - //assert(placement_address + size < MEM_END); + assert(placement_address + size < MEM_END); uint32_t hold = placement_address; memset((void *)hold, 0, size); placement_address += size; @@ -33,7 +35,7 @@ void *fmalloc(uint32_t size) void *kmalloc_a(uint32_t size) { - //assert(((placement_address & 0xFFFFF000) + 0x1000) + size < MEM_END); + assert(((placement_address & 0xFFFFF000) + 0x1000) + size < MEM_END); placement_address &= 0xFFFFF000; placement_address += 0x1000; @@ -94,7 +96,7 @@ void free_internal(struct heap_header *heap, void *address) { struct heap_header *head = (struct heap_header *)((uint32_t)address - HEAP_S); if (head == heap) { - warn("Can't collapse top of heap"); + //warn("Can't collapse top of heap"); // TODO: Fix "can't collapse top of heap" at start head->free = true; return; } diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index ed06004..19ec11d 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -126,7 +126,7 @@ void paging_install() info("Installed paging"); // Test mallocing - uintptr_t a = (uintptr_t)kmalloc(4096); // TODO: Fix "can't collapse top of heap" + uintptr_t a = (uintptr_t)kmalloc(4096); uintptr_t b = (uintptr_t)kmalloc(4096); kfree((void *)b); kfree((void *)a); |