Update docs

This commit is contained in:
田凯夫 2022-03-14 16:37:10 +08:00 committed by dramforever
parent 493fba58fe
commit e60ef5a67a
7 changed files with 36 additions and 2 deletions

View file

@ -12,6 +12,7 @@ use riscv::register::{
global_asm!(include_str!("trap.S"));
/// initialize CSR `stvec` as the entry of `__alltraps`
pub fn init() {
extern "C" {
fn __alltraps();
@ -21,6 +22,7 @@ pub fn init() {
}
}
/// timer interrupt enabled
pub fn enable_timer_interrupt() {
unsafe {
sie::set_stimer();
@ -28,9 +30,10 @@ pub fn enable_timer_interrupt() {
}
#[no_mangle]
/// handle an interrupt, exception, or system call from user space
pub fn trap_handler(cx: &mut TrapContext) -> &mut TrapContext {
let scause = scause::read();
let stval = stval::read();
let scause = scause::read(); // get trap cause
let stval = stval::read(); // get extra value
match scause.cause() {
Trap::Exception(Exception::UserEnvCall) => {
cx.sepc += 4;