Add page table lookup in pagefault.

master
Yuhao Zhou 6 years ago
parent 6cc607e0c8
commit 6038004576

@ -1,6 +1,9 @@
use mips::interrupts; use mips::interrupts;
use mips::tlb;
use mips::registers::cp0; use mips::registers::cp0;
use crate::drivers::DRIVERS; use crate::drivers::DRIVERS;
use mips::paging::{PageTable as MIPSPageTable, PageTableEntry, PageTableFlags as EF, TwoLevelPageTable};
use mips::addr::*;
pub use self::context::*; pub use self::context::*;
use log::*; use log::*;
@ -141,5 +144,10 @@ fn page_fault(tf: &mut TrapFrame) {
crate::trap::error(tf); crate::trap::error(tf);
} }
let virt_addr = VirtAddr::new(addr);
let root_table = unsafe {
&mut *(root_page_table_ptr as *mut MIPSPageTable)
};
let tlb_entry = root_table.lookup(addr);
tlb::write_tlb_random(tlb_entry);
} }

@ -21,7 +21,7 @@ mod stdio;
#[cfg(feature = "link_user")] #[cfg(feature = "link_user")]
global_asm!(concat!( global_asm!(concat!(
r#" r#"
.section .data .section .data.img
.global _user_img_start .global _user_img_start
.global _user_img_end .global _user_img_end
_user_img_start: _user_img_start:
@ -57,7 +57,22 @@ lazy_static! {
println!("Sfs start {:x}, end {:x}", _user_img_start as usize, _user_img_end as usize); println!("Sfs start {:x}, end {:x}", _user_img_start as usize, _user_img_end as usize);
Arc::new(unsafe { device::MemBuf::new(_user_img_start, _user_img_end) }) Arc::new(unsafe { device::MemBuf::new(_user_img_start, _user_img_end) })
}; };
let device2 = {
extern {
fn _user_img_start();
fn _user_img_end();
}
Arc::new(unsafe { device::MemBuf::new(_user_img_start, _user_img_end) })
};
let super_block = SimpleFileSystem::read(device2);
println!("Superblock: magic = {:x}, freemap_blocks = {:x}", super_block.magic, super_block.freemap_blocks);
println!("blocks = {:}", super_block.blocks);
println!("unused_blocks = {:}", super_block.unused_blocks);
let sfs = SimpleFileSystem::open(device).expect("failed to open SFS"); let sfs = SimpleFileSystem::open(device).expect("failed to open SFS");
// println!("{:}", sfs.free_map.read());
sfs.root_inode() sfs.root_inode()
}; };
} }

Loading…
Cancel
Save