diff --git a/include/metalsvm/mmu.h b/include/metalsvm/mmu.h index cbc01f25..3deaff35 100644 --- a/include/metalsvm/mmu.h +++ b/include/metalsvm/mmu.h @@ -36,7 +36,7 @@ typedef struct { atomic_size_t usage; } mm_t; -void mmu_init(void); +int mmu_init(void); #ifdef __cplusplus } diff --git a/mm/memory.c b/mm/memory.c index 9118ac76..577b4573 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef USE_MULTIBOOT #include #endif @@ -71,7 +72,7 @@ inline static void page_unmarked(unsigned int i) bitmap[index] = bitmap[index] & ~(1 << mod); } -void mmu_init(void) +int mmu_init(void) { size_t kernel_size; unsigned int i; @@ -80,7 +81,7 @@ void mmu_init(void) memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); #ifdef USE_MULTIBOOT - if (mb_info) { + if (mb_info && (mb_info->flags & (1 << (6)))) { multiboot_memory_map_t* mmap = (multiboot_memory_map_t*) mb_info->mmap_addr; multiboot_memory_map_t* mmap_end = (void*) ((size_t) mb_info->mmap_addr + mb_info->mmap_length); @@ -99,6 +100,10 @@ void mmu_init(void) } mmap++; } + } else { + kputs("Unable to initialize the memory management subsystem\n"); + sleep(5); + return -1; } #else #error Currently, MetalSVM needs multiboot! @@ -114,6 +119,8 @@ void mmu_init(void) page_marked(i); alloc_start = (unsigned int) (&kernel_end) / PAGE_SIZE + 1; + + return 0; } static void* task_malloc(task_t* task, size_t sz)