x86_64: Add a getter for the initial page directory
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2022-12-26 12:57:25 +01:00
parent 2600acc96c
commit a1eca479d5
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 10 additions and 0 deletions

View File

@ -32,4 +32,6 @@ namespace MMU
Result<PageDirectory*> create_page_directory_for_userspace(); Result<PageDirectory*> create_page_directory_for_userspace();
void setup_initial_page_directory(); void setup_initial_page_directory();
PageDirectory* kernel_page_directory();
} }

View File

@ -7,6 +7,8 @@
#pragma GCC push_options #pragma GCC push_options
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"
PageDirectory* g_kernel_directory;
void PageTableEntry::set_address(u64 addr) void PageTableEntry::set_address(u64 addr)
{ {
this->address = (addr >> 12); this->address = (addr >> 12);
@ -259,6 +261,7 @@ namespace MMU
void setup_initial_page_directory() void setup_initial_page_directory()
{ {
PageDirectory* const dir = get_page_directory(); PageDirectory* const dir = get_page_directory();
g_kernel_directory = dir;
const u64 paddr = (u64)dir; const u64 paddr = (u64)dir;
PageTableEntry& recursive_entry = dir->entries[rindex]; PageTableEntry& recursive_entry = dir->entries[rindex];
recursive_entry.read_write = true; recursive_entry.read_write = true;
@ -266,4 +269,9 @@ namespace MMU
recursive_entry.set_address(paddr); recursive_entry.set_address(paddr);
flush_all(); flush_all();
} }
PageDirectory* kernel_page_directory()
{
return g_kernel_directory;
}
} }