Begin creating an ActivePageTable::with function

This commit is contained in:
Philipp Oppermann
2017-04-18 12:00:17 +02:00
parent b2e79752fd
commit 4160cb6d7e

View File

@@ -157,6 +157,23 @@ impl ActivePageTable {
// TODO free p(1,2,3) table if empty
//allocator.deallocate_frame(frame);
}
pub fn with<F>(&mut self,
table: &mut InactivePageTable,
f: F)
where F: FnOnce(&mut ActivePageTable)
{
use x86_64::instructions::tlb;
// overwrite recursive mapping
self.p4_mut()[511].set(table.p4_frame.clone(), PRESENT | WRITABLE);
tlb::flush_all();
// execute f in the new context
f(self);
// TODO restore recursive mapping to original p4 table
}
}
pub struct InactivePageTable {