Skip to main content

MappingBackend

Trait MappingBackend 

Source
pub trait MappingBackend: Clone {
    type Addr: MemoryAddr;
    type Flags: Copy;
    type PageTable;

    // Required methods
    fn map(
        &self,
        start: Self::Addr,
        size: usize,
        flags: Self::Flags,
        page_table: &mut Self::PageTable,
    ) -> bool;
    fn unmap(
        &self,
        start: Self::Addr,
        size: usize,
        page_table: &mut Self::PageTable,
    ) -> bool;
    fn protect(
        &self,
        start: Self::Addr,
        size: usize,
        new_flags: Self::Flags,
        page_table: &mut Self::PageTable,
    ) -> bool;
    fn split(&mut self, align_diff: usize) -> Option<Self>;

    // Provided methods
    fn shrink_left(&mut self, _shrink_size: usize) { ... }
    fn shrink_right(&mut self, _shrink_size: usize) { ... }
}
Expand description

Underlying operations to do when manipulating mappings within the specific MemoryArea.

The backend can be different for different memory areas. e.g., for linear mappings, the target physical address is known when it is added to the page table. For lazy mappings, an empty mapping needs to be added to the page table to trigger a page fault.

Required Associated Types§

Source

type Addr: MemoryAddr

The address type used in the memory area.

Source

type Flags: Copy

The flags type used in the memory area.

Source

type PageTable

The page table type used in the memory area.

Required Methods§

Source

fn map( &self, start: Self::Addr, size: usize, flags: Self::Flags, page_table: &mut Self::PageTable, ) -> bool

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

Source

fn unmap( &self, start: Self::Addr, size: usize, page_table: &mut Self::PageTable, ) -> bool

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

Source

fn protect( &self, start: Self::Addr, size: usize, new_flags: Self::Flags, page_table: &mut Self::PageTable, ) -> bool

What to do when changing access flags.

Source

fn split(&mut self, align_diff: usize) -> Option<Self>

Splits the backend into two backends at the given alignment difference.

Provided Methods§

Source

fn shrink_left(&mut self, _shrink_size: usize)

Shrinks the backend from the left by the given size.

The backend start address is increased by shrink_size.

Source

fn shrink_right(&mut self, _shrink_size: usize)

Shrinks the backend from the right by the given size.

The backend end address is decreased by shrink_size.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§