pub struct LinearMemoryBus { /* private fields */ }Expand description
Fast linear-memory bus for RAM-backed emulators and WebAssembly builds.
This keeps all normal memory accesses inside Rust/wasm linear memory instead of crossing into a host callback for each byte/word/long. Addresses wrap within the backing buffer, with a fast mask path for power-of-two sizes.
Implementations§
Source§impl LinearMemoryBus
impl LinearMemoryBus
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether the backing buffer is empty.
A constructed LinearMemoryBus is never empty because
LinearMemoryBus::from_vec rejects an empty buffer.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Mutably borrow the complete backing buffer.
Taking a mutable slice advances the instruction-memory version conservatively because the caller may change executable bytes.
Sourcepub fn load(&mut self, address: u32, data: &[u8])
pub fn load(&mut self, address: u32, data: &[u8])
Copy bytes into memory at address, wrapping at the end of the backing buffer.
Sourcepub fn write_word_at(&mut self, address: u32, value: u16)
pub fn write_word_at(&mut self, address: u32, value: u16)
Write one big-endian word, wrapping within the backing buffer.
Sourcepub fn write_long_at(&mut self, address: u32, value: u32)
pub fn write_long_at(&mut self, address: u32, value: u32)
Write one big-endian longword, wrapping within the backing buffer.
Trait Implementations§
Source§impl AddressBus for LinearMemoryBus
impl AddressBus for LinearMemoryBus
Source§fn fast_mem(&mut self) -> Option<FastMem>
fn fast_mem(&mut self) -> Option<FastMem>
The whole backing buffer is side-effect-free RAM, so expose it as a
fastmem window starting at guest address 0. Accesses beyond len
(which the bus methods wrap) simply fall back to the bus.
Source§fn read_long(&mut self, address: u32) -> u32
fn read_long(&mut self, address: u32) -> u32
address.Source§fn write_byte(&mut self, address: u32, value: u8)
fn write_byte(&mut self, address: u32, value: u8)
address.Source§fn write_word(&mut self, address: u32, value: u16)
fn write_word(&mut self, address: u32, value: u16)
address.Source§fn write_long(&mut self, address: u32, value: u32)
fn write_long(&mut self, address: u32, value: u32)
address.Source§fn read_immediate_word(&mut self, address: u32) -> u16
fn read_immediate_word(&mut self, address: u32) -> u16
Source§fn read_immediate_long(&mut self, address: u32) -> u32
fn read_immediate_long(&mut self, address: u32) -> u32
Source§fn sync(&mut self, _cpu_clocks: u32)
fn sync(&mut self, _cpu_clocks: u32)
Source§fn try_read_byte(&mut self, address: u32) -> Result<u8, BusFault>
fn try_read_byte(&mut self, address: u32) -> Result<u8, BusFault>
Source§fn try_read_word(&mut self, address: u32) -> Result<u16, BusFault>
fn try_read_word(&mut self, address: u32) -> Result<u16, BusFault>
Source§fn try_read_long(&mut self, address: u32) -> Result<u32, BusFault>
fn try_read_long(&mut self, address: u32) -> Result<u32, BusFault>
Source§fn try_write_byte(&mut self, address: u32, value: u8) -> Result<(), BusFault>
fn try_write_byte(&mut self, address: u32, value: u8) -> Result<(), BusFault>
Source§fn try_write_word(&mut self, address: u32, value: u16) -> Result<(), BusFault>
fn try_write_word(&mut self, address: u32, value: u16) -> Result<(), BusFault>
Source§fn try_write_long(&mut self, address: u32, value: u32) -> Result<(), BusFault>
fn try_write_long(&mut self, address: u32, value: u32) -> Result<(), BusFault>
Source§fn read_three_bytes(&mut self, address: u32) -> u32
fn read_three_bytes(&mut self, address: u32) -> u32
address, returned in the
low 24 bits. Read moreSource§fn write_three_bytes(&mut self, address: u32, value: u32)
fn write_three_bytes(&mut self, address: u32, value: u32)
value as a big-endian three-byte operand. Read moreSource§fn try_read_three_bytes(&mut self, address: u32) -> Result<u32, BusFault>
fn try_read_three_bytes(&mut self, address: u32) -> Result<u32, BusFault>
AddressBus::read_three_bytes) for the
billing to take effect. Read moreSource§fn try_write_three_bytes(
&mut self,
address: u32,
value: u32,
) -> Result<(), BusFault>
fn try_write_three_bytes( &mut self, address: u32, value: u32, ) -> Result<(), BusFault>
Source§fn try_read_immediate_word(&mut self, address: u32) -> Result<u16, BusFault>
fn try_read_immediate_word(&mut self, address: u32) -> Result<u16, BusFault>
Source§fn try_read_immediate_long(&mut self, address: u32) -> Result<u32, BusFault>
fn try_read_immediate_long(&mut self, address: u32) -> Result<u32, BusFault>
Source§fn last_fetch_was_cached(&self) -> bool
fn last_fetch_was_cached(&self) -> bool
Source§fn begin_instruction_fetches(&mut self)
fn begin_instruction_fetches(&mut self)
Source§fn instruction_fetches_were_cached(&self) -> bool
fn instruction_fetches_were_cached(&self) -> bool
begin_instruction_fetches hit the instruction cache. Functional test
buses without a cache model default to the most recent fetch result.Source§fn take_boundary_request(&mut self) -> bool
fn take_boundary_request(&mut self) -> bool
Source§fn interrupt_acknowledge(&mut self, _level: u8) -> u32
fn interrupt_acknowledge(&mut self, _level: u8) -> u32
level. Read moreSource§fn ipl_hold_sample(&mut self)
fn ipl_hold_sample(&mut self)
Source§fn ipl_release_sample(&mut self)
fn ipl_release_sample(&mut self)
ipl_hold_sample poll-point hold before the instruction
boundary consumes it. Called on exception dispatch: the vector jump’s
handler-entry prefetch is a fresh poll point on real silicon (Moira
jumpToVector polls during the final refill read), so a hold placed
earlier in the faulted instruction must not survive into the handler.Source§fn reset_devices(&mut self)
fn reset_devices(&mut self)
Source§impl Clone for LinearMemoryBus
impl Clone for LinearMemoryBus
Source§fn clone(&self) -> LinearMemoryBus
fn clone(&self) -> LinearMemoryBus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more