Skip to content

Commit

Permalink
Merge pull request #467 from GZTimeWalker/patch-1
Browse files Browse the repository at this point in the history
Feat: add constructor for `InterruptStackFrameValue`
  • Loading branch information
Freax13 authored Mar 15, 2024
2 parents 43eb701 + 1f786d7 commit a441868
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,24 @@ impl EntryOptions {
pub struct InterruptStackFrame(InterruptStackFrameValue);

impl InterruptStackFrame {
/// Creates a new interrupt stack frame with the given values.
#[inline]
pub fn new(
instruction_pointer: VirtAddr,
code_segment: SegmentSelector,
cpu_flags: RFlags,
stack_pointer: VirtAddr,
stack_segment: SegmentSelector,
) -> Self {
Self(InterruptStackFrameValue::new(
instruction_pointer,
code_segment,
cpu_flags,
stack_pointer,
stack_segment,
))
}

/// Gives mutable access to the contents of the interrupt stack frame.
///
/// The `Volatile` wrapper is used because LLVM optimizations remove non-volatile
Expand Down Expand Up @@ -1030,6 +1048,26 @@ pub struct InterruptStackFrameValue {
}

impl InterruptStackFrameValue {
/// Creates a new interrupt stack frame with the given values.
#[inline]
pub fn new(
instruction_pointer: VirtAddr,
code_segment: SegmentSelector,
cpu_flags: RFlags,
stack_pointer: VirtAddr,
stack_segment: SegmentSelector,
) -> Self {
Self {
instruction_pointer,
code_segment,
_reserved1: Default::default(),
cpu_flags,
stack_pointer,
stack_segment,
_reserved2: Default::default(),
}
}

/// Call the `iretq` (interrupt return) instruction.
///
/// This function doesn't have to be called in an interrupt handler.
Expand Down

0 comments on commit a441868

Please sign in to comment.