Creates a PageTable containing only kernel pages - Copies the kernel pagetables into a new set of tables - Adds the KernelInfo read-only page Returns ------- - A pointer to the PageTable (virtual address in kernel mapped pages) - The physical address which can be written to cr3
()
| 181 | /// - The physical address which can be written to cr3 |
| 182 | /// |
| 183 | pub fn create_new_user_pagetable() -> (*mut PageTable, u64) { |
| 184 | let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()}; |
| 185 | |
| 186 | // Copy kernel pages |
| 187 | let (user_page_table_ptr, user_page_table_physaddr) = |
| 188 | copy_pagetables(memory_info.kernel_l4_table); |
| 189 | |
| 190 | // Add KernelInfo page |
| 191 | let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()}; |
| 192 | let mut mapper = unsafe { |
| 193 | OffsetPageTable::new(&mut *user_page_table_ptr, |
| 194 | memory_info.physical_memory_offset)}; |
| 195 | _ = kernel_info::add_to_user_table(&mut mapper, |
| 196 | &mut memory_info.frame_allocator); |
| 197 | |
| 198 | (user_page_table_ptr, user_page_table_physaddr) |
| 199 | } |
| 200 | |
| 201 | /// Switch to the specified page table |
| 202 | /// |
no test coverage detected