MemoryMappingOps

Trait MemoryMappingOps 

Source
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§

Source

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 from
  • length - Length of the mapping in bytes
§Returns
  • Result<(usize, usize, bool), &'static str> - (paddr, permissions, is_shared) on success

Provided Methods§

Source

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.

Source

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 created
  • paddr - Physical address that was mapped
  • length - Length of the mapping in bytes
  • offset - Offset within the object that was mapped
Source

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 removed
  • length - Length of the mapping that was removed
Source

fn supports_mmap(&self) -> bool

Check if memory mapping is supported

§Returns
  • bool - true if this object supports memory mapping
Source

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.

Source

fn resolve_fault( &self, access: &AccessKind, map: &VirtualMemoryMap, ) -> Result<ResolveFaultResult, ResolveFaultError>

Implementors§