Skip to main content

Backend

Enum Backend 

Source
pub enum Backend<H: PagingHandler> {
    Linear {
        pa_va_offset: usize,
    },
    Alloc {
        populate: bool,
        _phantom: PhantomData<H>,
    },
}
Expand description

A unified enum type for different memory mapping backends.

Currently, two backends are implemented:

  • Linear: used for linear mappings. The target physical frames are contiguous and their addresses should be known when creating the mapping.
  • Allocation: used in general, or for lazy mappings. The target physical frames are obtained from the global allocator.

Variants§

§

Linear

Linear mapping backend.

The offset between the virtual address and the physical address is constant, which is specified by pa_va_offset. For example, the virtual address vaddr is mapped to the physical address vaddr - pa_va_offset.

Fields

§pa_va_offset: usize

vaddr - paddr.

§

Alloc

Allocation mapping backend.

If populate is true, all physical frames are allocated when the mapping is created, and no page faults are triggered during the memory access. Otherwise, the physical frames are allocated on demand (by handling page faults).

Fields

§populate: bool

Whether to populate the physical frames when creating the mapping.

§_phantom: PhantomData<H>

A phantom data for the paging handler.

Implementations§

Source§

impl<H: PagingHandler> Backend<H>

Source

pub const fn new_alloc(populate: bool) -> Self

Creates a new allocation mapping backend.

Source§

impl<H: PagingHandler> Backend<H>

Source

pub const fn new_linear(pa_va_offset: usize) -> Self

Creates a new linear mapping backend.

Trait Implementations§

Source§

impl<H: PagingHandler> Clone for Backend<H>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<H: PagingHandler> MappingBackend for Backend<H>

Source§

type Addr = GuestPhysAddr

The address type used in the memory area.
Source§

type Flags = MappingFlags

The flags type used in the memory area.
Source§

type PageTable = PageTable64<A64HVPagingMetaData, A64PTEHV, H>

The page table type used in the memory area.
Source§

fn map( &self, start: GuestPhysAddr, size: usize, flags: MappingFlags, pt: &mut PageTable64<A64HVPagingMetaData, A64PTEHV, H>, ) -> bool

What to do when mapping a region within the area with the given flags.
Source§

fn unmap( &self, start: GuestPhysAddr, size: usize, pt: &mut PageTable64<A64HVPagingMetaData, A64PTEHV, H>, ) -> bool

What to do when unmaping a memory region within the area.
Source§

fn protect( &self, start: GuestPhysAddr, size: usize, new_flags: MappingFlags, page_table: &mut PageTable64<A64HVPagingMetaData, A64PTEHV, H>, ) -> bool

What to do when changing access flags.

Auto Trait Implementations§

§

impl<H> Freeze for Backend<H>

§

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

§

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

§

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

§

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

§

impl<H> UnsafeUnpin for Backend<H>

§

impl<H> UnwindSafe for Backend<H>
where H: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

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
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
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.