pub struct StateBank { /* private fields */ }Expand description
Word-addressed software state bank exposing observable driver state slots, policy-gated runtime knobs, read probes, and diagnostic triggers.
Implementations§
Source§impl StateBank
impl StateBank
Sourcepub fn new(logical_size: u64) -> Self
pub fn new(logical_size: u64) -> Self
Creates an empty StateBank with the given byte logical_size.
Sourcepub fn logical_size(&self) -> u64
pub fn logical_size(&self) -> u64
Returns the logical byte size of the state bank.
Sourcepub fn writable_offsets(&self) -> &[u64]
pub fn writable_offsets(&self) -> &[u64]
Returns the 4-byte aligned offsets that are configured as writable knobs or triggers.
Sourcepub fn ceiling(&self) -> ResourceCeiling
pub fn ceiling(&self) -> ResourceCeiling
Builds the default ResourceCeiling for this state bank, allowing
32-bit reads and polls within logical_size and permitting writes only
on offsets registered via Self::define_knob or Self::define_trigger.
Sourcepub fn define_state_slot(
&mut self,
offset: u64,
initial: u32,
) -> StateSlotHandle
pub fn define_state_slot( &mut self, offset: u64, initial: u32, ) -> StateSlotHandle
Defines a read-only 32-bit observable state slot at a 4-byte aligned
offset and returns a StateSlotHandle for the driver to update.
Sourcepub fn define_knob(&mut self, offset: u64, initial: u32) -> StateSlotHandle
pub fn define_knob(&mut self, offset: u64, initial: u32) -> StateSlotHandle
Defines a policy-gated writable 32-bit runtime knob at a 4-byte aligned
offset and returns a StateSlotHandle for the driver to read.
Sourcepub fn define_read_probe(
&mut self,
offset: u64,
probe: impl Fn() -> Result<u32, BackendError> + Send + Sync + 'static,
)
pub fn define_read_probe( &mut self, offset: u64, probe: impl Fn() -> Result<u32, BackendError> + Send + Sync + 'static, )
Defines a read-only on-demand probe callback at a 4-byte aligned offset.
Sourcepub fn define_trigger(
&mut self,
offset: u64,
trigger: impl Fn(u32) -> Result<u32, BackendError> + Send + Sync + 'static,
)
pub fn define_trigger( &mut self, offset: u64, trigger: impl Fn(u32) -> Result<u32, BackendError> + Send + Sync + 'static, )
Defines a write-triggered diagnostic action at a 4-byte aligned offset.
Writing value to offset invokes trigger(value) and stores the
returned u32 status into the entry’s last_result slot so readback
or subsequent read32/poll32 calls observe the trigger outcome.
Trait Implementations§
Source§impl MmioBackend for StateBank
impl MmioBackend for StateBank
Source§fn read32(&mut self, offset: u64) -> Result<u32, BackendError>
fn read32(&mut self, offset: u64) -> Result<u32, BackendError>
offset bytes from the start
of the logical resource.