Add map and identity_map functions for convenience

This commit is contained in:
Philipp Oppermann
2017-04-13 19:23:49 +02:00
parent bb473c7907
commit 3696c7bacb

View File

@@ -120,4 +120,18 @@ impl ActivePageTable {
assert!(p1[page.p1_index()].is_unused()); assert!(p1[page.p1_index()].is_unused());
p1[page.p1_index()].set(frame, flags | PRESENT); p1[page.p1_index()].set(frame, flags | PRESENT);
} }
pub fn map<A>(&mut self, page: Page, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator
{
let frame = allocator.allocate_frame().expect("out of memory");
self.map_to(page, frame, flags, allocator)
}
pub fn identity_map<A>(&mut self, frame: Frame, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator
{
let page = Page::containing_address(frame.start_address());
self.map_to(page, frame, flags, allocator)
}
} }