mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Switch to the new page table after mapping all sections
This commit is contained in:
@@ -104,6 +104,21 @@ impl ActivePageTable {
|
|||||||
temporary_page.unmap(self);
|
temporary_page.unmap(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn switch(&mut self, new_table: InactivePageTable) -> InactivePageTable {
|
||||||
|
use x86_64::PhysicalAddress;
|
||||||
|
use x86_64::registers::control_regs;
|
||||||
|
|
||||||
|
let old_table = InactivePageTable {
|
||||||
|
p4_frame: Frame::containing_address(
|
||||||
|
control_regs::cr3().0 as usize
|
||||||
|
),
|
||||||
|
};
|
||||||
|
unsafe {
|
||||||
|
control_regs::cr3_write(PhysicalAddress(
|
||||||
|
new_table.p4_frame.start_address() as u64));
|
||||||
|
}
|
||||||
|
old_table
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InactivePageTable {
|
pub struct InactivePageTable {
|
||||||
@@ -167,4 +182,7 @@ pub fn remap_the_kernel<A>(allocator: &mut A, boot_info: &BootInformation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let old_table = active_table.switch(new_table);
|
||||||
|
println!("NEW TABLE!!!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user