ros666::trap::context

Struct TrapCtx

Source
pub struct TrapCtx {
    pub x: [usize; 32],
    pub sstatus: usize,
    pub sepc: usize,
    pub kernel_satp: usize,
    pub kernel_virt_sp: usize,
    pub kernel_virt_trap_handler: usize,
}
Expand description

陷入上下文

用于保存和恢复陷入处理程序的上下文。

Fields§

§x: [usize; 32]

通用寄存器

§sstatus: usize

Supervisor 状态寄存器

§sepc: usize

Supervisor 异常程序计数器

§kernel_satp: usize

内核页表基址 (Supervisor Address Translation and Protection)

§kernel_virt_sp: usize

内核虚拟栈指针

§kernel_virt_trap_handler: usize

内核虚拟陷入处理程序入口地址

Implementations§

Source§

impl TrapCtx

Source

pub fn set_sp(&mut self, sp: usize)

设置栈指针寄存器的值。

Source

pub fn init_app_context( entry: usize, sp: usize, kernel_satp: usize, kernel_virt_sp: usize, kernel_virt_trap_handler: usize, ) -> Self

创建一个新的 TrapCtx,用于应用程序上下文。

§参数
  • entry:程序入口地址。
  • sp:栈指针地址。
  • kernel_satp:内核页表基址寄存器的值。
  • kernel_virt_sp:内核虚拟栈指针的值。
  • kernel_virt_trap_handler:内核虚拟陷入处理程序的地址。
§返回值

返回一个初始化的 TrapCtx 实例。

Trait Implementations§

Source§

impl Riscv64RegAlias for TrapCtx

Source§

fn zero(&mut self) -> &mut usize

返回零寄存器(x0)的可变引用,其值始终为 0。
Source§

fn ra(&mut self) -> &mut usize

返回返回地址寄存器(ra)的可变引用。
Source§

fn sp(&mut self) -> &mut usize

返回栈指针寄存器(x2)的可变引用。
Source§

fn gp(&mut self) -> &mut usize

返回全局指针寄存器(gp)的可变引用。
Source§

fn tp(&mut self) -> &mut usize

返回线程指针寄存器(tp)的可变引用。
Source§

fn t(&mut self, i: usize) -> &mut usize

返回一个临时寄存器(t0-t6)的可变引用。 Read more
Source§

fn s(&mut self, i: usize) -> &mut usize

返回一个保存寄存器(s0-s11)的可变引用。 Read more
Source§

fn a(&mut self, i: usize) -> &mut usize

返回一个参数寄存器(a0-a7)的可变引用。 Read more
Source§

fn sepc(&mut self) -> &mut usize

返回一个可变引用,指向监管者异常程序计数器(sepc)。
Source§

fn sstatus(&mut self) -> &mut usize

返回一个可变引用,指向监管者状态寄存器(sstatus)。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.