mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel/aarch64: Keep track of root page table and kernel directory table
This commit is contained in:
parent
697c5ca5e5
commit
d9946c8e89
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/FireFox317 Commit: https://github.com/SerenityOS/serenity/commit/d9946c8e89 Pull-request: https://github.com/SerenityOS/serenity/pull/16911 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/nico ✅
1 changed files with 17 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue