pub struct PageLevel<PTE>{
pub shift_bits: usize,
pub va_bits: usize,
pub present_bit: (PTE, PTE),
pub huge_page_bit: (PTE, PTE),
pub page_table_mask: PTE,
}Expand description
Describes a single page level of the page hierarchy.
Fields§
§shift_bits: usizeThe number of bits to shift right in the virtual address to get the index bits for this page level.
va_bits: usizeThe number of bits in the virtual address to extract as the index for this page level.
present_bit: (PTE, PTE)The present bit in the PTE. The first mask is to select the relevants bits, the second is what the value should be upon masking.
huge_page_bit: (PTE, PTE)The huge page bit in the PTE. If the current page level does not support huge pages, then this should be set to zero. The first mask is to select the relevant bits, the second is what the value should be upon masking.
page_table_mask: PTEThe page table mask that should be set when allocating new page tables.
Implementations§
Source§impl<PTE> PageLevel<PTE>
impl<PTE> PageLevel<PTE>
Sourcepub fn entries(&self) -> usize
pub fn entries(&self) -> usize
Calculates the number of entries present in a page table for this page level.
Sourcepub fn mask(&self) -> usize
pub fn mask(&self) -> usize
Calculates the shifted mask to select the appropriate bits from the virtual address.
Sourcepub fn end(&self, addr: usize) -> usize
pub fn end(&self, addr: usize) -> usize
Calculates the last virtual address within the same page for the current page level of the given a virtual address. This can be used to retrieve the first address of the next page for the current page level by simply adding one.
Sourcepub fn pte_index(&self, addr: usize) -> usize
pub fn pte_index(&self, addr: usize) -> usize
Calculates the PTE index of the given virtual address for the current page table level, which can then be used to index into the page table to get the corresponding PTE for this virtual address.
Sourcepub fn is_present(&self, pte: PTE) -> bool
pub fn is_present(&self, pte: PTE) -> bool
Given a PTE, it checks if the PTE points to a present page or page table.
Sourcepub fn is_huge_page(&self, pte: PTE) -> bool
pub fn is_huge_page(&self, pte: PTE) -> bool
Given a PTE, it checks if the PTE points to a huge page. Always returns false if the
current page level does not support huge pages.