Struct axhal::arch::UspaceContext
source · 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 const fn set_retval(&mut self, rax: usize)
pub const fn set_retval(&mut self, rax: usize)
Sets the return value register.
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.
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