pub struct Memory { /* private fields */ }Expand description
Unified memory backing stores. Owns the actual byte arrays for ROM, SRAM, and flash (XIP). No bus fabric or timing — just raw storage.
Implementations§
Source§impl Memory
impl Memory
pub fn new() -> Self
Sourcepub fn with_sizes(rom_size: usize, sram_size: usize) -> Self
pub fn with_sizes(rom_size: usize, sram_size: usize) -> Self
Construct a Memory with chip-specific ROM and SRAM sizes.
Used by rp2040_emu (16 KB ROM, 264 KB SRAM) and any future chip
crate that differs from the RP2350 defaults baked into new().
XIP starts empty; populate via load_flash.
Sourcepub fn with_flash(rom_size: usize, sram_size: usize, flash_size: usize) -> Self
pub fn with_flash(rom_size: usize, sram_size: usize, flash_size: usize) -> Self
Construct a Memory with chip-specific ROM, SRAM, and a fixed-size
flash window. Used by rp2040_emu for its 2 MB XIP window: the
bus decoder maps a fixed address range, so the flash buffer must
cover the whole window regardless of image size.
Flash bytes are zero-initialised; populate via Self::load_flash,
which clamps to flash_size and zeroes any remaining tail.
Sourcepub fn flash_size(&self) -> usize
pub fn flash_size(&self) -> usize
Current flash (XIP) buffer size in bytes. Zero when constructed
via new() / with_sizes() and load_flash has not been called
yet (rp2350_emu dynamic-resize path).
pub fn load_rom(&mut self, data: &[u8])
pub fn rom_read8(&self, offset: u32) -> u8
pub fn rom_read16(&self, offset: u32) -> u16
pub fn rom_read32(&self, offset: u32) -> u32
pub fn sram_read8(&self, offset: u32) -> u8
pub fn sram_read16(&self, offset: u32) -> u16
pub fn sram_read32(&self, offset: u32) -> u32
pub fn sram_write8(&mut self, offset: u32, val: u8)
pub fn sram_write16(&mut self, offset: u32, val: u16)
pub fn sram_write32(&mut self, offset: u32, val: u32)
Sourcepub fn load_flash(&mut self, data: &[u8])
pub fn load_flash(&mut self, data: &[u8])
Copy data into the flash buffer starting at offset 0.
- If the buffer was pre-sized via
Self::with_flash, the copy clamps at the buffer length and any previously-loaded tail is zeroed so a re-load doesn’t leak stale bytes past the new image. - Otherwise (default /
with_sizespath — rp2350_emu) the buffer is resized to match the new data. This preserves the pre-PicoGUS behaviour where callers treat XIP as a dynamically-sized image.
pub fn xip_read8(&self, offset: u32) -> u8
pub fn xip_read16(&self, offset: u32) -> u16
pub fn xip_read32(&self, offset: u32) -> u32
pub fn peek8(&self, addr: u32) -> u8
pub fn poke8(&mut self, addr: u32, val: u8)
pub fn peek32(&self, addr: u32) -> u32
pub fn poke32(&mut self, addr: u32, val: u32)
Sourcepub fn into_parts(self) -> (Vec<u8>, Vec<u8>, Vec<u8>)
pub fn into_parts(self) -> (Vec<u8>, Vec<u8>, Vec<u8>)
Consume the backing store, yielding (rom, sram, xip) Vecrp2350_emu::threaded) to
seed a SharedMemory from an existing Emulator’s Bus::memory
without bulk-reading every byte through the scalar accessors.