x86_64::structures::idt

Struct InterruptStackFrame

Source
pub struct InterruptStackFrame(/* private fields */);
Expand description

Wrapper type for the interrupt stack frame pushed by the CPU.

This type derefs to an InterruptStackFrameValue, which allows reading the actual values.

This wrapper type ensures that no accidental modification of the interrupt stack frame occurs, which can cause undefined behavior (see the as_mut method for more information).

Implementations§

Source§

impl InterruptStackFrame

Source

pub fn new( instruction_pointer: VirtAddr, code_segment: SegmentSelector, cpu_flags: RFlags, stack_pointer: VirtAddr, stack_segment: SegmentSelector, ) -> Self

Creates a new interrupt stack frame with the given values.

Source

pub unsafe fn as_mut(&mut self) -> Volatile<&mut InterruptStackFrameValue>

Gives mutable access to the contents of the interrupt stack frame.

The Volatile wrapper is used because LLVM optimizations remove non-volatile modifications of the interrupt stack frame.

§Safety

This function is unsafe since modifying the content of the interrupt stack frame can easily lead to undefined behavior. For example, by writing an invalid value to the instruction pointer field, the CPU can jump to arbitrary code at the end of the interrupt.

Also, it is not fully clear yet whether modifications of the interrupt stack frame are officially supported by LLVM’s x86 interrupt calling convention.

Methods from Deref<Target = InterruptStackFrameValue>§

Source

pub unsafe fn iretq(&self) -> !

Call the iretq (interrupt return) instruction.

This function doesn’t have to be called in an interrupt handler. By manually construction a new InterruptStackFrameValue it’s possible to transition from a higher privilege level to a lower one.

§Safety

Calling iretq is unsafe because setting the instruction pointer, stack pointer, RFlags, CS and SS register can all cause undefined behaviour when done incorrectly.

Trait Implementations§

Source§

impl Debug for InterruptStackFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for InterruptStackFrame

Source§

type Target = InterruptStackFrameValue

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.