From: Tulio A M Mendes Date: Thu, 5 Feb 2026 22:40:53 +0000 (-0300) Subject: mm: use hal_cpu_idle for heap corruption halts X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=d546d392cee998489fcb4abae3dc6c36ad7ffa5f;p=AdrOS.git mm: use hal_cpu_idle for heap corruption halts --- diff --git a/src/mm/heap.c b/src/mm/heap.c index 026d441b..60f9c9a8 100644 --- a/src/mm/heap.c +++ b/src/mm/heap.c @@ -8,11 +8,12 @@ */ #include "heap.h" -#include "pmm.h" -#include "vmm.h" #include "uart_console.h" - +#include "pmm.h" #include "spinlock.h" +#include "hal/cpu.h" +#include +#include // Heap starts at 3GB + 256MB #define KHEAP_START 0xD0000000 @@ -42,7 +43,7 @@ void check_integrity(heap_header_t* header) { uart_print("Block at: "); // TODO: print address uart_print(" has invalid magic number.\n"); - for(;;) __asm__("hlt"); + for(;;) hal_cpu_idle(); } } void kheap_init(void) { @@ -100,7 +101,7 @@ void* kmalloc(size_t size) { if (current->magic != HEAP_MAGIC) { spin_unlock_irqrestore(&heap_lock, flags); uart_print("[HEAP] Corruption Detected in kmalloc scan!\n"); - for(;;) __asm__("hlt"); + for(;;) hal_cpu_idle(); } if (current->is_free && current->size >= aligned_size) { @@ -148,7 +149,7 @@ void kfree(void* ptr) { if (header->magic != HEAP_MAGIC) { spin_unlock_irqrestore(&heap_lock, flags); uart_print("[HEAP] Corruption Detected in kfree!\n"); - for(;;) __asm__("hlt"); + for(;;) hal_cpu_idle(); } header->is_free = 1;