Struct kernel_hal::context::UserContext
source · [−]#[repr(transparent)]pub struct UserContext(_);
Expand description
User context saved on trap.
Implementations
sourceimpl UserContext
impl UserContext
sourcepub fn setup_uspace(&mut self, pc: usize, sp: usize, args: &[usize; 3])
pub fn setup_uspace(&mut self, pc: usize, sp: usize, args: &[usize; 3])
Initialize the context for entry into userspace. Note: if the number of args < 3, please fill with zeros Eg: ctx.setup_uspace(pc_, sp_, &[arg1, arg2, 0])
sourcepub fn enter_uspace(&mut self)
pub fn enter_uspace(&mut self)
Switch to user mode.
sourcepub fn error_code(&self) -> usize
Available on x86-64 only.
pub fn error_code(&self) -> usize
Returns the error_code
field of the context.
sourcepub fn trap_reason(&self) -> TrapReason
pub fn trap_reason(&self) -> TrapReason
Returns TrapReason
according to the context.
sourcepub fn raw_trap_reason(&self) -> usize
pub fn raw_trap_reason(&self) -> usize
Returns a usize
representing the trap reason. (i.e., IDT vector for x86, scause
for RISC-V)
sourcepub fn general(&self) -> &GeneralRegs
pub fn general(&self) -> &GeneralRegs
Returns the reference of general registers.
sourcepub fn general_mut(&mut self) -> &mut GeneralRegs
pub fn general_mut(&mut self) -> &mut GeneralRegs
Returns the mutable reference of general registers.
sourcepub fn get_field(&mut self, which: UserContextField) -> usize
pub fn get_field(&mut self, which: UserContextField) -> usize
Read a field of the context.
sourcepub fn set_field(&mut self, which: UserContextField, value: usize)
pub fn set_field(&mut self, which: UserContextField, value: usize)
Write a field of the context.
sourcepub fn advance_pc(&mut self, reason: TrapReason)
pub fn advance_pc(&mut self, reason: TrapReason)
Advance the instruction pointer in trap handler on some architecture.
Trait Implementations
sourceimpl Clone for UserContext
impl Clone for UserContext
sourcefn clone(&self) -> UserContext
fn clone(&self) -> UserContext
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for UserContext
impl Debug for UserContext
sourceimpl Default for UserContext
impl Default for UserContext
impl Copy 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcefn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcefn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.