diff --git a/kernel/include/memory/PMM.h b/kernel/include/memory/PMM.h index f991e21f..991361d5 100644 --- a/kernel/include/memory/PMM.h +++ b/kernel/include/memory/PMM.h @@ -20,4 +20,8 @@ namespace PMM uint64_t get_free(); uint64_t get_used(); uint64_t get_reserved(); + + uint64_t get_bitmap_size(); + + void map_bitmap_to_virtual(); }; diff --git a/kernel/src/init/Init.cpp b/kernel/src/init/Init.cpp index 15085901..bb33881d 100644 --- a/kernel/src/init/Init.cpp +++ b/kernel/src/init/Init.cpp @@ -1,3 +1,5 @@ +#define MODULE "init" + #include "init/Init.h" #include "assert.h" #include "bootboot.h" @@ -57,6 +59,8 @@ void Init::early_init() Mersenne::init(); + kdbgln("Page bitmap uses %ld bytes of memory", PMM::get_bitmap_size()); + __stack_chk_guard = Mersenne::get(); } diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index 599c73fb..dbc02cb7 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -13,6 +13,7 @@ void MemoryManager::init() { PMM::init(); kernelVMM.init(); + PMM::map_bitmap_to_virtual(); } void* MemoryManager::get_mapping(void* physicalAddress, int flags) diff --git a/kernel/src/memory/PMM.cpp b/kernel/src/memory/PMM.cpp index a71e0cb5..459c6133 100644 --- a/kernel/src/memory/PMM.cpp +++ b/kernel/src/memory/PMM.cpp @@ -5,6 +5,7 @@ #include "bootboot.h" #include "memory/Memory.h" #include "memory/MemoryManager.h" +#include "misc/utils.h" #include "std/string.h" extern BOOTBOOT bootboot; @@ -169,4 +170,15 @@ uint64_t PMM::get_used() uint64_t PMM::get_reserved() { return reserved_mem; +} + +uint64_t PMM::get_bitmap_size() +{ + return bitmap_size; +} + +void PMM::map_bitmap_to_virtual() +{ + virtual_bitmap_addr = + (char*)MemoryManager::get_unaligned_mappings(bitmap_addr, Utilities::get_blocks_from_size(4096, bitmap_size)); } \ No newline at end of file