mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-21 23:56:18 +04:00
enable interrupt
This commit is contained in:
parent
b13833e0e9
commit
6906337068
@ -4,9 +4,10 @@ pub fn is_page_fault(trap: usize) -> bool {
|
||||
use cp0::cause::Exception as E;
|
||||
let cause = cp0::cause::Cause { bits: trap as u32 };
|
||||
match cause.cause() {
|
||||
E::TLBModification => true,
|
||||
E::TLBLoadMiss => true,
|
||||
E::TLBStoreMiss => true,
|
||||
E::TLBModification | E::TLBLoadMiss | E::TLBStoreMiss => {
|
||||
info!("{:#?}", cause.cause());
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,12 @@ pub fn init() {
|
||||
status.enable_soft_int1();
|
||||
// Enable clock interrupt
|
||||
status.enable_hard_int5();
|
||||
|
||||
// status.enable_hard_int4();
|
||||
// status.enable_hard_int3();
|
||||
// status.enable_hard_int2();
|
||||
// status.enable_hard_int1();
|
||||
// status.enable_hard_int0();
|
||||
// error!("{:#x?}", status);
|
||||
cp0::status::write(status);
|
||||
info!("interrupt: init end");
|
||||
}
|
||||
@ -79,9 +84,11 @@ pub extern "C" fn trap_handler(tf: &mut TrapFrame) {
|
||||
}
|
||||
|
||||
fn interrupt_dispatcher(tf: &mut TrapFrame) {
|
||||
/*
|
||||
let pint = tf.cause.pending_interrupt();
|
||||
trace!(" Interrupt {:08b} ", pint);
|
||||
let cause = cp0::cause::Cause {
|
||||
bits: tf.cause as u32,
|
||||
};
|
||||
let pint = cause.pending_interrupt();
|
||||
// trace!(" Interrupt {:08b} ", pint);
|
||||
if (pint & 0b100_000_00) != 0 {
|
||||
timer();
|
||||
} else if (pint & 0b011_111_00) != 0 {
|
||||
@ -89,7 +96,6 @@ fn interrupt_dispatcher(tf: &mut TrapFrame) {
|
||||
} else {
|
||||
ipi();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
fn external() {
|
||||
@ -242,6 +248,22 @@ pub fn handle_user_page_fault(thread: &Arc<Thread>, addr: usize) -> bool {
|
||||
} else {
|
||||
tlb_entry.entry_lo1.valid()
|
||||
};
|
||||
// thread.vm.lock().handle_page_fault(addr);
|
||||
// if !crate::memory::handle_page_fault(addr) {
|
||||
// extern "C" {
|
||||
// fn _copy_user_start();
|
||||
// fn _copy_user_end();
|
||||
// }
|
||||
// let mut inner = thread.inner.lock();
|
||||
// if let Some(tf) = &mut inner.context {
|
||||
// let mut tf = &mut tf.user;
|
||||
// if tf.epc >= _copy_user_start as usize && tf.epc < _copy_user_end as usize {
|
||||
// debug!("fixup for addr {:x?}", addr);
|
||||
// tf.epc = crate::memory::read_user_fixup as usize;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if !tlb_valid {
|
||||
if !thread.vm.lock().handle_page_fault(addr) {
|
||||
@ -261,7 +283,7 @@ pub fn handle_user_page_fault(thread: &Arc<Thread>, addr: usize) -> bool {
|
||||
fn page_fault(tf: &mut TrapFrame) {
|
||||
// TODO: set access/dirty bit
|
||||
let addr = tf.vaddr;
|
||||
trace!("\nEXCEPTION: Page Fault @ {:#x}", addr);
|
||||
// info!("\nEXCEPTION: Page Fault @ {:#x}", addr);
|
||||
|
||||
let virt_addr = VirtAddr::new(addr);
|
||||
let root_table = unsafe { &mut *(get_root_page_table_ptr() as *mut MIPSPageTable) };
|
||||
@ -330,3 +352,5 @@ pub fn wait_for_interrupt() {
|
||||
cp0::status::enable_interrupt();
|
||||
cp0::status::disable_interrupt();
|
||||
}
|
||||
|
||||
//2ea84
|
||||
|
@ -55,7 +55,7 @@ use xmas_elf::{
|
||||
pub type Tid = usize;
|
||||
|
||||
pub struct ThreadContext {
|
||||
user: Box<UserContext>,
|
||||
pub user: Box<UserContext>,
|
||||
/// TODO: lazy fp
|
||||
fp: Box<FpState>,
|
||||
}
|
||||
@ -65,7 +65,7 @@ pub struct ThreadContext {
|
||||
pub struct ThreadInner {
|
||||
/// user context
|
||||
/// None when thread is running in user
|
||||
context: Option<ThreadContext>,
|
||||
pub context: Option<ThreadContext>,
|
||||
/// Kernel performs futex wake when thread exits.
|
||||
/// Ref: [http://man7.org/linux/man-pages/man2/set_tid_address.2.html]
|
||||
pub clear_child_tid: usize,
|
||||
@ -311,8 +311,12 @@ impl Thread {
|
||||
}
|
||||
#[cfg(target_arch = "mips")]
|
||||
{
|
||||
// UM | CP1
|
||||
context.status = 1 << 4 | 1 << 29;
|
||||
// UM | CP1 | IE
|
||||
context.status = 1 << 4 | 1 << 29 | 1;
|
||||
// IM1..IM0
|
||||
context.status |= 1 << 8 | 1 << 9;
|
||||
// IPL(IM5..IM2)
|
||||
context.status |= 1 << 15 | 1 << 14 | 1 << 13 | 1 << 12;
|
||||
}
|
||||
|
||||
let thread = Thread {
|
||||
@ -511,7 +515,7 @@ pub fn spawn(thread: Arc<Thread>) {
|
||||
_ if is_page_fault(trap_num) => {
|
||||
// page fault
|
||||
let addr = get_page_fault_addr();
|
||||
debug!("page fault from user @ {:#x}", addr);
|
||||
info!("page fault from user @ {:#x}", addr);
|
||||
|
||||
if !handle_user_page_fault(&thread, addr) {
|
||||
// TODO: SIGSEGV
|
||||
|
@ -13,6 +13,10 @@ pub fn add_user_shell() {
|
||||
// This one can transfer env vars!
|
||||
// Why???
|
||||
|
||||
#[cfg(target_arch = "mips")]
|
||||
let init_shell = "/rust/sh"; //from docker-library
|
||||
|
||||
#[cfg(not(target_arch = "mips"))]
|
||||
let init_shell = "/busybox"; //from docker-library
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
|
@ -664,11 +664,11 @@ impl Syscall<'_> {
|
||||
let flags = AtFlags::from_bits_truncate(flags);
|
||||
if !proc.pid.is_init() {
|
||||
// we trust pid 0 process
|
||||
info!(
|
||||
"faccessat: dirfd: {}, path: {:?}, mode: {:#o}, flags: {:?}",
|
||||
dirfd as isize, path, mode, flags
|
||||
);
|
||||
}
|
||||
info!(
|
||||
"faccessat: dirfd: {}, path: {:?}, mode: {:#o}, flags: {:?}",
|
||||
dirfd as isize, path, mode, flags
|
||||
);
|
||||
let _inode =
|
||||
proc.lookup_inode_at(dirfd, &path, !flags.contains(AtFlags::SYMLINK_NOFOLLOW))?;
|
||||
Ok(0)
|
||||
|
Loading…
Reference in New Issue
Block a user