diff --git a/os/built/opensbi.bin b/os/built/opensbi.bin index b29f51f..eec9a26 100755 Binary files a/os/built/opensbi.bin and b/os/built/opensbi.bin differ diff --git a/os/src/interrupt/handler.rs b/os/src/interrupt/handler.rs index 0cfce8c..3bd1d9c 100644 --- a/os/src/interrupt/handler.rs +++ b/os/src/interrupt/handler.rs @@ -3,6 +3,7 @@ use super::timer; use riscv::register::stvec; use riscv::register::scause::Scause; use riscv::register::scause::{Exception, Trap, Interrupt}; +use crate::sbi::console_putchar; global_asm!(include_str!("./interrupt.asm")); @@ -28,7 +29,7 @@ pub fn handle_interrupt(context: &mut Context, scause: Scause, stval: usize) { Trap::Exception(Exception::Breakpoint) => breakpoint(context), // 时钟中断 Trap::Interrupt(Interrupt::SupervisorTimer) => supervisor_timer(context), - Trap::Interrupt(Interrupt::SupervisorSoft) => supervisor_soft(context), + Trap::Interrupt(Interrupt::SupervisorSoft) => supervisor_soft(context, stval), // 其他情况,终止当前线程 _ => fault(context, scause, stval), } @@ -43,8 +44,10 @@ fn supervisor_timer(_: &Context) { timer::tick(); } -fn supervisor_soft(_: &Context) { - println!("soft"); +fn supervisor_soft(_: &Context, stval: usize) { + //panic!("into ssoft"); + //println!("stval = {}", stval & 0xff); + console_putchar(stval & 0xff); unsafe { let mut sip: usize = 0; llvm_asm!("csrci sip, 1 << 1" : "=r"(sip) ::: "volatile"); diff --git a/tools/opensbi/lib/sbi_trap.c b/tools/opensbi/lib/sbi_trap.c index ecaff9b..2649a78 100644 --- a/tools/opensbi/lib/sbi_trap.c +++ b/tools/opensbi/lib/sbi_trap.c @@ -159,10 +159,12 @@ void sbi_trap_handler(struct sbi_trap_regs *regs, struct sbi_scratch *scratch) unsigned irq_id = *irq_id_ptr; // putchar char c = *(unsigned*)(0x38000004) & 0xff; - sbi_printf("%c", c); + //sbi_printf("%c", c); + sbi_putc(0); // complete *irq_id_ptr = irq_id; + csr_write(CSR_STVAL, c); csr_set(CSR_MIP, MIP_SSIP); break; default: