fix map_kernel on riscv32

master
WangRunji 6 years ago
parent 46e7a61ba7
commit 0965d24083

@ -243,16 +243,23 @@ impl InactivePageTable for InactivePageTable0 {
#[cfg(target_arch = "riscv32")] #[cfg(target_arch = "riscv32")]
fn map_kernel(&mut self) { fn map_kernel(&mut self) {
let table = unsafe { &mut *ROOT_PAGE_TABLE }; let table = unsafe { &mut *ROOT_PAGE_TABLE };
let e0 = table[0x40]; extern {
let e1 = table[KERNEL_P2_INDEX]; fn start();
let e2 = table[KERNEL_P2_INDEX + 1]; fn end();
let e3 = table[KERNEL_P2_INDEX + 2]; }
let mut entrys: [PageTableEntry; 16] = unsafe { core::mem::uninitialized() };
let entry_start = start as usize >> 22;
let entry_end = (end as usize >> 22) + 1;
let entry_count = entry_end - entry_start;
for i in 0..entry_count {
entrys[i] = table[entry_start + i];
}
self.edit(|_| { self.edit(|_| {
table[0x40] = e0; // NOTE: 'table' now refers to new page table
table[KERNEL_P2_INDEX] = e1; for i in 0..entry_count {
table[KERNEL_P2_INDEX + 1] = e2; table[entry_start + i] = entrys[i];
table[KERNEL_P2_INDEX + 2] = e3; }
}); });
} }

Loading…
Cancel
Save