Skip to content

Commit 6461745

Browse files
authored
Merge pull request #312 from haraldh/isr_frame
fix: enable manipulation of `InterruptStackFrame`
2 parents 31172ac + 0ad7789 commit 6461745

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/structures/idt.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ impl fmt::Debug for InterruptStackFrame {
851851
}
852852

853853
/// Represents the interrupt stack frame pushed by the CPU on interrupt or exception entry.
854-
#[derive(Clone)]
854+
#[derive(Clone, Copy)]
855855
#[repr(C)]
856856
pub struct InterruptStackFrameValue {
857857
/// This value points to the instruction that should be executed when the interrupt
@@ -1115,4 +1115,23 @@ mod test {
11151115
phantom: PhantomData,
11161116
})
11171117
}
1118+
1119+
#[test]
1120+
fn isr_frame_manipulation() {
1121+
let mut frame = InterruptStackFrame {
1122+
value: InterruptStackFrameValue {
1123+
instruction_pointer: VirtAddr::new(0x1000),
1124+
code_segment: 0,
1125+
cpu_flags: 0,
1126+
stack_pointer: VirtAddr::new(0x2000),
1127+
stack_segment: 0,
1128+
},
1129+
};
1130+
1131+
unsafe {
1132+
frame
1133+
.as_mut()
1134+
.update(|f| f.instruction_pointer = f.instruction_pointer + 2u64);
1135+
}
1136+
}
11181137
}

0 commit comments

Comments
 (0)