Struct trapframe::UserContext 
source · #[repr(C)]pub struct UserContext {
    pub general: GeneralRegs,
    pub trap_num: usize,
    pub error_code: usize,
}Expand description
User space context
Fields§
§general: GeneralRegs§trap_num: usize§error_code: usizeImplementations§
source§impl UserContext
 
impl UserContext
sourcepub fn run(&mut self)
 
pub fn run(&mut self)
Go to user space with the context, and come back when a trap occurs.
On return, the context will be reset to the status before the trap.
Trap reason and error code will be placed at trap_num and error_code.
If the trap was triggered by syscall instruction, the trap_num will be set to 0x100.
If trap_num is 0x100, it will go user by sysret (rcx and r11 are dropped),
otherwise it will use iret.
Example
use trapframe::{UserContext, GeneralRegs};
// init user space context
let mut context = UserContext {
    general: GeneralRegs {
        rip: 0x1000,
        rsp: 0x10000,
        ..Default::default()
    },
    ..Default::default()
};
// go to user
context.run();
// back from user
println!("back from user: {:#x?}", context);source§impl UserContext
 
impl UserContext
sourcepub fn get_syscall_num(&self) -> usize
 
pub fn get_syscall_num(&self) -> usize
Get number of syscall
sourcepub fn get_syscall_ret(&self) -> usize
 
pub fn get_syscall_ret(&self) -> usize
Get return value of syscall
sourcepub fn set_syscall_ret(&mut self, ret: usize)
 
pub fn set_syscall_ret(&mut self, ret: usize)
Set return value of syscall
sourcepub fn get_syscall_args(&self) -> [usize; 6]
 
pub fn get_syscall_args(&self) -> [usize; 6]
Get syscall args
Trait Implementations§
source§impl Clone for UserContext
 
impl Clone for UserContext
source§fn clone(&self) -> UserContext
 
fn clone(&self) -> UserContext
Returns a copy of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moresource§impl Debug for UserContext
 
impl Debug for UserContext
source§impl Default for UserContext
 
impl Default for UserContext
source§fn default() -> UserContext
 
fn default() -> UserContext
Returns the “default value” for a type. Read more
source§impl PartialEq for UserContext
 
impl PartialEq for UserContext
source§impl Pod for UserContext
 
impl Pod for UserContext
source§fn new_zeroed() -> Self
 
fn new_zeroed() -> Self
Creates a new instance of Pod type that is filled with zeroes.
source§fn new_uninit() -> Self
 
fn new_uninit() -> Self
Creates a new instance of Pod type with uninitialized content.
source§fn from_bytes(bytes: &[u8]) -> Self
 
fn from_bytes(bytes: &[u8]) -> Self
Creates a new instance from the given bytes.
source§fn as_bytes_mut(&mut self) -> &mut [u8]
 
fn as_bytes_mut(&mut self) -> &mut [u8]
As a mutable slice of bytes.
impl Copy for UserContext
impl Eq for UserContext
impl StructuralEq for UserContext
impl StructuralPartialEq for UserContext
Auto Trait Implementations§
impl RefUnwindSafe for UserContext
impl Send for UserContext
impl Sync for UserContext
impl Unpin for UserContext
impl UnwindSafe for UserContext
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