This should only be called from the init function because each call will result in a mutable reference
(physical_memory_offset: VirtAddr)
| 88 | /// This should only be called from the init function |
| 89 | /// because each call will result in a mutable reference |
| 90 | unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) |
| 91 | -> &'static mut PageTable { |
| 92 | use x86_64::registers::control::Cr3; |
| 93 | |
| 94 | let (level_4_table_frame, _) = Cr3::read(); |
| 95 | |
| 96 | let phys = level_4_table_frame.start_address(); |
| 97 | let virt = physical_memory_offset + phys.as_u64(); |
| 98 | let page_table_ptr: *mut PageTable = virt.as_mut_ptr(); |
| 99 | |
| 100 | &mut *page_table_ptr // unsafe |
| 101 | } |
| 102 | |
| 103 | /// Create a new page table |
| 104 | /// |
no test coverage detected