Enum solana_rbpf::memory_region::MemoryMapping
source · pub enum MemoryMapping<'a> {
Identity,
Aligned(AlignedMemoryMapping<'a>),
Unaligned(UnalignedMemoryMapping<'a>),
}
Expand description
Maps virtual memory to host memory.
Variants§
Identity
Used when address translation is disabled
Aligned(AlignedMemoryMapping<'a>)
Aligned memory mapping which uses the upper half of an address to identify the underlying memory region.
Unaligned(UnalignedMemoryMapping<'a>)
Memory mapping that allows mapping unaligned memory regions.
Implementations§
source§impl<'a> MemoryMapping<'a>
impl<'a> MemoryMapping<'a>
sourcepub fn new(
regions: Vec<MemoryRegion>,
config: &'a Config,
sbpf_version: &'a SBPFVersion
) -> Result<Self, EbpfError>
pub fn new( regions: Vec<MemoryRegion>, config: &'a Config, sbpf_version: &'a SBPFVersion ) -> Result<Self, EbpfError>
Creates a new memory mapping.
Uses aligned or unaligned memory mapping depending on the value of
config.aligned_memory_mapping=true
.
sourcepub fn new_with_cow(
regions: Vec<MemoryRegion>,
cow_cb: MemoryCowCallback,
config: &'a Config,
sbpf_version: &'a SBPFVersion
) -> Result<Self, EbpfError>
pub fn new_with_cow( regions: Vec<MemoryRegion>, cow_cb: MemoryCowCallback, config: &'a Config, sbpf_version: &'a SBPFVersion ) -> Result<Self, EbpfError>
Creates a new memory mapping.
Uses aligned or unaligned memory mapping depending on the value of
config.aligned_memory_mapping=true
. cow_cb
is used to copy CoW memory regions.
sourcepub fn map(
&self,
access_type: AccessType,
vm_addr: u64,
len: u64
) -> ProgramResult
pub fn map( &self, access_type: AccessType, vm_addr: u64, len: u64 ) -> ProgramResult
Map virtual memory to host memory.
sourcepub fn load<T: Pod + Into<u64>>(&self, vm_addr: u64) -> ProgramResult
pub fn load<T: Pod + Into<u64>>(&self, vm_addr: u64) -> ProgramResult
Loads size_of::<T>()
bytes from the given address.
Works across memory region boundaries.
sourcepub fn store<T: Pod>(&self, value: T, vm_addr: u64) -> ProgramResult
pub fn store<T: Pod>(&self, value: T, vm_addr: u64) -> ProgramResult
Store value
at the given address.
Works across memory region boundaries if len
does not fit within a single region.
sourcepub fn region(
&self,
access_type: AccessType,
vm_addr: u64
) -> Result<&MemoryRegion, EbpfError>
pub fn region( &self, access_type: AccessType, vm_addr: u64 ) -> Result<&MemoryRegion, EbpfError>
Returns the MemoryRegion
corresponding to the given address.
sourcepub fn get_regions(&self) -> &[MemoryRegion]
pub fn get_regions(&self) -> &[MemoryRegion]
Returns the MemoryRegion
s in this mapping.
sourcepub fn replace_region(
&mut self,
index: usize,
region: MemoryRegion
) -> Result<(), EbpfError>
pub fn replace_region( &mut self, index: usize, region: MemoryRegion ) -> Result<(), EbpfError>
Replaces the MemoryRegion
at the given index