AddrSpace

Struct AddrSpace 

Source
pub struct AddrSpace<H: PagingHandler> { /* private fields */ }
Expand description

The virtual memory address space.

Implementations§

Source§

impl<H: PagingHandler> AddrSpace<H>

Source

pub const fn base(&self) -> GuestPhysAddr

Returns the address space base.

Source

pub const fn end(&self) -> GuestPhysAddr

Returns the address space end.

Source

pub fn size(&self) -> usize

Returns the address space size.

Source

pub const fn page_table( &self, ) -> &PageTable64<ExtendedPageTableMetadata, EPTEntry, H>

Returns the reference to the inner page table.

Source

pub const fn page_table_root(&self) -> PhysAddr

Returns the root physical address of the inner page table.

Source

pub fn contains_range(&self, start: GuestPhysAddr, size: usize) -> bool

Checks if the address space contains the given address range.

Source

pub fn new_empty(base: GuestPhysAddr, size: usize) -> AxResult<Self>

Creates a new empty address space.

Source

pub fn map_linear( &mut self, start_vaddr: GuestPhysAddr, start_paddr: PhysAddr, size: usize, flags: MappingFlags, ) -> AxResult

Add a new linear mapping.

See Backend for more details about the mapping backends.

The flags parameter indicates the mapping permissions and attributes.

Source

pub fn map_alloc( &mut self, start: GuestPhysAddr, size: usize, flags: MappingFlags, populate: bool, ) -> AxResult

Add a new allocation mapping.

See Backend for more details about the mapping backends.

The flags parameter indicates the mapping permissions and attributes.

Source

pub fn unmap(&mut self, start: GuestPhysAddr, size: usize) -> AxResult

Removes mappings within the specified virtual address range.

Source

pub fn clear(&mut self)

Removes all mappings in the address space.

Source

pub fn handle_page_fault( &mut self, vaddr: GuestPhysAddr, access_flags: MappingFlags, ) -> bool

Handles a page fault at the given address.

access_flags indicates the access type that caused the page fault.

Returns true if the page fault is handled successfully (not a real fault).

Source

pub fn translate(&self, vaddr: GuestPhysAddr) -> Option<PhysAddr>

Translates the given VirtAddr into PhysAddr.

Returns None if the virtual address is out of range or not mapped.

Source

pub fn translated_byte_buffer( &self, vaddr: GuestPhysAddr, len: usize, ) -> Option<Vec<&'static mut [u8]>>

Translate&Copy the given VirtAddr with LENGTH len to a mutable u8 Vec through page table.

Returns None if the virtual address is out of range or not mapped.

Source

pub fn translate_and_get_limit( &self, vaddr: GuestPhysAddr, ) -> Option<(PhysAddr, usize)>

Translates the given VirtAddr into PhysAddr, and returns the size of the MemoryArea corresponding to the target vaddr.

Returns None if the virtual address is out of range or not mapped.

Trait Implementations§

Source§

impl<H: PagingHandler> Debug for AddrSpace<H>

Source§

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

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

impl<H: PagingHandler> Drop for AddrSpace<H>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<H> Freeze for AddrSpace<H>

§

impl<H> RefUnwindSafe for AddrSpace<H>
where H: RefUnwindSafe,

§

impl<H> Send for AddrSpace<H>
where H: Send,

§

impl<H> Sync for AddrSpace<H>
where H: Sync,

§

impl<H> Unpin for AddrSpace<H>
where H: Unpin,

§

impl<H> UnwindSafe for AddrSpace<H>

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.