pub struct UspaceContext(/* private fields */);
Available on crate feature
uspace
only.Expand description
Context to enter user space.
Implementations§
Source§impl UspaceContext
impl UspaceContext
Sourcepub fn new(entry: usize, ustack_top: VirtAddr, arg0: usize) -> Self
pub fn new(entry: usize, ustack_top: VirtAddr, arg0: usize) -> Self
Creates a new context with the given entry point, user stack pointer, and the argument.
Sourcepub const fn from(tf: &TrapFrame) -> Self
pub const fn from(tf: &TrapFrame) -> Self
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.
Sourcepub 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.
Methods from Deref<Target = TrapFrame>§
Sourcepub fn set_retval(&mut self, rax: usize)
pub fn set_retval(&mut self, rax: usize)
Sets the return value register.
Trait Implementations§
Source§impl Deref for UspaceContext
impl Deref for UspaceContext
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