Skip to content

Commit

Permalink
Merge pull request #334 from Freax13/cr2-read-raw
Browse files Browse the repository at this point in the history
add `Cr2::read_raw`
  • Loading branch information
Freax13 authored Jan 17, 2022
2 parents bb82677 + 38537d1 commit 5014113
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/registers/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ mod x86_64 {
/// Read the current page fault linear address from the CR2 register.
#[inline]
pub fn read() -> VirtAddr {
VirtAddr::new(Self::read_raw())
}

/// Read the current page fault linear address from the CR2 register as a raw `u64`.
#[inline]
pub fn read_raw() -> u64 {
let value: u64;

#[cfg(feature = "inline_asm")]
Expand All @@ -264,7 +270,7 @@ mod x86_64 {
value = crate::asm::x86_64_asm_read_cr2();
}

VirtAddr::new(value)
value
}
}

Expand Down

0 comments on commit 5014113

Please sign in to comment.