1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 00:16:17 +04:00

Refactored RISC-V page table identity mapping into a function.

This commit is contained in:
dzy 2018-09-14 21:43:16 +08:00
parent 11223957d1
commit 5a0ce1e464
2 changed files with 7 additions and 5 deletions

@ -1 +1 @@
Subproject commit ed6e4c5b935d9d027303da829a7508c105df3139
Subproject commit 48dffe3f9aa6404a1bfe53de6645b53401d7499e

View File

@ -17,9 +17,11 @@ pub fn setup_page_table(frame: Frame) {
p2.set_recursive(RECURSIVE_PAGE_PML4, frame.clone());
// Set kernel identity map
p2[0x40].set(Frame::of_addr(PhysAddr::new(0x10000000)), EF::VALID | EF::READABLE | EF::WRITABLE);
p2[KERNEL_PML4].set(Frame::of_addr(PhysAddr::new((KERNEL_PML4 as u32) << 22)), EF::VALID | EF::READABLE | EF::WRITABLE | EF::EXECUTABLE);
p2[KERNEL_PML4 + 1].set(Frame::of_addr(PhysAddr::new((KERNEL_PML4 as u32 + 1) << 22)), EF::VALID | EF::READABLE | EF::WRITABLE | EF::EXECUTABLE);
// 0x10000000 ~ 1K area
p2.map_identity(0x40, EF::VALID | EF::READABLE | EF::WRITABLE);
// 0x80000000 ~ 8K area
p2.map_identity(KERNEL_PML4, EF::VALID | EF::READABLE | EF::WRITABLE | EF::EXECUTABLE);
p2.map_identity(KERNEL_PML4 + 1, EF::VALID | EF::READABLE | EF::WRITABLE | EF::EXECUTABLE);
use super::riscv::register::satp;
unsafe { satp::set(satp::Mode::Sv32, 0, frame); }
@ -249,4 +251,4 @@ impl FrameDeallocator for FrameAllocatorForRiscv {
fn dealloc(&mut self, frame: Frame) {
dealloc_frame(frame.start_address().as_u32() as usize);
}
}
}