#[repr(C)]pub struct TrapFrame {Show 34 fields
pub sepc: usize,
pub x1_ra: usize,
pub x2_sp: usize,
pub x3_gp: usize,
pub x4_tp: usize,
pub x5_t0: usize,
pub x6_t1: usize,
pub x7_t2: usize,
pub x8_s0: usize,
pub x9_s1: usize,
pub x10_a0: usize,
pub x11_a1: usize,
pub x12_a2: usize,
pub x13_a3: usize,
pub x14_a4: usize,
pub x15_a5: usize,
pub x16_a6: usize,
pub x17_a7: usize,
pub x18_s2: usize,
pub x19_s3: usize,
pub x20_s4: usize,
pub x21_s5: usize,
pub x22_s6: usize,
pub x23_s7: usize,
pub x24_s8: usize,
pub x25_s9: usize,
pub x26_s10: usize,
pub x27_s11: usize,
pub x28_t3: usize,
pub x29_t4: usize,
pub x30_t5: usize,
pub x31_t6: usize,
pub sstatus: usize,
pub kernel_sp: usize,
}Expand description
陷阱帧结构体,保存寄存器状态
Fields§
§sepc: usize程序计数器 在发生陷阱时,sepc 寄存器的值应保存到这里
x1_ra: usize§x2_sp: usize§x3_gp: usize§x4_tp: usize§x5_t0: usize§x6_t1: usize§x7_t2: usize§x8_s0: usize§x9_s1: usize§x10_a0: usize§x11_a1: usize§x12_a2: usize§x13_a3: usize§x14_a4: usize§x15_a5: usize§x16_a6: usize§x17_a7: usize§x18_s2: usize§x19_s3: usize§x20_s4: usize§x21_s5: usize§x22_s6: usize§x23_s7: usize§x24_s8: usize§x25_s9: usize§x26_s10: usize§x27_s11: usize§x28_t3: usize§x29_t4: usize§x30_t5: usize§x31_t6: usize§sstatus: usize§kernel_sp: usizeImplementations§
Source§impl TrapFrame
impl TrapFrame
Sourcepub fn set_kernel_trap_frame(
&mut self,
entry: usize,
terminal: usize,
kernel_sp: usize,
)
pub fn set_kernel_trap_frame( &mut self, entry: usize, terminal: usize, kernel_sp: usize, )
设置内核线程的初始陷阱帧 参数:
entry: 线程入口地址terminal: 线程结束时跳转地址kernel_sp: 内核栈顶地址
Sourcepub unsafe fn set_clone_trap_frame(
&mut self,
parent_frame: &TrapFrame,
kernel_sp: usize,
user_sp: usize,
)
pub unsafe fn set_clone_trap_frame( &mut self, parent_frame: &TrapFrame, kernel_sp: usize, user_sp: usize, )
设置克隆线程的 TrapFrame 参数:
parent_frame: 父线程的 TrapFrame 引用entry: 线程入口地址args: 传递给线程函数的参数kernel_sp: 内核栈顶地址user_sp: 用户栈顶地址
§安全性
parent_frame必须指向一个完全初始化的、有效的TrapFrameparent_frame必须在整个复制期间保持有效self必须指向一个可写的内存区域,大小至少为size_of::<TrapFrame>()self和parent_frame不能内存重叠- 调用后
self将包含parent_frame的精确副本(除了修改的字段)
Sourcepub fn set_exec_trap_frame(
&mut self,
entry: usize,
user_sp: usize,
kernel_sp: usize,
argc: usize,
argv: usize,
envp: usize,
)
pub fn set_exec_trap_frame( &mut self, entry: usize, user_sp: usize, kernel_sp: usize, argc: usize, argv: usize, envp: usize, )
设置用户态的 TrapFrame 用于execve新程序 参数:
entry: 用户程序入口地址user_sp: 用户栈顶地址kernel_sp: 内核栈顶地址argc: 命令行参数个数argv: 命令行参数指针数组地址envp: 环境变量指针数组地址
Sourcepub unsafe fn set_fork_trap_frame(&mut self, parent_frame: &TrapFrame)
pub unsafe fn set_fork_trap_frame(&mut self, parent_frame: &TrapFrame)
Sourcepub fn to_mcontext(&self) -> MContextT
pub fn to_mcontext(&self) -> MContextT
将 TrapFrame 转换为 MContextT 结构体
Sourcepub fn restore_from_mcontext(&mut self, mcontext: &MContextT)
pub fn restore_from_mcontext(&mut self, mcontext: &MContextT)
从 MContextT 恢复 TrapFrame
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TrapFrame
impl RefUnwindSafe for TrapFrame
impl Send for TrapFrame
impl Sync for TrapFrame
impl Unpin for TrapFrame
impl UnwindSafe for TrapFrame
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)