From 772d53256327ee67daa273408f7859f9699f29f4 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Tue, 3 Jan 2023 10:05:40 +0800 Subject: [PATCH] update code, now '-bios none' can get the same result as ch9 --- os/Makefile | 2 +- os/src/main.rs | 6 +++--- os/src/trap/mod.rs | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/os/Makefile b/os/Makefile index 4331ae5c..6b7e9cfa 100644 --- a/os/Makefile +++ b/os/Makefile @@ -71,7 +71,7 @@ disasm-vim: kernel @nvim $(DISASM_TMP) @rm $(DISASM_TMP) -run: run-inner-none +run: run-inner run-inner-none: build @qemu-system-riscv64 \ diff --git a/os/src/main.rs b/os/src/main.rs index 44402534..b9b5f15a 100644 --- a/os/src/main.rs +++ b/os/src/main.rs @@ -260,9 +260,9 @@ pub fn rust_main() -> ! { println!("KERN: init gpu"); let _gpu = GPU_DEVICE.clone(); println!("KERN: init keyboard"); - // let _keyboard = KEYBOARD_DEVICE.clone(); - //println!("KERN: init mouse"); - //let _mouse = MOUSE_DEVICE.clone(); + let _keyboard = KEYBOARD_DEVICE.clone(); + println!("KERN: init mouse"); + let _mouse = MOUSE_DEVICE.clone(); println!("KERN: init trap"); trap::init(); //trap::enable_timer_interrupt(); diff --git a/os/src/trap/mod.rs b/os/src/trap/mod.rs index 05a91268..6040c7fa 100644 --- a/os/src/trap/mod.rs +++ b/os/src/trap/mod.rs @@ -95,18 +95,18 @@ pub fn trap_handler() -> ! { Trap::Exception(Exception::IllegalInstruction) => { current_add_signal(SignalFlags::SIGILL); } - Trap::Interrupt(Interrupt::SupervisorTimer) => { - set_next_trigger(); - check_timer(); - suspend_current_and_run_next(); - } + // Trap::Interrupt(Interrupt::SupervisorTimer) => { + // set_next_trigger(); + // check_timer(); + // suspend_current_and_run_next(); + // } Trap::Interrupt(Interrupt::SupervisorSoft) => { //set_next_trigger(); const SSIP: usize = 1 << 1; unsafe { asm!("csrc sip, {}", in(reg) SSIP); } - println!("TRAP: ssoft in Kern"); + //println!("TRAP: ssoft in Kern"); check_timer(); // do not schedule now } @@ -161,18 +161,18 @@ pub fn trap_from_kernel(_trap_cx: &TrapContext) { Trap::Interrupt(Interrupt::SupervisorExternal) => { crate::board::irq_handler(); } - Trap::Interrupt(Interrupt::SupervisorTimer) => { - //set_next_trigger(); - check_timer(); - // do not schedule now - } + // Trap::Interrupt(Interrupt::SupervisorTimer) => { + // //set_next_trigger(); + // check_timer(); + // // do not schedule now + // } Trap::Interrupt(Interrupt::SupervisorSoft) => { //set_next_trigger(); const SSIP: usize = 1 << 1; unsafe { asm!("csrc sip, {}", in(reg) SSIP); } - println!("TRAP: ssoft in Kern"); + //println!("TRAP: ssoft in Kern"); check_timer(); // do not schedule now }