Unmaps the given page and adds all freed frames to the given `FrameAllocator`.
(&mut self, page: Page, allocator: &mut A)
| 101 | |
| 102 | /// Unmaps the given page and adds all freed frames to the given `FrameAllocator`. |
| 103 | pub fn unmap<A>(&mut self, page: Page, allocator: &mut A) |
| 104 | where A: FrameAllocator |
| 105 | { |
| 106 | use x86_64::VirtualAddress; |
| 107 | use x86_64::instructions::tlb; |
| 108 | |
| 109 | assert!(self.translate(page.start_address()).is_some()); |
| 110 | |
| 111 | let p1 = self.p4_mut() |
| 112 | .next_table_mut(page.p4_index()) |
| 113 | .and_then(|p3| p3.next_table_mut(page.p3_index())) |
| 114 | .and_then(|p2| p2.next_table_mut(page.p2_index())) |
| 115 | .expect("mapping code does not support huge pages"); |
| 116 | let frame = p1[page.p1_index()].pointed_frame().unwrap(); |
| 117 | p1[page.p1_index()].set_unused(); |
| 118 | |
| 119 | // flush page address from the TLB |
| 120 | tlb::flush(VirtualAddress(page.start_address())); |
| 121 | |
| 122 | // TODO free p(1,2,3) table if empty |
| 123 | // allocator.deallocate_frame(frame); |
| 124 | } |
| 125 | } |
no test coverage detected