diff --git a/kernel/src/arch/MMU.h b/kernel/src/arch/MMU.h index 095ed40a..cc0b6b42 100644 --- a/kernel/src/arch/MMU.h +++ b/kernel/src/arch/MMU.h @@ -32,4 +32,6 @@ namespace MMU Result create_page_directory_for_userspace(); void setup_initial_page_directory(); + + PageDirectory* kernel_page_directory(); } \ No newline at end of file diff --git a/kernel/src/arch/x86_64/MMU.cpp b/kernel/src/arch/x86_64/MMU.cpp index c381b7d9..a985df7b 100644 --- a/kernel/src/arch/x86_64/MMU.cpp +++ b/kernel/src/arch/x86_64/MMU.cpp @@ -7,6 +7,8 @@ #pragma GCC push_options #pragma GCC diagnostic ignored "-Wconversion" +PageDirectory* g_kernel_directory; + void PageTableEntry::set_address(u64 addr) { this->address = (addr >> 12); @@ -259,6 +261,7 @@ namespace MMU void setup_initial_page_directory() { PageDirectory* const dir = get_page_directory(); + g_kernel_directory = dir; const u64 paddr = (u64)dir; PageTableEntry& recursive_entry = dir->entries[rindex]; recursive_entry.read_write = true; @@ -266,4 +269,9 @@ namespace MMU recursive_entry.set_address(paddr); flush_all(); } + + PageDirectory* kernel_page_directory() + { + return g_kernel_directory; + } } \ No newline at end of file