pub struct PhysAddr(/* private fields */);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§
Source§impl PhysAddr
impl PhysAddr
Sourcepub const fn new(addr: u64) -> Self
pub const fn new(addr: u64) -> Self
Creates a new physical address.
§Panics
This function panics if a bit in the range 52 to 64 is set.
If the memory_encryption feature has been enabled and an encryption bit has been
configured, this also panics if the encryption bit is manually set in the address.
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.
If the memory_encryption feature has been enabled and an encryption bit has been
configured, this also fails if the encryption bit is manually set in the address.
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) -> Selfwhere
U: Into<u64>,
pub fn align_up<U>(self, align: U) -> Selfwhere
U: Into<u64>,
Aligns the physical address upwards to the given alignment.
See the align_up function for more information.
§Panics
This function panics if the resulting address has a bit in the range 52 to 64 set.
Sourcepub fn align_down<U>(self, align: U) -> Selfwhere
U: Into<u64>,
pub fn align_down<U>(self, align: U) -> Selfwhere
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) -> boolwhere
U: Into<u64>,
pub fn is_aligned<U>(self, align: U) -> boolwhere
U: Into<u64>,
Checks whether the physical address has the demanded alignment.
Trait Implementations§
Source§impl AddAssign<u64> for PhysAddr
impl AddAssign<u64> for PhysAddr
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreimpl Copy for PhysAddr
impl Eq for PhysAddr
Source§impl Ord for PhysAddr
impl Ord for PhysAddr
1.21.0 (const: unstable)§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for PhysAddr
impl PartialOrd for PhysAddr
impl StructuralPartialEq for PhysAddr
Auto Trait Implementations§
impl Freeze for PhysAddr
impl RefUnwindSafe for PhysAddr
impl Send for PhysAddr
impl Sync for PhysAddr
impl Unpin for PhysAddr
impl UnsafeUnpin for PhysAddr
impl UnwindSafe for PhysAddr
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)