|
|
@ -30,7 +30,6 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize {
|
|
|
|
T_BRKPT => breakpoint(),
|
|
|
|
T_BRKPT => breakpoint(),
|
|
|
|
T_DBLFLT => double_fault(),
|
|
|
|
T_DBLFLT => double_fault(),
|
|
|
|
T_PGFLT => page_fault(tf),
|
|
|
|
T_PGFLT => page_fault(tf),
|
|
|
|
T_GPFLT => general_protection_fault(),
|
|
|
|
|
|
|
|
T_IRQ0...64 => {
|
|
|
|
T_IRQ0...64 => {
|
|
|
|
let irq = tf.trap_num as u8 - T_IRQ0;
|
|
|
|
let irq = tf.trap_num as u8 - T_IRQ0;
|
|
|
|
match irq {
|
|
|
|
match irq {
|
|
|
@ -50,6 +49,7 @@ pub extern fn rust_trap(tf: &mut TrapFrame) -> usize {
|
|
|
|
T_SWITCH_TOU => to_user(tf),
|
|
|
|
T_SWITCH_TOU => to_user(tf),
|
|
|
|
T_SYSCALL => syscall(tf),
|
|
|
|
T_SYSCALL => syscall(tf),
|
|
|
|
T_SYSCALL32 => syscall32(tf),
|
|
|
|
T_SYSCALL32 => syscall32(tf),
|
|
|
|
|
|
|
|
T_DIVIDE | T_GPFLT | T_ILLOP => error(tf),
|
|
|
|
_ => panic!("Unhandled interrupt {:x}", tf.trap_num),
|
|
|
|
_ => panic!("Unhandled interrupt {:x}", tf.trap_num),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -83,17 +83,7 @@ fn page_fault(tf: &mut TrapFrame) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
error(tf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn general_protection_fault() {
|
|
|
|
|
|
|
|
error!("\nEXCEPTION: General Protection Fault");
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn invalid_opcode() {
|
|
|
|
|
|
|
|
error!("\nEXCEPTION: Invalid Opcode");
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
use super::consts::*;
|
|
|
|
use super::consts::*;
|
|
|
@ -152,6 +142,14 @@ fn syscall32(tf: &mut TrapFrame) {
|
|
|
|
tf.rax = ret as usize;
|
|
|
|
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) {
|
|
|
|
fn set_return_rsp(tf: &TrapFrame) {
|
|
|
|
use arch::gdt::Cpu;
|
|
|
|
use arch::gdt::Cpu;
|
|
|
|
use core::mem::size_of;
|
|
|
|
use core::mem::size_of;
|
|
|
|