diff --git a/kernel/Makefile b/kernel/Makefile index 9466a82..d7d1df1 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -134,7 +134,13 @@ qemu_opts += \ -kernel $(kernel_img) else ifeq ($(arch), mipsel) -ifeq ($(board), $(filter $(board), malta mipssim)) +ifeq ($(board), malta) +qemu_opts += \ + -machine $(board) \ + -serial null -serial null -serial mon:stdio \ + -kernel $(kernel_img) +endif +ifeq ($(board), mipssim) qemu_opts += \ -machine $(board) \ -serial mon:stdio \ diff --git a/kernel/src/arch/mipsel/board/malta/mod.rs b/kernel/src/arch/mipsel/board/malta/mod.rs index 0c594ef..67d5a8f 100644 --- a/kernel/src/arch/mipsel/board/malta/mod.rs +++ b/kernel/src/arch/mipsel/board/malta/mod.rs @@ -1,5 +1,6 @@ use once::*; use alloc::string::String; +use mips::registers::cp0; #[path = "../../../../drivers/serial/16550_reg.rs"] pub mod serial; @@ -12,7 +13,14 @@ pub mod consts; /// Initialize serial port first pub fn init_serial_early() { assert_has_not_been_called!("board::init must be called only once"); - serial::init(0xb80003f8); + // initialize serial driver + serial::init(0xbf000900); + // Enable serial interrupt + unsafe { + let mut status = cp0::status::read(); + status.enable_hard_int2(); + cp0::status::write(status); + } println!("Hello QEMU Malta!"); } diff --git a/kernel/src/arch/mipsel/interrupt.rs b/kernel/src/arch/mipsel/interrupt.rs index d85539e..19c0aad 100644 --- a/kernel/src/arch/mipsel/interrupt.rs +++ b/kernel/src/arch/mipsel/interrupt.rs @@ -75,7 +75,7 @@ pub extern fn rust_trap(tf: &mut TrapFrame) { fn interrupt_dispatcher(tf: &mut TrapFrame) { let pint = tf.cause.pending_interrupt(); - trace!(" Interrupt {:?} ", tf.cause.pending_interrupt()); + trace!(" Interrupt {:08b} ", pint); if (pint & 0b100_000_00) != 0 { timer(); } else if (pint & 0b011_111_00) != 0 { @@ -86,7 +86,6 @@ fn interrupt_dispatcher(tf: &mut TrapFrame) { } fn external() { - // TODO // true means handled, false otherwise let handlers = [try_process_serial, try_process_drivers]; for handler in handlers.iter() { @@ -99,6 +98,7 @@ fn external() { fn try_process_serial() -> bool { match super::io::getchar_option() { Some(ch) => { + trace!("Get char {} from serial", ch); crate::trap::serial(ch); true }