Skip to main content

VirtAddr

Struct VirtAddr 

Source
#[repr(transparent)]
pub struct VirtAddr(u64);
Expand description

A type representing virtual addresses in the CPU’s virtual address space

Tuple Fields§

§0: u64

Implementations§

Source§

impl VirtAddr

Source

pub const fn new(addr: u64) -> Self

Creates a new VirtAddr from a raw u64 address

Source

pub const fn null() -> Self

Creates a new VirtAddr which points to 0

Source

pub fn from_ptr<T>(ptr: *const T) -> Self

Creates a new VirtAddr from a *const T or *mut T pointer

Source

pub fn from_phys(phys: PhysAddr) -> Self

Creates a new VirtAddr from a physical address

Source

pub fn as_u64(self) -> u64

Returns the address as a u64

Source

pub fn as_usize(self) -> usize

Returns the address as a usize

Source

pub fn as_ptr<T>(self) -> *const T

Returns the address as a *const T pointer

Source

pub fn as_mut_ptr<T>(self) -> *mut T

Returns the address as a *mut T pointer

Source

pub fn align_up(self, align: u64) -> Self

Returns a new address aligned to the next larger address which is aligned to align

§Panics

In debug builds if align is not a power of two

Source

pub fn align_down(self, align: u64) -> Self

Returns a new address aligned to the next smaller address which is aligned to align

§Panics

In debug builds if align is not a power of two

Source

pub fn is_aligned(self, align: u64) -> bool

Check whether the address is aligned to align

Source§

impl VirtAddr

Source

pub fn as_x86_64(self) -> VirtAddr

Returns a [x86_64::VirtAddr] with the same address value

Source

pub fn p1_index(self) -> PageTableIndex

Returns the index into the P1 page table (PT) for this virtual address, in range 0..512

Source

pub fn p2_index(self) -> PageTableIndex

Returns the index into the P2 page table (PD) for this virtual address, in range 0..512

Source

pub fn p3_index(self) -> PageTableIndex

Returns the index into the P3 page table (PDPT) for this virtual address, in range 0..512

Source

pub fn p4_index(self) -> PageTableIndex

Returns the index into the P4 page table (PML4) for this virtual address, in range 0..512

Trait Implementations§

Source§

impl Add for VirtAddr

Source§

fn add(self, rhs: VirtAddr) -> Self::Output

Add trait for adding a VirtAddr to a VirtAddr, returns a new instance of VirtAddr

Source§

type Output = VirtAddr

The resulting type after applying the + operator.
Source§

impl Add<u64> for VirtAddr

Source§

fn add(self, rhs: u64) -> Self::Output

Add trait for adding a u64 to a VirtAddr, returns a new instance of VirtAddr

Source§

type Output = VirtAddr

The resulting type after applying the + operator.
Source§

impl AddAssign for VirtAddr

Source§

fn add_assign(&mut self, rhs: VirtAddr)

AddAssign trait for add-assigning a VirtAddr to a VirtAddr

Source§

impl AddAssign<u64> for VirtAddr

Source§

fn add_assign(&mut self, rhs: u64)

AddAssign trait for add-assigning a u64 to a VirtAddr

Source§

impl Borrow<VirtAddr> for Vma

Source§

fn borrow(&self) -> &VirtAddr

Returns a reference to Vma::start_addr to make it possible for [BTreeSet] to compare it with a VirtAddr directly

Source§

impl Clone for VirtAddr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for VirtAddr

Source§

impl Debug for VirtAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the address as VirtAddr(0x<hex>) (e.g. VirtAddr(0xffff800000000000))

Source§

impl Display for VirtAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the address as 0x<hex> (e.g. 0xffff800000000000)

Source§

impl Eq for VirtAddr

Source§

impl Hash for VirtAddr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl LowerHex for VirtAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Delegates to the inner u64 for {:x} / {:#x} to work

Source§

impl Ord for VirtAddr

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0 (const: unstable)§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable)§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable)§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for VirtAddr

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for VirtAddr

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable)§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable)§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable)§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable)§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Pointer for VirtAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Delegates to the inner u64, cast to *const () for {:p} to work

Source§

impl StructuralPartialEq for VirtAddr

Source§

impl Sub for VirtAddr

Source§

fn sub(self, rhs: VirtAddr) -> Self::Output

Sub trait for subtracting a VirtAddr from a VirtAddr, returns a new instance of VirtAddr

Source§

type Output = VirtAddr

The resulting type after applying the - operator.
Source§

impl Sub<u64> for VirtAddr

Source§

fn sub(self, rhs: u64) -> Self::Output

Sub trait for subtracting a u64 from a VirtAddr, returns a new instance of VirtAddr

Source§

type Output = VirtAddr

The resulting type after applying the - operator.
Source§

impl SubAssign for VirtAddr

Source§

fn sub_assign(&mut self, rhs: VirtAddr)

SubAssign trait for sub-assigning a VirtAddr from a VirtAddr

Source§

impl SubAssign<u64> for VirtAddr

Source§

fn sub_assign(&mut self, rhs: u64)

SubAssign trait for sub-assigning a u64 from a VirtAddr

Source§

impl UpperHex for VirtAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Delegates to the inner u64 for {:X} / {:#X} to work

Auto Trait Implementations§

§

impl Freeze for VirtAddr

§

impl RefUnwindSafe for VirtAddr

§

impl Send for VirtAddr

§

impl Sync for VirtAddr

§

impl Unpin for VirtAddr

§

impl UnsafeUnpin for VirtAddr

§

impl UnwindSafe for VirtAddr

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.