Struct solana_rbpf::memory_region::MemoryRegion
source · #[repr(C, align(32))]pub struct MemoryRegion {
pub host_addr: Cell<u64>,
pub vm_addr: u64,
pub vm_addr_end: u64,
pub len: u64,
pub vm_gap_shift: u8,
pub state: Cell<MemoryState>,
}
Expand description
Memory region for bounds checking and address translation
Fields§
§host_addr: Cell<u64>
start host address
vm_addr: u64
start virtual address
vm_addr_end: u64
end virtual address
len: u64
Length in bytes
vm_gap_shift: u8
Size of regular gaps as bit shift (63 means this region is continuous)
state: Cell<MemoryState>
Whether the region is readonly, writable or must be copied before writing
Implementations§
source§impl MemoryRegion
impl MemoryRegion
sourcepub fn new_for_testing(
slice: &[u8],
vm_addr: u64,
vm_gap_size: u64,
state: MemoryState
) -> Self
pub fn new_for_testing( slice: &[u8], vm_addr: u64, vm_gap_size: u64, state: MemoryState ) -> Self
Only to be used in tests and benches
sourcepub fn new_readonly(slice: &[u8], vm_addr: u64) -> Self
pub fn new_readonly(slice: &[u8], vm_addr: u64) -> Self
Creates a new readonly MemoryRegion from a slice
sourcepub fn new_writable(slice: &mut [u8], vm_addr: u64) -> Self
pub fn new_writable(slice: &mut [u8], vm_addr: u64) -> Self
Creates a new writable MemoryRegion from a mutable slice
sourcepub fn new_cow(slice: &[u8], vm_addr: u64, cow_id: u64) -> Self
pub fn new_cow(slice: &[u8], vm_addr: u64, cow_id: u64) -> Self
Creates a new copy on write MemoryRegion.
The region is made writable
sourcepub fn new_writable_gapped(
slice: &mut [u8],
vm_addr: u64,
vm_gap_size: u64
) -> Self
pub fn new_writable_gapped( slice: &mut [u8], vm_addr: u64, vm_gap_size: u64 ) -> Self
Creates a new writable gapped MemoryRegion from a mutable slice
sourcepub fn vm_to_host(&self, vm_addr: u64, len: u64) -> ProgramResult
pub fn vm_to_host(&self, vm_addr: u64, len: u64) -> ProgramResult
Convert a virtual machine address into a host address
Trait Implementations§
source§impl Debug for MemoryRegion
impl Debug for MemoryRegion
source§impl Default for MemoryRegion
impl Default for MemoryRegion
source§fn default() -> MemoryRegion
fn default() -> MemoryRegion
Returns the “default value” for a type. Read more
source§impl Ord for MemoryRegion
impl Ord for MemoryRegion
source§impl PartialEq for MemoryRegion
impl PartialEq for MemoryRegion
source§fn eq(&self, other: &MemoryRegion) -> bool
fn eq(&self, other: &MemoryRegion) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for MemoryRegion
impl PartialOrd for MemoryRegion
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for MemoryRegion
impl StructuralPartialEq for MemoryRegion
Auto Trait Implementations§
impl !Freeze for MemoryRegion
impl !RefUnwindSafe for MemoryRegion
impl Send for MemoryRegion
impl !Sync for MemoryRegion
impl Unpin for MemoryRegion
impl UnwindSafe for MemoryRegion
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more