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

change cpu_flags's type to RFlags #324

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
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
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