Run hello_world/power one by one in batch mode.

This commit is contained in:
Yifan Wu 2020-11-20 01:18:25 +08:00
parent bae5383602
commit 2ce04bf19f
10 changed files with 74 additions and 26 deletions

View file

@ -2,9 +2,9 @@ use riscv::register::sstatus::{Sstatus, self, SPP};
#[repr(C)]
pub struct TrapContext {
x: [usize; 32],
sstatus: Sstatus,
sepc: usize,
pub x: [usize; 32],
pub sstatus: Sstatus,
pub sepc: usize,
}
impl TrapContext {

View file

@ -10,6 +10,7 @@ use riscv::register::{
},
stval,
};
use crate::syscall::syscall;
global_asm!(include_str!("trap.S"));
@ -23,10 +24,11 @@ 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) => {
panic!("Triggered UserEnvCall!");
cx.sepc += 4;
cx.x[10] = syscall(cx.x[17], [cx.x[10], cx.x[11], cx.x[12]]) as usize;
}
_ => {
panic!("Unsupported trap!");