Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add constructor for InterruptStackFrameValue #467

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@

/// An Interrupt Descriptor Table entry.
///
/// The generic parameter is some [`InterruptFn`], depending on the interrupt vector.

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

unresolved link to `InterruptFn`

Check warning on line 674 in src/structures/idt.rs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

unresolved link to `InterruptFn`
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Entry<F> {
Expand Down Expand Up @@ -971,6 +971,24 @@
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 @@
}

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
Loading