From 051596d8f93926a8325724781d862adb4c02fef6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 31 Dec 2015 03:38:49 +0100 Subject: [PATCH] Try to switch tables, causes boot loop --- src/memory/paging/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/memory/paging/mod.rs b/src/memory/paging/mod.rs index 2393160c..bf11fc2a 100644 --- a/src/memory/paging/mod.rs +++ b/src/memory/paging/mod.rs @@ -109,6 +109,18 @@ impl ActivePageTable { temporary_page.unmap(self); } + + pub fn switch(&mut self, new_table: InactivePageTable) -> InactivePageTable { + use x86::controlregs; + + let old_table = InactivePageTable { + p4_frame: Frame::containing_address(unsafe { controlregs::cr3() } as usize), + }; + unsafe { + controlregs::cr3_write(new_table.p4_frame.start_address() as u64); + } + old_table + } } pub struct InactivePageTable { @@ -205,4 +217,7 @@ pub fn remap_the_kernel(allocator: &mut A, boot_info: &BootInformation) } } }); + + let old_table = active_table.switch(new_table); + println!("NEW TABLE!!!"); }