diff --git a/Cargo.lock b/Cargo.lock index 9560cc3..9c49471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,12 +313,12 @@ dependencies = [ [[package]] name = "x86_64" -version = "0.14.12" +version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cb6fd45bfeab6a5055c5bffdb08768bd0c069f1d946debe585bbb380a7c062" +checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" dependencies = [ "bit_field", - "bitflags 2.5.0", + "bitflags 1.3.2", "rustversion", "volatile", ] diff --git a/Cargo.toml b/Cargo.toml index 618076c..1187670 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ sbi-rt = { version = "0.0.2", features = ["legacy"] } [target.'cfg(target_arch = "x86_64")'.dependencies] x86 = "0.52" -x86_64 = "0.14" +x86_64 = "=0.14.10" multiboot = "0.8.0" x2apic = "0.4" raw-cpuid = "11.0" diff --git a/src/components/timer/aarch64.rs b/src/components/timer/aarch64.rs index 312a4a5..e9f6599 100644 --- a/src/components/timer/aarch64.rs +++ b/src/components/timer/aarch64.rs @@ -19,7 +19,7 @@ impl Time { } pub fn set_next_timer() { - CNTP_TVAL_EL0.set(CNTFRQ_EL0.get() / 1000); + CNTP_TVAL_EL0.set(CNTFRQ_EL0.get() / 100); } pub fn init() { diff --git a/src/components/timer/x86_64.rs b/src/components/timer/x86_64.rs index 37c26d2..6041b45 100644 --- a/src/components/timer/x86_64.rs +++ b/src/components/timer/x86_64.rs @@ -104,7 +104,7 @@ pub(crate) fn init_early() { log::info!("ticks 50us: {}", ticks10ms / 10 / 20); // lapic.set_timer_initial(ticks10ms * 0x100); // Set 500us ticks - lapic.set_timer_initial(ticks10ms / 20); + lapic.set_timer_initial(ticks10ms * 100); debug!("count: {}", lapic.timer_current()); // set_oneshot_timer(2000); } diff --git a/src/components/trap/mod.rs b/src/components/trap/mod.rs index 8144684..e30ddcc 100644 --- a/src/components/trap/mod.rs +++ b/src/components/trap/mod.rs @@ -24,6 +24,7 @@ pub enum TrapType { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum EscapeReason { NoReason, + Exception(usize), IRQ, Timer, SysCall, @@ -34,6 +35,11 @@ impl Into for TrapType { fn into(self) -> EscapeReason { match self { TrapType::SysCall => EscapeReason::SysCall, + TrapType::Timer => EscapeReason::Timer, + TrapType::StorePageFault(e)| + TrapType::LoadPageFault(e)| + TrapType::InstructionPageFault(e)| + TrapType::IllegalInstruction(e)=>EscapeReason::Exception(e), _ => EscapeReason::NoReason, } } diff --git a/src/components/trap/x86_64.rs b/src/components/trap/x86_64.rs index 8a733f8..c3992cc 100644 --- a/src/components/trap/x86_64.rs +++ b/src/components/trap/x86_64.rs @@ -61,7 +61,7 @@ bitflags! { // 内核中断回调 #[no_mangle] -fn kernel_callback(context: &mut TrapFrame) { +fn kernel_callback(context: &mut TrapFrame) -> TrapType { let trap_type = match context.vector as u8 { PAGE_FAULT_VECTOR => { let pflags = PageFaultFlags::from_bits_truncate(context.rflags as _); @@ -103,6 +103,7 @@ fn kernel_callback(context: &mut TrapFrame) { } }; unsafe { crate::components::trap::_interrupt_for_arch(context, trap_type, 0) }; + trap_type } #[naked] @@ -347,7 +348,7 @@ unsafe extern "C" fn syscall_entry() { mov ecx, 0xC0000100 rdmsr mov [rsp + 15*8+4], edx - mov [rsp + 15*8], eax # push fabase + mov [rsp + 15*8], eax # push fsbase mov ecx, 0xC0000102 rdmsr @@ -404,10 +405,7 @@ pub fn run_user_task(context: &mut TrapFrame) -> EscapeReason { unsafe { crate::components::trap::_interrupt_for_arch(context, TrapType::SysCall, 0) }; EscapeReason::SysCall } - _ => { - kernel_callback(context); - EscapeReason::NoReason - } + _ => kernel_callback(context).into() } }