From 0ad778942e42f971deeac7dc2d3acc2dba356e63 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 14 Oct 2021 13:51:19 +0200 Subject: [PATCH] fix: enable manipulation of `InterruptStackFrame` Derive `Copy` for `InterruptStackFrameValue` or otherwise ``` error[E0277]: the trait bound `InterruptStackFrameValue: core::marker::Copy` is not satisfied ``` Signed-off-by: Harald Hoyer --- src/structures/idt.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/structures/idt.rs b/src/structures/idt.rs index ed38ea735..5b0d9d1ba 100644 --- a/src/structures/idt.rs +++ b/src/structures/idt.rs @@ -851,7 +851,7 @@ impl fmt::Debug for InterruptStackFrame { } /// Represents the interrupt stack frame pushed by the CPU on interrupt or exception entry. -#[derive(Clone)] +#[derive(Clone, Copy)] #[repr(C)] pub struct InterruptStackFrameValue { /// This value points to the instruction that should be executed when the interrupt @@ -1115,4 +1115,23 @@ mod test { phantom: PhantomData, }) } + + #[test] + fn isr_frame_manipulation() { + let mut frame = InterruptStackFrame { + value: InterruptStackFrameValue { + instruction_pointer: VirtAddr::new(0x1000), + code_segment: 0, + cpu_flags: 0, + stack_pointer: VirtAddr::new(0x2000), + stack_segment: 0, + }, + }; + + unsafe { + frame + .as_mut() + .update(|f| f.instruction_pointer = f.instruction_pointer + 2u64); + } + } }