diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index 8ebe0b98..dffbd6cd 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -99,6 +99,17 @@ namespace MemoryManager init_physical_frame_allocator(); KernelVM::init(); MMU::setup_initial_page_directory(); + + // NOTE: We force these operations to succeed, because if we can't map the frame bitmap to virtual memory + // there's no point in continuing. + auto bitmap_pages = g_frame_bitmap.size_in_bytes() / ARCH_PAGE_SIZE; + + auto virtual_bitmap_base = KernelVM::alloc_several_pages(bitmap_pages).release_value(); + map_frames_at(virtual_bitmap_base, (u64)g_frame_bitmap.location(), bitmap_pages, + MMU::ReadWrite | MMU::NoExecute) + .release_value(); + + g_frame_bitmap.initialize((void*)virtual_bitmap_base, g_frame_bitmap.size_in_bytes()); } void lock_frame(u64 frame)