#[repr(C)]pub struct Registers {
pub gprs: GeneralPurposeRegisters,
error_code: u64,
/* private fields */
}Expand description
x86_64 Trap frame.
Fields§
§gprs: GeneralPurposeRegisters§error_code: u64Implementations§
Source§impl Registers
impl Registers
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new register frame for a user thread.
This function initializes a Registers structure with default values
for a new user-space thread.
§Returns
- A
Registersinstance with default values for user-space execution.
§Example
let mut regs = Registers::new();
*regs.rip() = 0x400000; // Set entry point
*regs.rsp() = 0x7FFFFFFFE000; // Set user stack pointerSourcepub fn rip(&mut self) -> &mut usize
pub fn rip(&mut self) -> &mut usize
Returns a mutable reference to the instruction pointer (RIP).
This function allows modifying the instruction pointer, which determines the next instruction the CPU will execute when the thread resumes.
§Returns
- A mutable reference to the
ripfield in the interrupt stack frame.
§Example
let mut regs = Registers::new();
*regs.rip() = 0x400000; // Set the entry pointSourcepub fn rsp(&mut self) -> &mut usize
pub fn rsp(&mut self) -> &mut usize
Returns a mutable reference to the stack pointer (RSP).
This function allows modifying the stack pointer, which should point to the top of the stack before execution.
§Returns
- A mutable reference to the
rspfield.
§Example
let mut regs = Registers::new();
*regs.rsp() = 0x7FFFFFFFE000; // Set the user stack pointerSourcepub extern "C" fn launch(&self) -> !
pub extern "C" fn launch(&self) -> !
Launch the frame.
Launches a thread by restoring its saved register state.
This function returns the never type (!), meaning that once
executed, there is no way to return to the current execution
context.
§Safety
- The kernel must release all temporary resources such as locally
allocated
Box, [SpinLockGuard], or [InterruptGuard] before calling this function.
§Behavior
- Restores general-purpose registers from
self.gprs. - Enables interrupts.
- Transfers to saved execution state by executing
iretq.
§Example Usage
let regs = Registers::new();
regs.launch(); // This function does not return
unreachable!() // Execution will never reach hereTrait Implementations§
impl Copy for Registers
Auto Trait Implementations§
impl Freeze for Registers
impl RefUnwindSafe for Registers
impl Send for Registers
impl Sync for Registers
impl Unpin for Registers
impl UnwindSafe for Registers
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
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)