pub struct VirtAddr(/* private fields */);
Expand description
A virtual memory address on riscv64
.
64-bit addresses on riscv64 “must have bits 63–48 all equal to bit 47, or else a page-fault exception will occur.”
Implementations§
Source§impl VirtAddr
impl VirtAddr
Sourcepub const unsafe fn new_unsafe(addr: u64) -> VirtAddr
pub const unsafe fn new_unsafe(addr: u64) -> VirtAddr
Creates a new address, without any checks.
§Safety
If addr
does not comply with the platforms requirements for
this address type, this can lead to UB in functions relying on
the compliance or when using the requirements.
Source§impl VirtAddr
impl VirtAddr
Sourcepub const fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid>
pub const fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid>
Tries to create a new canonical virtual address.
Sourcepub const fn new_truncate(addr: u64) -> VirtAddr
pub const fn new_truncate(addr: u64) -> VirtAddr
Creates a new canonical virtual address.
This function performs sign extension of bit 47 to make the address canonical, overwriting bits 48 to 63.
Sourcepub fn from_ptr<T: ?Sized>(ptr: *const T) -> Self
pub fn from_ptr<T: ?Sized>(ptr: *const T) -> Self
Creates a virtual address from the given pointer
Sourcepub const fn as_mut_ptr<T>(self) -> *mut T
pub const fn as_mut_ptr<T>(self) -> *mut T
Converts the address to a mutable raw pointer.
pub const fn as_usize(&self) -> usize
Sourcepub fn base_page_offset(self) -> u64
pub fn base_page_offset(self) -> u64
Offset within the 4 KiB page.
Sourcepub fn large_page_offset(self) -> u64
pub fn large_page_offset(self) -> u64
Offset within the 2 MiB page.
Sourcepub fn giga_page_offset(self) -> u64
pub fn giga_page_offset(self) -> u64
Offset within the 1 GiB page.
Sourcepub fn tera_page_offset(self) -> u64
pub fn tera_page_offset(self) -> u64
Offset within the 512 GiB page.
Trait Implementations§
Source§impl AddAssign<u64> for VirtAddr
impl AddAssign<u64> for VirtAddr
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+=
operation. Read moreSource§impl AddAssign<usize> for VirtAddr
impl AddAssign<usize> for VirtAddr
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
+=
operation. Read moreSource§impl BitAndAssign<u64> for VirtAddr
impl BitAndAssign<u64> for VirtAddr
Source§fn bitand_assign(&mut self, rhs: u64)
fn bitand_assign(&mut self, rhs: u64)
&=
operation. Read moreSource§impl BitOrAssign<u64> for VirtAddr
impl BitOrAssign<u64> for VirtAddr
Source§fn bitor_assign(&mut self, rhs: u64)
fn bitor_assign(&mut self, rhs: u64)
|=
operation. Read moreSource§impl BitXorAssign<u64> for VirtAddr
impl BitXorAssign<u64> for VirtAddr
Source§fn bitxor_assign(&mut self, rhs: u64)
fn bitxor_assign(&mut self, rhs: u64)
^=
operation. Read moreSource§impl MemoryAddress for VirtAddr
impl MemoryAddress for VirtAddr
Source§impl Ord for VirtAddr
impl Ord for VirtAddr
Source§impl PartialOrd for VirtAddr
impl PartialOrd for VirtAddr
Source§impl ShlAssign<usize> for VirtAddr
impl ShlAssign<usize> for VirtAddr
Source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read moreSource§impl ShrAssign<usize> for VirtAddr
impl ShrAssign<usize> for VirtAddr
Source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moreSource§impl SubAssign<u64> for VirtAddr
impl SubAssign<u64> for VirtAddr
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-=
operation. Read moreSource§impl SubAssign<usize> for VirtAddr
impl SubAssign<usize> for VirtAddr
Source§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
-=
operation. Read more