PMM: Map the page bitmap to kernel heap once the PMM and VMM are both initialized

This commit is contained in:
apio 2022-10-04 18:36:09 +02:00
parent 5d8b825659
commit 8f310dd307
4 changed files with 21 additions and 0 deletions

View File

@ -20,4 +20,8 @@ namespace PMM
uint64_t get_free(); uint64_t get_free();
uint64_t get_used(); uint64_t get_used();
uint64_t get_reserved(); uint64_t get_reserved();
uint64_t get_bitmap_size();
void map_bitmap_to_virtual();
}; };

View File

@ -1,3 +1,5 @@
#define MODULE "init"
#include "init/Init.h" #include "init/Init.h"
#include "assert.h" #include "assert.h"
#include "bootboot.h" #include "bootboot.h"
@ -57,6 +59,8 @@ void Init::early_init()
Mersenne::init(); Mersenne::init();
kdbgln("Page bitmap uses %ld bytes of memory", PMM::get_bitmap_size());
__stack_chk_guard = Mersenne::get(); __stack_chk_guard = Mersenne::get();
} }

View File

@ -13,6 +13,7 @@ void MemoryManager::init()
{ {
PMM::init(); PMM::init();
kernelVMM.init(); kernelVMM.init();
PMM::map_bitmap_to_virtual();
} }
void* MemoryManager::get_mapping(void* physicalAddress, int flags) void* MemoryManager::get_mapping(void* physicalAddress, int flags)

View File

@ -5,6 +5,7 @@
#include "bootboot.h" #include "bootboot.h"
#include "memory/Memory.h" #include "memory/Memory.h"
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include "misc/utils.h"
#include "std/string.h" #include "std/string.h"
extern BOOTBOOT bootboot; extern BOOTBOOT bootboot;
@ -169,4 +170,15 @@ uint64_t PMM::get_used()
uint64_t PMM::get_reserved() uint64_t PMM::get_reserved()
{ {
return reserved_mem; 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));
} }