diff options
author | Timon Kruiper <timonkruiper@gmail.com> | 2023-01-24 19:22:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-27 11:41:43 +0100 |
commit | d9946c8e8968428b30350ff944b46f82ac400bd4 (patch) | |
tree | e9f6e01e11683114a31278d37b1932f80345f263 /Kernel/Arch | |
parent | 697c5ca5e59cf25a39c7190674781d1175f52bbf (diff) | |
download | serenity-d9946c8e8968428b30350ff944b46f82ac400bd4.zip |
Kernel/aarch64: Keep track of root page table and kernel directory table
Diffstat (limited to 'Kernel/Arch')
-rw-r--r-- | Kernel/Arch/aarch64/MMU.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/MMU.cpp b/Kernel/Arch/aarch64/MMU.cpp index dd17158455..cb21eda2fd 100644 --- a/Kernel/Arch/aarch64/MMU.cpp +++ b/Kernel/Arch/aarch64/MMU.cpp @@ -239,6 +239,17 @@ static u64* get_page_directory(u64* root_table, VirtualAddress virtual_addr) return descriptor_to_pointer(level2_table[level1_idx]); } +static u64* get_page_directory_table(u64* root_table, VirtualAddress virtual_addr) +{ + u64 level0_idx = (virtual_addr.get() >> 39) & 0x1FF; + u64* level1_table = root_table; + + if (level1_table[level0_idx] == 0) + return nullptr; + + return descriptor_to_pointer(level1_table[level0_idx]); +} + static void setup_kernel_page_directory(u64* root_table) { auto kernel_page_directory = (PhysicalPtr)get_page_directory(root_table, VirtualAddress { *adjust_by_mapping_base(&kernel_mapping_base) }); @@ -246,6 +257,12 @@ static void setup_kernel_page_directory(u64* root_table) panic_without_mmu("Could not find kernel page directory!"sv); *adjust_by_mapping_base(&boot_pd_kernel) = PhysicalAddress(kernel_page_directory); + + // FIXME: Rename boot_pml4t to something architecture agnostic. + *adjust_by_mapping_base(&boot_pml4t) = PhysicalAddress((PhysicalPtr)root_table); + + // FIXME: Rename to directory_table or similar + *adjust_by_mapping_base(&boot_pdpt) = PhysicalAddress((PhysicalPtr)get_page_directory_table(root_table, VirtualAddress { *adjust_by_mapping_base(&kernel_mapping_base) })); } void init_page_tables() |