Struct x86_64::VirtAddr [−][src]
#[repr(transparent)]pub struct VirtAddr(_);
A canonical 64-bit virtual 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 UsizeConversions
trait can be used for performing conversions
between u64
and usize
.
On x86_64
, only the 48 lower bits of a virtual address can be used. The top 16 bits need
to be copies of bit 47, i.e. the most significant bit. Addresses that fulfil this criterium
are called “canonical”. This type guarantees that it always represents a canonical address.
Methods
impl VirtAddr
[src]
impl VirtAddr
pub fn new(addr: u64) -> VirtAddr
[src]
pub fn new(addr: u64) -> VirtAddr
Creates a new canonical virtual address.
This function performs sign extension of bit 47 to make the address canonical. Panics if the bits in the range 48 to 64 contain data (i.e. are not null and no sign extension).
pub fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid>
[src]
pub fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid>
Tries to create a new canonical virtual address.
This function tries to performs sign extension of bit 47 to make the address canonical. It succeeds if bits 48 to 64 are either a correct sign extension (i.e. copies of bit 47) or all null. Else, an error is returned.
pub fn new_unchecked(addr: u64) -> VirtAddr
[src]
pub fn new_unchecked(addr: u64) -> VirtAddr
Creates a new canonical virtual address without checks.
This function performs sign extension of bit 47 to make the address canonical, so
bits 48 to 64 are overwritten. If you want to check that these bits contain no data,
use new
or try_new
.
pub const fn zero() -> VirtAddr
[src]
pub const fn zero() -> VirtAddr
Creates a virtual address that points to 0
.
pub fn as_u64(self) -> u64
[src]
pub fn as_u64(self) -> u64
Converts the address to an u64
.
pub fn as_ptr<T>(self) -> *const T
[src]
pub fn as_ptr<T>(self) -> *const T
Converts the address to a raw pointer.
pub fn as_mut_ptr<T>(self) -> *mut T
[src]
pub fn as_mut_ptr<T>(self) -> *mut T
Converts the address to a mutable raw pointer.
pub fn align_up<U>(self, align: U) -> Self where
U: Into<u64>,
[src]
pub fn align_up<U>(self, align: U) -> Self where
U: Into<u64>,
Aligns the virtual address upwards to the given alignment.
See the align_up
function for more information.
pub fn align_down<U>(self, align: U) -> Self where
U: Into<u64>,
[src]
pub fn align_down<U>(self, align: U) -> Self where
U: Into<u64>,
Aligns the virtual address downwards to the given alignment.
See the align_down
function for more information.
pub fn is_aligned<U>(self, align: U) -> bool where
U: Into<u64>,
[src]
pub fn is_aligned<U>(self, align: U) -> bool where
U: Into<u64>,
Checks whether the virtual address has the demanded alignment.
pub fn page_offset(&self) -> u12
[src]
pub fn page_offset(&self) -> u12
Returns the 12-bit page offset of this virtual address.
pub fn p1_index(&self) -> u9
[src]
pub fn p1_index(&self) -> u9
Returns the 9-bit level 1 page table index.
pub fn p2_index(&self) -> u9
[src]
pub fn p2_index(&self) -> u9
Returns the 9-bit level 2 page table index.
pub fn p3_index(&self) -> u9
[src]
pub fn p3_index(&self) -> u9
Returns the 9-bit level 3 page table index.
pub fn p4_index(&self) -> u9
[src]
pub fn p4_index(&self) -> u9
Returns the 9-bit level 4 page table index.
Trait Implementations
impl Clone for VirtAddr
[src]
impl Clone for VirtAddr
fn clone(&self) -> VirtAddr
[src]
fn clone(&self) -> VirtAddr
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for VirtAddr
[src]
impl Copy for VirtAddr
impl PartialEq for VirtAddr
[src]
impl PartialEq for VirtAddr
fn eq(&self, other: &VirtAddr) -> bool
[src]
fn eq(&self, other: &VirtAddr) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &VirtAddr) -> bool
[src]
fn ne(&self, other: &VirtAddr) -> bool
This method tests for !=
.
impl Eq for VirtAddr
[src]
impl Eq for VirtAddr
impl PartialOrd for VirtAddr
[src]
impl PartialOrd for VirtAddr
fn partial_cmp(&self, other: &VirtAddr) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &VirtAddr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &VirtAddr) -> bool
[src]
fn lt(&self, other: &VirtAddr) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &VirtAddr) -> bool
[src]
fn le(&self, other: &VirtAddr) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &VirtAddr) -> bool
[src]
fn gt(&self, other: &VirtAddr) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &VirtAddr) -> bool
[src]
fn ge(&self, other: &VirtAddr) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for VirtAddr
[src]
impl Ord for VirtAddr
fn cmp(&self, other: &VirtAddr) -> Ordering
[src]
fn cmp(&self, other: &VirtAddr) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Debug for VirtAddr
[src]
impl Debug for VirtAddr
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Add<u64> for VirtAddr
[src]
impl Add<u64> for VirtAddr
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: u64) -> Self::Output
[src]
fn add(self, rhs: u64) -> Self::Output
Performs the +
operation.
impl AddAssign<u64> for VirtAddr
[src]
impl AddAssign<u64> for VirtAddr
fn add_assign(&mut self, rhs: u64)
[src]
fn add_assign(&mut self, rhs: u64)
Performs the +=
operation.
impl Add<usize> for VirtAddr where
u64: FromUsize,
[src]
impl Add<usize> for VirtAddr where
u64: FromUsize,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: usize) -> Self::Output
[src]
fn add(self, rhs: usize) -> Self::Output
Performs the +
operation.
impl AddAssign<usize> for VirtAddr where
u64: FromUsize,
[src]
impl AddAssign<usize> for VirtAddr where
u64: FromUsize,
fn add_assign(&mut self, rhs: usize)
[src]
fn add_assign(&mut self, rhs: usize)
Performs the +=
operation.
impl Sub<u64> for VirtAddr
[src]
impl Sub<u64> for VirtAddr
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: u64) -> Self::Output
[src]
fn sub(self, rhs: u64) -> Self::Output
Performs the -
operation.
impl SubAssign<u64> for VirtAddr
[src]
impl SubAssign<u64> for VirtAddr
fn sub_assign(&mut self, rhs: u64)
[src]
fn sub_assign(&mut self, rhs: u64)
Performs the -=
operation.
impl Sub<usize> for VirtAddr where
u64: FromUsize,
[src]
impl Sub<usize> for VirtAddr where
u64: FromUsize,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: usize) -> Self::Output
[src]
fn sub(self, rhs: usize) -> Self::Output
Performs the -
operation.
impl SubAssign<usize> for VirtAddr where
u64: FromUsize,
[src]
impl SubAssign<usize> for VirtAddr where
u64: FromUsize,
fn sub_assign(&mut self, rhs: usize)
[src]
fn sub_assign(&mut self, rhs: usize)
Performs the -=
operation.
impl Sub<VirtAddr> for VirtAddr
[src]
impl Sub<VirtAddr> for VirtAddr