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) -> StateBank
pub fn new(logical_size: u64) -> StateBank
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.Source§impl ResourceBackend for StateBank
impl ResourceBackend for StateBank
fn read32(&mut self, offset: u64) -> Result<u32, BackendError>
fn write32(&mut self, offset: u64, value: u32) -> Result<(), BackendError>
fn barrier(&mut self)
fn gpio_read(&mut self) -> Result<bool, BackendError>
fn gpio_write(&mut self, _value: bool) -> Result<(), BackendError>
fn i2c_transfer( &mut self, _write_data: &[u8], _read_length: usize, ) -> Result<Vec<u8>, BackendError>
fn spi_transmit(&mut self, _tx_data: &[u8]) -> Result<Vec<u8>, BackendError>
fn clock_enable(&mut self) -> Result<(), BackendError>
fn clock_disable(&mut self) -> Result<(), BackendError>
fn clock_is_enabled(&mut self) -> Result<bool, BackendError>
fn clock_set_rate(&mut self, _hz: u64) -> Result<(), BackendError>
fn clock_query_rate(&mut self, _hz_in: u64) -> Result<u64, BackendError>
fn clock_get_rate(&mut self) -> Result<u64, BackendError>
fn reset_assert(&mut self) -> Result<(), BackendError>
fn reset_deassert(&mut self) -> Result<(), BackendError>
fn reset_toggle(&mut self) -> Result<(), BackendError>
fn reset_status(&mut self) -> Result<bool, BackendError>
fn serial_read(&mut self) -> Result<Vec<u8>, BackendError>
fn serial_write(&mut self, _data: &[u8]) -> Result<(), BackendError>
Auto Trait Implementations§
impl !RefUnwindSafe for StateBank
impl !UnwindSafe for StateBank
impl Freeze for StateBank
impl Send for StateBank
impl Sync for StateBank
impl Unpin for StateBank
impl UnsafeUnpin for StateBank
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more