Update rustsbi-qemu && batch worked on qemu/k210.

This commit is contained in:
Yifan Wu 2020-11-20 11:10:38 +08:00
parent 2ce04bf19f
commit 6671f99afb
8 changed files with 33 additions and 5 deletions

View file

@ -11,6 +11,7 @@ use riscv::register::{
stval,
};
use crate::syscall::syscall;
use crate::batch::run_next_app;
global_asm!(include_str!("trap.S"));
@ -24,14 +25,23 @@ pub fn init() {
#[no_mangle]
pub fn trap_handler(cx: &mut TrapContext) -> &mut TrapContext {
let scause = scause::read();
let _stval = stval::read();
let stval = stval::read();
match scause.cause() {
Trap::Exception(Exception::UserEnvCall) => {
cx.sepc += 4;
cx.x[10] = syscall(cx.x[17], [cx.x[10], cx.x[11], cx.x[12]]) as usize;
}
Trap::Exception(Exception::StoreFault) |
Trap::Exception(Exception::StorePageFault) => {
println!("[kernel] PageFault in application, core dumped.");
run_next_app();
}
Trap::Exception(Exception::IllegalInstruction) => {
println!("[kernel] IllegalInstruction in application, core dumped.");
run_next_app();
}
_ => {
panic!("Unsupported trap!");
panic!("Unsupported trap {:?}, stval = {:#x}!", scause.cause(), stval);
}
}
cx