Add comments in ch6
This commit is contained in:
parent
cea2febe35
commit
f9346edad1
35 changed files with 374 additions and 116 deletions
|
@ -1,20 +1,30 @@
|
|||
//! Implementation of [`TrapContext`]
|
||||
use riscv::register::sstatus::{self, Sstatus, SPP};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
///trap context structure containing sstatus, sepc and registers
|
||||
pub struct TrapContext {
|
||||
/// general regs[0..31]
|
||||
pub x: [usize; 32],
|
||||
/// CSR sstatus
|
||||
pub sstatus: Sstatus,
|
||||
/// CSR sepc
|
||||
pub sepc: usize,
|
||||
/// Addr of Page Table
|
||||
pub kernel_satp: usize,
|
||||
/// kernel stack
|
||||
pub kernel_sp: usize,
|
||||
/// Addr of trap_handler function
|
||||
pub trap_handler: usize,
|
||||
}
|
||||
|
||||
impl TrapContext {
|
||||
///set stack pointer to x_2 reg (sp)
|
||||
pub fn set_sp(&mut self, sp: usize) {
|
||||
self.x[2] = sp;
|
||||
}
|
||||
///init app context
|
||||
pub fn app_init_context(
|
||||
entry: usize,
|
||||
sp: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue