Update docs
This commit is contained in:
parent
493fba58fe
commit
e60ef5a67a
7 changed files with 36 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue