pub trait MemoryMappingOps: Send + Sync {
// Required method
fn get_mapping_info(
&self,
offset: usize,
length: usize,
) -> Result<(usize, usize, bool), &'static str>;
// Provided methods
fn get_mapping_info_with(
&self,
offset: usize,
length: usize,
_is_shared: bool,
) -> Result<(usize, usize, bool), &'static str> { ... }
fn on_mapped(
&self,
vaddr: usize,
paddr: usize,
length: usize,
offset: usize,
) { ... }
fn on_unmapped(&self, vaddr: usize, length: usize) { ... }
fn supports_mmap(&self) -> bool { ... }
fn mmap_owner_name(&self) -> String { ... }
fn resolve_fault(
&self,
access: &AccessKind,
map: &VirtualMemoryMap,
) -> Result<ResolveFaultResult, ResolveFaultError> { ... }
}Expand description
Memory mapping operations capability
This trait represents the ability to provide memory mapping information and receive notifications about mapping lifecycle events. Objects that support memory mapping (like files and devices) should implement this trait to provide mmap/munmap functionality.
Required Methods§
Sourcefn get_mapping_info(
&self,
offset: usize,
length: usize,
) -> Result<(usize, usize, bool), &'static str>
fn get_mapping_info( &self, offset: usize, length: usize, ) -> Result<(usize, usize, bool), &'static str>
Get mapping information for a region of the object
Returns the physical address, permissions, and sharing information for mapping a region of this object into virtual memory.
§Arguments
offset- Offset within the object to start mapping fromlength- Length of the mapping in bytes
§Returns
Result<(usize, usize, bool), &'static str>- (paddr, permissions, is_shared) on success
Provided Methods§
Sourcefn get_mapping_info_with(
&self,
offset: usize,
length: usize,
_is_shared: bool,
) -> Result<(usize, usize, bool), &'static str>
fn get_mapping_info_with( &self, offset: usize, length: usize, _is_shared: bool, ) -> Result<(usize, usize, bool), &'static str>
Get mapping information with sharing intent.
Default implementation ignores is_shared and delegates to
get_mapping_info for backward compatibility.
Sourcefn on_mapped(&self, vaddr: usize, paddr: usize, length: usize, offset: usize)
fn on_mapped(&self, vaddr: usize, paddr: usize, length: usize, offset: usize)
Notification that a mapping has been created
Called when a mapping of this object has been successfully created in the virtual memory manager. The object can use this to track its active mappings.
§Arguments
vaddr- Virtual address where the mapping was createdpaddr- Physical address that was mappedlength- Length of the mapping in bytesoffset- Offset within the object that was mapped
Sourcefn on_unmapped(&self, vaddr: usize, length: usize)
fn on_unmapped(&self, vaddr: usize, length: usize)
Notification that a mapping has been removed
Called when a mapping of this object has been removed from the virtual memory manager. The object should clean up any tracking of this mapping.
§Arguments
vaddr- Virtual address where the mapping was removedlength- Length of the mapping that was removed
Sourcefn supports_mmap(&self) -> bool
fn supports_mmap(&self) -> bool
Sourcefn mmap_owner_name(&self) -> String
fn mmap_owner_name(&self) -> String
Diagnostic helper: return a short owner name for logging
Default implementation returns a generic “object” string. Implementers (e.g. VfsFileObject) should override to provide more meaningful names such as file paths.