Skip to content

Commit

Permalink
Merge pull request #324 from Freax13/interrupt-stack-frame-types
Browse files Browse the repository at this point in the history
change `cpu_flags`'s type to `RFlags`
  • Loading branch information
josephlr authored Nov 11, 2021
2 parents 9ce47b3 + c49a3b3 commit 9f2114c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ edition = "2018"

[dependencies]
bit_field = "0.9.0"
bitflags = "1.0.4"
bitflags = "1.3.2"
volatile = "0.4.4"

[build-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion src/registers/rflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub use self::x86_64::*;
use bitflags::bitflags;

bitflags! {
/// The RFLAGS register.
/// The RFLAGS register. All bit patterns are valid representations for this type.
#[repr(transparent)]
pub struct RFlags: u64 {
/// Processor feature identification flag.
///
Expand Down
12 changes: 3 additions & 9 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//!
//! These types are defined for the compatibility with the Nightly Rust build.

use crate::registers::rflags::RFlags;
use crate::{PrivilegeLevel, VirtAddr};
use bit_field::BitField;
use bitflags::bitflags;
Expand Down Expand Up @@ -938,7 +939,7 @@ pub struct InterruptStackFrameValue {
pub code_segment: SegmentSelector,
_reserved1: [u8; 6],
/// The flags register before the interrupt handler was invoked.
pub cpu_flags: u64,
pub cpu_flags: RFlags,
/// The stack pointer at the time of the interrupt.
pub stack_pointer: VirtAddr,
/// The stack segment descriptor at the time of the interrupt (often zero in 64-bit mode).
Expand All @@ -948,17 +949,10 @@ pub struct InterruptStackFrameValue {

impl fmt::Debug for InterruptStackFrameValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct Hex(u64);
impl fmt::Debug for Hex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:#x}", self.0)
}
}

let mut s = f.debug_struct("InterruptStackFrame");
s.field("instruction_pointer", &self.instruction_pointer);
s.field("code_segment", &self.code_segment);
s.field("cpu_flags", &Hex(self.cpu_flags));
s.field("cpu_flags", &self.cpu_flags);
s.field("stack_pointer", &self.stack_pointer);
s.field("stack_segment", &self.stack_segment);
s.finish()
Expand Down

0 comments on commit 9f2114c

Please sign in to comment.