pub trait MappingBackend: Clone {
type Addr: MemoryAddr;
type Flags: Copy;
type MutationContext;
type PageTable;
// Required methods
fn map(
&self,
start: Self::Addr,
size: usize,
flags: Self::Flags,
context: &mut Self::MutationContext,
page_table: &mut Self::PageTable,
) -> bool;
fn unmap(
&self,
start: Self::Addr,
size: usize,
context: &mut Self::MutationContext,
page_table: &mut Self::PageTable,
) -> bool;
fn protect(
&self,
start: Self::Addr,
size: usize,
new_flags: Self::Flags,
context: &mut Self::MutationContext,
page_table: &mut Self::PageTable,
) -> bool;
fn split(&mut self, align_diff: usize) -> Option<Self>;
// Provided methods
fn validate_map(
&self,
_start: Self::Addr,
_size: usize,
_flags: Self::Flags,
_page_table: &Self::PageTable,
) -> bool { ... }
fn validate_unmap(
&self,
_start: Self::Addr,
_size: usize,
_page_table: &Self::PageTable,
) -> bool { ... }
fn validate_protect(
&self,
_start: Self::Addr,
_size: usize,
_new_flags: Self::Flags,
_page_table: &Self::PageTable,
) -> bool { ... }
fn shrink_left(&mut self, _shrink_size: usize) -> bool { ... }
fn shrink_right(&mut self, _shrink_size: usize) -> bool { ... }
}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§
Sourcetype Addr: MemoryAddr
type Addr: MemoryAddr
The address type used in the memory area.
Sourcetype MutationContext
type MutationContext
Per-mutation state that must be shared by all page-table operations in one logical mapping transaction.
Required Methods§
Sourcefn map(
&self,
start: Self::Addr,
size: usize,
flags: Self::Flags,
context: &mut Self::MutationContext,
page_table: &mut Self::PageTable,
) -> bool
fn map( &self, start: Self::Addr, size: usize, flags: Self::Flags, context: &mut Self::MutationContext, page_table: &mut Self::PageTable, ) -> bool
What to do when mapping a region within the area with the given flags.
Sourcefn unmap(
&self,
start: Self::Addr,
size: usize,
context: &mut Self::MutationContext,
page_table: &mut Self::PageTable,
) -> bool
fn unmap( &self, start: Self::Addr, size: usize, context: &mut Self::MutationContext, page_table: &mut Self::PageTable, ) -> bool
What to do when unmaping a memory region within the area.
Provided Methods§
Sourcefn validate_map(
&self,
_start: Self::Addr,
_size: usize,
_flags: Self::Flags,
_page_table: &Self::PageTable,
) -> bool
fn validate_map( &self, _start: Self::Addr, _size: usize, _flags: Self::Flags, _page_table: &Self::PageTable, ) -> bool
Read-only validation for a mapping operation. Backends that can
inspect conflicts or allocation requirements should override this
hook. MemorySet invokes it before an overlapping MAP_FIXED
operation removes the old mapping, so a rejected request has no
externally visible side effect.
Sourcefn validate_unmap(
&self,
_start: Self::Addr,
_size: usize,
_page_table: &Self::PageTable,
) -> bool
fn validate_unmap( &self, _start: Self::Addr, _size: usize, _page_table: &Self::PageTable, ) -> bool
Preflights mapping shape and resource ownership for Self::unmap.
The page table is not mutated between this preflight and commit. A
backend that can predict rejection from mapping shape or owned
resources must override this method. The commit can still fail because
of concurrent external state or resource pressure; in that case earlier
disjoint subranges may already be unmapped, while MemorySet retains
all area metadata and backend owners so the caller can quarantine and
retry the published mutation.
Sourcefn validate_protect(
&self,
_start: Self::Addr,
_size: usize,
_new_flags: Self::Flags,
_page_table: &Self::PageTable,
) -> bool
fn validate_protect( &self, _start: Self::Addr, _size: usize, _new_flags: Self::Flags, _page_table: &Self::PageTable, ) -> bool
Validate a protection update before applying it. This mirrors
Self::validate_unmap and is optional for legacy backends.
Sourcefn shrink_left(&mut self, _shrink_size: usize) -> bool
fn shrink_left(&mut self, _shrink_size: usize) -> bool
Shrinks the backend from the left by the given size.
The backend start address is increased by shrink_size.
Sourcefn shrink_right(&mut self, _shrink_size: usize) -> bool
fn shrink_right(&mut self, _shrink_size: usize) -> bool
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".