Skip to main content

EmulatorMemory

Trait EmulatorMemory 

Source
pub trait EmulatorMemory: DomainMemory<V = SizedValue> {
    // Required methods
    fn configure_spaces(&mut self, ctx: &Context<'_>);
    fn read_bytes(
        &self,
        space: MemorySpaceId,
        addr: u64,
        size: usize,
    ) -> Result<Vec<u8>, EmulatorErrorKind>;
    fn write_bytes(
        &mut self,
        space: MemorySpaceId,
        addr: u64,
        bytes: &[u8],
    ) -> Result<(), EmulatorErrorKind>;
}
Expand description

The byte-addressable memory an emulator run needs, over and above the value-domain reads and writes of DomainMemory.

DomainMemory speaks in whole values of a domain, which is all the interpreter itself needs. A harness needs more: to seed a fixture, dump a region, or poke a single register lane, it has to talk in bytes. Keeping those on a separate trait is what lets StandaloneEmulator be generic over its memory, so a richer backend — one with mapped pages and permissions — can be substituted without the interpreter knowing.

Required Methods§

Source

fn configure_spaces(&mut self, ctx: &Context<'_>)

Prepares per-space bookkeeping for ctx. Called before any access, and cheap to call repeatedly: spaces are append-only, so an implementation can skip the work when nothing has been added.

Source

fn read_bytes( &self, space: MemorySpaceId, addr: u64, size: usize, ) -> Result<Vec<u8>, EmulatorErrorKind>

Reads size raw bytes, without the value-domain’s width handling.

Source

fn write_bytes( &mut self, space: MemorySpaceId, addr: u64, bytes: &[u8], ) -> Result<(), EmulatorErrorKind>

Writes raw bytes, creating the space if it does not exist yet.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§