Struct memory_structs::Page

source ·
pub struct Page<P: PageSize = Page4K> { /* private fields */ }
Expand description

A Page is a chunk of virtual memory aligned to a page boundary (default 4KiB) given by the P parameter.

Implementations§

source§

impl Page<Page4K>

source

pub const fn containing_address(addr: VirtualAddress) -> Page

Returns the 4KiB Page containing the given VirtualAddress.

source

pub const fn align_up(&self, alignment_4k_pages: usize) -> Page

Returns a new Page that is aligned up from this Page to the nearest multiple of alignment_4k_pages.

source

pub const fn from_4k_into_generic<P: PageSize>(self) -> Page<P>

Converts a known 4K-sized Page into a Page<P> with a generic PageSize parameter.

source§

impl Page<Page2M>

source

pub const fn containing_address_2mb(addr: VirtualAddress) -> Page<Page2M>

Returns the 2MiB huge Page containing the given VirtualAddress.

source

pub const fn from_2m_into_generic<P: PageSize>(self) -> Page<P>

Converts a known 2M-sized Page into a Page<P> with a generic PageSize parameter.

source§

impl Page<Page1G>

source

pub const fn containing_address_1gb(addr: VirtualAddress) -> Page<Page1G>

Returns the 1GiB huge Page containing the given VirtualAddress.

source

pub const fn from_1g_into_generic<P: PageSize>(self) -> Page<P>

Converts a known 1G-sized Page into a Page<P> with a generic PageSize parameter.

source§

impl<P: PageSize> Page<P>

source

pub const MIN: Page<P> = _

The minimum (smallest) valid value a Page can have.

source

pub const MAX: Page<P> = _

The maximum (largest) valid value a Page can have.

source

pub const fn number(&self) -> usize

Returns the 4K-sized number of this Page.

source

pub const fn start_address(&self) -> VirtualAddress

Returns the VirtualAddress at the start of this Page.

source

pub const fn page_size(&self) -> MemChunkSize

Returns the size of this Page.

source§

impl<P: PageSize> Page<P>

source

pub const fn p4_index(&self) -> usize

Returns the 9-bit part of this Page’s VirtualAddress that is the index into the P4 page table entries list.

source

pub const fn p3_index(&self) -> usize

Returns the 9-bit part of this Page’s VirtualAddress that is the index into the P3 page table entries list.

source

pub const fn p2_index(&self) -> usize

Returns the 9-bit part of this Page’s VirtualAddress that is the index into the P2 page table entries list.

source

pub const fn p1_index(&self) -> usize

Returns the 9-bit part of this Page’s VirtualAddress that is the index into the P1 page table entries list.

Using this returned usize value as an index into the P1 entries list will give you the final PTE, from which you can extract the mapped Frame using PageTableEntry::pointed_frame().

Trait Implementations§

source§

impl<P: PageSize> Add<usize> for Page<P>

§

type Output = Page<P>

The resulting type after applying the + operator.
source§

fn add(self, rhs: usize) -> Page<P>

Performs the + operation. Read more
source§

impl<P: PageSize> AddAssign<usize> for Page<P>

source§

fn add_assign(&mut self, rhs: usize)

Performs the += operation. Read more
source§

impl<P: Clone + PageSize> Clone for Page<P>

source§

fn clone(&self) -> Page<P>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<P: PageSize> Debug for Page<P>

source§

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

Formats the value using the given formatter. Read more
source§

impl From<Page<Page1G>> for Page<Page4K>

source§

fn from(p: Page<Page1G>) -> Self

Converts to this type from the input type.
source§

impl From<Page<Page2M>> for Page<Page4K>

source§

fn from(p: Page<Page2M>) -> Self

Converts to this type from the input type.
source§

impl<P: Ord + PageSize> Ord for Page<P>

source§

fn cmp(&self, other: &Page<P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<P: PartialEq + PageSize> PartialEq<Page<P>> for Page<P>

source§

fn eq(&self, other: &Page<P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P: PartialOrd + PageSize> PartialOrd<Page<P>> for Page<P>

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<P: PageSize> Step for Page<P>

source§

fn steps_between(start: &Page<P>, end: &Page<P>) -> Option<usize>

🔬This is a nightly-only experimental API. (step_trait)
Returns the number of successor steps required to get from start to end. Read more
source§

fn forward_checked(start: Page<P>, count: usize) -> Option<Page<P>>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
source§

fn backward_checked(start: Page<P>, count: usize) -> Option<Page<P>>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
source§

fn forward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
source§

unsafe fn forward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
source§

fn backward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
source§

unsafe fn backward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
source§

impl<P: PageSize> Sub<usize> for Page<P>

§

type Output = Page<P>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: usize) -> Page<P>

Performs the - operation. Read more
source§

impl<P: PageSize> SubAssign<usize> for Page<P>

source§

fn sub_assign(&mut self, rhs: usize)

Performs the -= operation. Read more
source§

impl TryFrom<Page<Page4K>> for Page<Page1G>

§

type Error = &'static str

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

fn try_from(p: Page) -> Result<Self, &'static str>

Performs the conversion.
source§

impl TryFrom<Page<Page4K>> for Page<Page2M>

§

type Error = &'static str

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

fn try_from(p: Page) -> Result<Self, &'static str>

Performs the conversion.
source§

impl<P: Copy + PageSize> Copy for Page<P>

source§

impl<P: Eq + PageSize> Eq for Page<P>

source§

impl<P: PageSize> StructuralEq for Page<P>

source§

impl<P: PageSize> StructuralPartialEq for Page<P>

Auto Trait Implementations§

§

impl<P> RefUnwindSafe for Page<P>where P: RefUnwindSafe,

§

impl<P> Send for Page<P>where P: Send,

§

impl<P> Sync for Page<P>where P: Sync,

§

impl<P> Unpin for Page<P>where P: Unpin,

§

impl<P> UnwindSafe for Page<P>where P: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.