Skip to content

Commit 9f2114c

Browse files
authored
Merge pull request #324 from Freax13/interrupt-stack-frame-types
change `cpu_flags`'s type to `RFlags`
2 parents 9ce47b3 + c49a3b3 commit 9f2114c

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ edition = "2018"
2727

2828
[dependencies]
2929
bit_field = "0.9.0"
30-
bitflags = "1.0.4"
30+
bitflags = "1.3.2"
3131
volatile = "0.4.4"
3232

3333
[build-dependencies]

src/registers/rflags.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ pub use self::x86_64::*;
66
use bitflags::bitflags;
77

88
bitflags! {
9-
/// The RFLAGS register.
9+
/// The RFLAGS register. All bit patterns are valid representations for this type.
10+
#[repr(transparent)]
1011
pub struct RFlags: u64 {
1112
/// Processor feature identification flag.
1213
///

src/structures/idt.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//!
2121
//! These types are defined for the compatibility with the Nightly Rust build.
2222
23+
use crate::registers::rflags::RFlags;
2324
use crate::{PrivilegeLevel, VirtAddr};
2425
use bit_field::BitField;
2526
use bitflags::bitflags;
@@ -938,7 +939,7 @@ pub struct InterruptStackFrameValue {
938939
pub code_segment: SegmentSelector,
939940
_reserved1: [u8; 6],
940941
/// The flags register before the interrupt handler was invoked.
941-
pub cpu_flags: u64,
942+
pub cpu_flags: RFlags,
942943
/// The stack pointer at the time of the interrupt.
943944
pub stack_pointer: VirtAddr,
944945
/// The stack segment descriptor at the time of the interrupt (often zero in 64-bit mode).
@@ -948,17 +949,10 @@ pub struct InterruptStackFrameValue {
948949

949950
impl fmt::Debug for InterruptStackFrameValue {
950951
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
951-
struct Hex(u64);
952-
impl fmt::Debug for Hex {
953-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
954-
write!(f, "{:#x}", self.0)
955-
}
956-
}
957-
958952
let mut s = f.debug_struct("InterruptStackFrame");
959953
s.field("instruction_pointer", &self.instruction_pointer);
960954
s.field("code_segment", &self.code_segment);
961-
s.field("cpu_flags", &Hex(self.cpu_flags));
955+
s.field("cpu_flags", &self.cpu_flags);
962956
s.field("stack_pointer", &self.stack_pointer);
963957
s.field("stack_segment", &self.stack_segment);
964958
s.finish()

0 commit comments

Comments
 (0)