diff --git a/src/arch/x86_64/interrupt/handler.rs b/src/arch/x86_64/interrupt/handler.rs index 44ff6a1..92cbbf9 100644 --- a/src/arch/x86_64/interrupt/handler.rs +++ b/src/arch/x86_64/interrupt/handler.rs @@ -30,7 +30,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize { T_BRKPT => breakpoint(), T_DBLFLT => double_fault(), T_PGFLT => page_fault(tf), - T_GPFLT => general_protection_fault(), T_IRQ0...64 => { let irq = tf.trap_num as u8 - T_IRQ0; match irq { @@ -50,6 +49,7 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize { T_SWITCH_TOU => to_user(tf), T_SYSCALL => syscall(tf), T_SYSCALL32 => syscall32(tf), + T_DIVIDE | T_GPFLT | T_ILLOP => error(tf), _ => panic!("Unhandled interrupt {:x}", tf.trap_num), } @@ -83,17 +83,7 @@ fn page_fault(tf: &mut TrapFrame) { return; } - loop {} -} - -fn general_protection_fault() { - error!("\nEXCEPTION: General Protection Fault"); - loop {} -} - -fn invalid_opcode() { - error!("\nEXCEPTION: Invalid Opcode"); - loop {} + error(tf); } use super::consts::*; @@ -152,6 +142,14 @@ fn syscall32(tf: &mut TrapFrame) { tf.rax = ret as usize; } +fn error(tf: &TrapFrame) { + use process::PROCESSOR; + let mut processor = PROCESSOR.try().unwrap().lock(); + let pid = processor.current_pid(); + error!("Process {} error:\n{:#x?}", pid, tf); + processor.exit(pid, 0x100); // TODO: Exit code for error +} + fn set_return_rsp(tf: &TrapFrame) { use arch::gdt::Cpu; use core::mem::size_of; diff --git a/status.md b/status.md index 55041f8..4e1747e 100644 --- a/status.md +++ b/status.md @@ -1,10 +1,10 @@ ## uCore 32bit user programs pass status - [ ] badarg - [ ] badsegment -- [ ] divzero +- [x] divzero - [ ] exit -- [ ] faultread -- [ ] faultreadkernel +- [x] faultread +- [x] faultreadkernel - [x] forktest - [x] forktree - [x] hello @@ -15,8 +15,8 @@ - [ ] sh - [ ] sleep - [x] sleepkill -- [ ] softint +- [x] softint - [x] spin -- [ ] testbss +- [x] testbss - [x] waitkill - [x] yield