MCPcopy Create free account
hub / github.com/Infinity-OS/infinity / unmap

Method unmap

src/memory/paging/mapper.rs:103–124  ·  view source on GitHub ↗

Unmaps the given page and adds all freed frames to the given `FrameAllocator`.

(&mut self, page: Page, allocator: &mut A)

Source from the content-addressed store, hash-verified

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}

Callers 3

withMethod · 0.45
newMethod · 0.45
remap_the_kernelFunction · 0.45

Calls 9

next_table_mutMethod · 0.80
p4_mutMethod · 0.80
p4_indexMethod · 0.80
p3_indexMethod · 0.80
p2_indexMethod · 0.80
pointed_frameMethod · 0.80
p1_indexMethod · 0.80
set_unusedMethod · 0.80
start_addressMethod · 0.45

Tested by

no test coverage detected