Struct UspaceContext
pub struct UspaceContext(/* private fields */);
Available on crate feature
uspace
only.Expand description
Context to enter user space.
Implementations§
§impl UspaceContext
impl UspaceContext
pub const fn empty() -> UspaceContext
pub const fn empty() -> UspaceContext
Creates an empty context with all registers set to zero.
pub fn new(entry: usize, ustack_top: VirtAddr, arg0: usize) -> UspaceContext
pub fn new(entry: usize, ustack_top: VirtAddr, arg0: usize) -> UspaceContext
Creates a new context with the given entry point, user stack pointer, and the argument.
pub const fn from(tf: &TrapFrame) -> UspaceContext
pub const fn from(tf: &TrapFrame) -> UspaceContext
Creates a new context from the given TrapFrame
.
It copies almost all registers except CS
and SS
which need to be
set to the user segment selectors.
pub const fn set_retval(&mut self, rax: usize)
pub const fn set_retval(&mut self, rax: usize)
Sets the return value register.
pub unsafe fn enter_uspace(&self, kstack_top: VirtAddr) -> !
pub unsafe fn enter_uspace(&self, kstack_top: VirtAddr) -> !
Enters user space.
It restores the user registers and jumps to the user entry point
(saved in rip
).
When an exception or syscall occurs, the kernel stack pointer is
switched to kstack_top
.
§Safety
This function is unsafe because it changes processor mode and the stack.
Auto Trait Implementations§
impl Freeze for UspaceContext
impl RefUnwindSafe for UspaceContext
impl Send for UspaceContext
impl Sync for UspaceContext
impl Unpin for UspaceContext
impl UnwindSafe for UspaceContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more