From 0f54f0de1004c6e9a455c295dc76879ac37a408f Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 29 Apr 2020 21:16:56 +0200 Subject: Fixed several warnings, errors and dumb bugs --- src/kernel/memory/alloc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/kernel/memory/alloc.c') 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 #include +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; } -- cgit v1.2.3