Skip to main content

VirtualAddressSpace

Struct VirtualAddressSpace 

Source
pub struct VirtualAddressSpace<P: PhysicalMemoryProvider> {
    physical: P,
    page_table_root: u64,
    mode: TranslationMode,
    pagefiles: Vec<Box<dyn PagefileSource>>,
    prototype_source: Option<Box<dyn PrototypePteSource>>,
}
Expand description

A virtual address space backed by physical memory and page tables.

Fields§

§physical: P§page_table_root: u64§mode: TranslationMode§pagefiles: Vec<Box<dyn PagefileSource>>§prototype_source: Option<Box<dyn PrototypePteSource>>

Implementations§

Source§

impl<P: PhysicalMemoryProvider> VirtualAddressSpace<P>

Source

pub fn new(physical: P, page_table_root: u64, mode: TranslationMode) -> Self

Create a new virtual address space.

Source

pub fn with_pagefile(self, source: Box<dyn PagefileSource>) -> Self

Attach a pagefile source for resolving paged-out memory.

Source

pub fn with_prototype_source(self, source: Box<dyn PrototypePteSource>) -> Self

Attach a prototype PTE source for resolving shared section pages.

Source

pub fn virt_to_phys(&self, vaddr: u64) -> Result<u64>

Translate a virtual address to a physical address.

Source

pub fn read_virt(&self, vaddr: u64, buf: &mut [u8]) -> Result<()>

Read buf.len() bytes from virtual address vaddr, handling page boundary crossings.

Uses walk_x86_64_4level_internal() to resolve each 4K chunk, transparently handling physical, transition, demand-zero, and pagefile pages.

Source

fn read_pagefile_page( &self, vaddr: u64, pagefile_num: u8, page_offset: u64, ) -> Result<[u8; 4096]>

Source

pub fn physical(&self) -> &P

Return a reference to the underlying physical memory provider.

Source

pub fn mode(&self) -> TranslationMode

Return the translation mode.

Source

fn read_pte(&self, addr: u64) -> Result<u64>

Source

fn walk_x86_64_4level(&self, vaddr: u64) -> Result<u64>

Source

fn walk_x86_64_4level_internal(&self, vaddr: u64) -> Result<TranslationResult>

Source

fn decode_non_present_pte(pte: u64, page_offset: u64) -> TranslationResult

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.