#[repr(transparent)]pub struct PhysAddr(_);
Expand description
A 64-bit physical memory address.
This is a wrapper type around an u64
, so it is always 8 bytes, even when compiled
on non 64-bit systems. The
TryFrom
trait can be used for performing conversions
between u64
and usize
.
On x86_64
, only the 52 lower bits of a physical address can be used. The top 12 bits need
to be zero. This type guarantees that it always represents a valid physical address.
Implementations
sourceimpl PhysAddr
impl PhysAddr
sourcepub const fn new_truncate(addr: u64) -> PhysAddr
pub const fn new_truncate(addr: u64) -> PhysAddr
Creates a new physical address, throwing bits 52..64 away.
sourcepub const unsafe fn new_unsafe(addr: u64) -> PhysAddr
pub const unsafe fn new_unsafe(addr: u64) -> PhysAddr
Creates a new physical address, without any checks.
Safety
You must make sure bits 52..64 are zero. This is not checked.
sourcepub const fn try_new(addr: u64) -> Result<Self, PhysAddrNotValid>
pub const fn try_new(addr: u64) -> Result<Self, PhysAddrNotValid>
Tries to create a new physical address.
Fails if any bits in the range 52 to 64 are set.
sourcepub const fn is_null(self) -> bool
pub const fn is_null(self) -> bool
Convenience method for checking if a physical address is null.
sourcepub fn align_up<U>(self, align: U) -> Self where
U: Into<u64>,
pub fn align_up<U>(self, align: U) -> Self where
U: Into<u64>,
Aligns the physical address upwards to the given alignment.
See the align_up
function for more information.
sourcepub fn align_down<U>(self, align: U) -> Self where
U: Into<u64>,
pub fn align_down<U>(self, align: U) -> Self where
U: Into<u64>,
Aligns the physical address downwards to the given alignment.
See the align_down
function for more information.
sourcepub fn is_aligned<U>(self, align: U) -> bool where
U: Into<u64>,
pub fn is_aligned<U>(self, align: U) -> bool where
U: Into<u64>,
Checks whether the physical address has the demanded alignment.
Trait Implementations
sourceimpl AddAssign<u64> for PhysAddr
impl AddAssign<u64> for PhysAddr
sourcefn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
Performs the +=
operation. Read more
sourceimpl AddAssign<usize> for PhysAddr
impl AddAssign<usize> for PhysAddr
sourcefn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the +=
operation. Read more
sourceimpl Ord for PhysAddr
impl Ord for PhysAddr
sourceimpl PartialOrd<PhysAddr> for PhysAddr
impl PartialOrd<PhysAddr> for PhysAddr
sourcefn partial_cmp(&self, other: &PhysAddr) -> Option<Ordering>
fn partial_cmp(&self, other: &PhysAddr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<u64> for PhysAddr
impl SubAssign<u64> for PhysAddr
sourcefn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
Performs the -=
operation. Read more
sourceimpl SubAssign<usize> for PhysAddr
impl SubAssign<usize> for PhysAddr
sourcefn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
Performs the -=
operation. Read more
impl Copy for PhysAddr
impl Eq for PhysAddr
impl StructuralEq for PhysAddr
impl StructuralPartialEq for PhysAddr
Auto Trait Implementations
impl RefUnwindSafe for PhysAddr
impl Send for PhysAddr
impl Sync for PhysAddr
impl Unpin for PhysAddr
impl UnwindSafe for PhysAddr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more