Skip to main content

Memory

Struct Memory 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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).

Source

pub fn load_rom(&mut self, data: &[u8])

Source

pub fn rom_read8(&self, offset: u32) -> u8

Source

pub fn rom_read16(&self, offset: u32) -> u16

Source

pub fn rom_read32(&self, offset: u32) -> u32

Source

pub fn sram_read8(&self, offset: u32) -> u8

Source

pub fn sram_read16(&self, offset: u32) -> u16

Source

pub fn sram_read32(&self, offset: u32) -> u32

Source

pub fn sram_write8(&mut self, offset: u32, val: u8)

Source

pub fn sram_write16(&mut self, offset: u32, val: u16)

Source

pub fn sram_write32(&mut self, offset: u32, val: u32)

Source

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_sizes path — 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.
Source

pub fn xip_read8(&self, offset: u32) -> u8

Source

pub fn xip_read16(&self, offset: u32) -> u16

Source

pub fn xip_read32(&self, offset: u32) -> u32

Source

pub fn peek8(&self, addr: u32) -> u8

Source

pub fn poke8(&mut self, addr: u32, val: u8)

Source

pub fn peek32(&self, addr: u32) -> u32

Source

pub fn poke32(&mut self, addr: u32, val: u32)

Source

pub fn into_parts(self) -> (Vec<u8>, Vec<u8>, Vec<u8>)

Consume the backing store, yielding (rom, sram, xip) Vec triples. Used by the threading runtime (rp2350_emu::threaded) to seed a SharedMemory from an existing Emulator’s Bus::memory without bulk-reading every byte through the scalar accessors.

Trait Implementations§

Source§

impl Default for Memory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more