From dad95a81601a1f40814ea774861a215c90b2c4cb Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 7 Dec 2022 10:58:59 +0100 Subject: [PATCH] Map the page bitmap to virtual memory --- kernel/src/memory/MemoryManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)