Load a very simple ELF and launch it in usermode
This commit is contained in:
parent
398838dc1b
commit
850792bbf1
11 changed files with 201 additions and 59 deletions
|
@ -46,6 +46,15 @@ impl Mapper {
|
|||
self.map_to(page, frame, flags)
|
||||
}
|
||||
|
||||
/// Update flags for a page
|
||||
pub fn remap(&mut self, page: Page, flags: EntryFlags) {
|
||||
let mut p3 = self.p4_mut().next_table_mut(page.p4_index()).expect("failed to remap: no p3");
|
||||
let mut p2 = p3.next_table_mut(page.p3_index()).expect("failed to remap: no p2");
|
||||
let mut p1 = p2.next_table_mut(page.p2_index()).expect("failed to remap: no p1");
|
||||
let frame = p1[page.p1_index()].pointed_frame().expect("failed to remap: not mapped");
|
||||
p1[page.p1_index()].set(frame, flags | entry::PRESENT);
|
||||
}
|
||||
|
||||
/// Identity map a frame
|
||||
pub fn identity_map(&mut self, frame: Frame, flags: EntryFlags) {
|
||||
let page = Page::containing_address(VirtualAddress::new(frame.start_address().get()));
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<L> Table<L> where L: HierarchicalLevel {
|
|||
assert!(!self[index].flags().contains(HUGE_PAGE),
|
||||
"mapping code does not support huge pages");
|
||||
let frame = allocate_frame().expect("no frames available");
|
||||
self[index].set(frame, PRESENT | WRITABLE);
|
||||
self[index].set(frame, PRESENT | WRITABLE | USER_ACCESSIBLE /* Allow users to go down the page table, implement permissions at the page level */);
|
||||
self.next_table_mut(index).unwrap().zero();
|
||||
}
|
||||
self.next_table_mut(index).unwrap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue