forked from Bananymous/banan-os
Kernel: MMU keeps track of the current
This commit is contained in:
parent
d82c6c2337
commit
31ac3260ed
|
@ -18,6 +18,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
static MMU* s_instance = nullptr;
|
static MMU* s_instance = nullptr;
|
||||||
|
static MMU* s_current = nullptr;
|
||||||
|
|
||||||
void MMU::initialize()
|
void MMU::initialize()
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,12 @@ namespace Kernel
|
||||||
return *s_instance;
|
return *s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMU& MMU::current()
|
||||||
|
{
|
||||||
|
ASSERT(s_current);
|
||||||
|
return *s_current;
|
||||||
|
}
|
||||||
|
|
||||||
static uint64_t* allocate_page_aligned_page()
|
static uint64_t* allocate_page_aligned_page()
|
||||||
{
|
{
|
||||||
void* page = kmalloc(PAGE_SIZE, PAGE_SIZE);
|
void* page = kmalloc(PAGE_SIZE, PAGE_SIZE);
|
||||||
|
@ -130,6 +137,7 @@ namespace Kernel
|
||||||
void MMU::load()
|
void MMU::load()
|
||||||
{
|
{
|
||||||
asm volatile("movq %0, %%cr3" :: "r"(m_highest_paging_struct));
|
asm volatile("movq %0, %%cr3" :: "r"(m_highest_paging_struct));
|
||||||
|
s_current = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMU::identity_map_page(paddr_t address, flags_t flags)
|
void MMU::identity_map_page(paddr_t address, flags_t flags)
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace Kernel
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static MMU& get();
|
static MMU& get();
|
||||||
|
|
||||||
|
static MMU& current();
|
||||||
|
|
||||||
MMU();
|
MMU();
|
||||||
~MMU();
|
~MMU();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue