Skip to content

Commit

Permalink
print in M and SSoft also knows
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfcyx committed Aug 3, 2020
1 parent 89f63f5 commit ba4dd90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Binary file modified os/built/opensbi.bin
Binary file not shown.
10 changes: 9 additions & 1 deletion os/src/interrupt/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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_timer(context),
Trap::Interrupt(Interrupt::SupervisorSoft) => supervisor_soft(context),
// 其他情况,终止当前线程
_ => fault(context, scause, stval),
}
Expand All @@ -43,6 +43,14 @@ fn supervisor_timer(_: &Context) {
timer::tick();
}

fn supervisor_soft(_: &Context) {
println!("soft");
unsafe {
let mut sip: usize = 0;
llvm_asm!("csrci sip, 1 << 1" : "=r"(sip) ::: "volatile");
}
}

fn fault(context: &mut Context, scause: Scause, stval: usize) {
panic!(
"Unresolved interrupt: {:?}\n{:x?}\nstval: {:x}",
Expand Down
2 changes: 2 additions & 0 deletions tools/opensbi/lib/sbi_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ void sbi_trap_handler(struct sbi_trap_regs *regs, struct sbi_scratch *scratch)
sbi_printf("%c", c);
// complete
*irq_id_ptr = irq_id;

csr_set(CSR_MIP, MIP_SSIP);
break;
default:
msg = "unhandled external interrupt";
Expand Down

0 comments on commit ba4dd90

Please sign in to comment.