pub struct BasicMemory<const BASE_ADDR: u64, const SIZE: usize> { /* private fields */ }Expand description
Basic memory implementation.
Flat structure, no rwx protections, no alignment requirements. It uses stack, so for larger allocation it’ll need to be boxed (zero-initialized is fine) or a custom implementation to be used.
This implementation is intentionally basic and correct, but not the most performant. It is possible to have a more efficient implementation that skips certain checks by placing additional constraints on the program.
This works for simpler cases, while a more sophisticated implementation might prevent certain memory from being writable, supporting actual virtual memory with dynamically allocated memory pages, etc.
Implementations§
Source§impl<const BASE_ADDR: u64, const SIZE: usize> BasicMemory<BASE_ADDR, SIZE>
impl<const BASE_ADDR: u64, const SIZE: usize> BasicMemory<BASE_ADDR, SIZE>
Sourcepub fn get_mut_bytes(
&mut self,
address: u64,
size: usize,
) -> Result<&mut [u8], VirtualMemoryError>
pub fn get_mut_bytes( &mut self, address: u64, size: usize, ) -> Result<&mut [u8], VirtualMemoryError>
Get a mutable slice of memory.
This is primarily useful for setting up the program and should not be used beyond that.
Trait Implementations§
Source§impl<const BASE_ADDR: u64, const SIZE: usize> Clone for BasicMemory<BASE_ADDR, SIZE>
impl<const BASE_ADDR: u64, const SIZE: usize> Clone for BasicMemory<BASE_ADDR, SIZE>
Source§fn clone(&self) -> BasicMemory<BASE_ADDR, SIZE>
fn clone(&self) -> BasicMemory<BASE_ADDR, SIZE>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more