Create a new page table Returns ------- - A pointer to the PageTable (virtual address in kernel mapped pages) - The physical address which can be written to cr3
()
| 109 | /// - The physical address which can be written to cr3 |
| 110 | /// |
| 111 | fn create_empty_pagetable() -> (*mut PageTable, u64) { |
| 112 | // Need to borrow as mutable so that we can allocate new frames |
| 113 | // and so modify the frame allocator |
| 114 | let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()}; |
| 115 | |
| 116 | // Get a frame to store the level 4 table |
| 117 | let level_4_table_frame = memory_info.frame_allocator.allocate_frame().unwrap(); |
| 118 | let phys = level_4_table_frame.start_address(); // Physical address |
| 119 | let virt = memory_info.physical_memory_offset + phys.as_u64(); // Kernel virtual address |
| 120 | let page_table_ptr: *mut PageTable = virt.as_mut_ptr(); |
| 121 | |
| 122 | // Clear all entries in the page table |
| 123 | unsafe { |
| 124 | (*page_table_ptr).zero(); |
| 125 | } |
| 126 | |
| 127 | (page_table_ptr, phys.as_u64()) |
| 128 | } |
| 129 | |
| 130 | /// Copy a set of pagetables |
| 131 | fn copy_pagetables(level_4_table: &PageTable) -> (*mut PageTable, u64) { |
no test coverage detected