Skip to content

Commit 1f786d7

Browse files
committed
feat: add constructor for InterruptStackFrameValue
1 parent 43eb701 commit 1f786d7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/structures/idt.rs

+38
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,24 @@ impl EntryOptions {
971971
pub struct InterruptStackFrame(InterruptStackFrameValue);
972972

973973
impl InterruptStackFrame {
974+
/// Creates a new interrupt stack frame with the given values.
975+
#[inline]
976+
pub fn new(
977+
instruction_pointer: VirtAddr,
978+
code_segment: SegmentSelector,
979+
cpu_flags: RFlags,
980+
stack_pointer: VirtAddr,
981+
stack_segment: SegmentSelector,
982+
) -> Self {
983+
Self(InterruptStackFrameValue::new(
984+
instruction_pointer,
985+
code_segment,
986+
cpu_flags,
987+
stack_pointer,
988+
stack_segment,
989+
))
990+
}
991+
974992
/// Gives mutable access to the contents of the interrupt stack frame.
975993
///
976994
/// The `Volatile` wrapper is used because LLVM optimizations remove non-volatile
@@ -1030,6 +1048,26 @@ pub struct InterruptStackFrameValue {
10301048
}
10311049

10321050
impl InterruptStackFrameValue {
1051+
/// Creates a new interrupt stack frame with the given values.
1052+
#[inline]
1053+
pub fn new(
1054+
instruction_pointer: VirtAddr,
1055+
code_segment: SegmentSelector,
1056+
cpu_flags: RFlags,
1057+
stack_pointer: VirtAddr,
1058+
stack_segment: SegmentSelector,
1059+
) -> Self {
1060+
Self {
1061+
instruction_pointer,
1062+
code_segment,
1063+
_reserved1: Default::default(),
1064+
cpu_flags,
1065+
stack_pointer,
1066+
stack_segment,
1067+
_reserved2: Default::default(),
1068+
}
1069+
}
1070+
10331071
/// Call the `iretq` (interrupt return) instruction.
10341072
///
10351073
/// This function doesn't have to be called in an interrupt handler.

0 commit comments

Comments
 (0)