Switch context
(&mut self, new_table: InactivePageTable)
| 143 | |
| 144 | /// Switch context |
| 145 | pub fn switch(&mut self, new_table: InactivePageTable) -> InactivePageTable { |
| 146 | use x86_64::PhysicalAddress; |
| 147 | use x86_64::registers::control_regs; |
| 148 | |
| 149 | // store the ond table |
| 150 | let old_table = InactivePageTable { |
| 151 | p4_frame: Frame::containing_address(control_regs::cr3().0 as usize), |
| 152 | }; |
| 153 | |
| 154 | // switch to the new page table |
| 155 | unsafe { |
| 156 | control_regs::cr3_write(PhysicalAddress(new_table.p4_frame.start_address() as u64)); |
| 157 | } |
| 158 | |
| 159 | // return the old table |
| 160 | old_table |
| 161 | } |
| 162 | |
| 163 | /// Flush all the TLB table |
| 164 | pub fn flush_all(&mut self) { |
no test coverage detected