Skip to content

Commit

Permalink
uarths recv intr worked after sbi_putc(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfcyx committed Aug 3, 2020
1 parent ba4dd90 commit be22c1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Binary file modified os/built/opensbi.bin
Binary file not shown.
9 changes: 6 additions & 3 deletions os/src/interrupt/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand All @@ -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),
}
Expand All @@ -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");
Expand Down
4 changes: 3 additions & 1 deletion tools/opensbi/lib/sbi_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit be22c1d

Please sign in to comment.