kernel::dynamic_binary_storage

Trait DynamicBinaryStore

Source
pub trait DynamicBinaryStore {
    // Required methods
    fn setup(&self, app_length: usize) -> Result<usize, ErrorCode>;
    fn write(
        &self,
        buffer: SubSliceMut<'static, u8>,
        offset: usize,
    ) -> Result<(), ErrorCode>;
    fn finalize(&self) -> Result<(), ErrorCode>;
    fn abort(&self) -> Result<(), ErrorCode>;
    fn set_storage_client(&self, client: &'static dyn DynamicBinaryStoreClient);
}
Expand description

This interface supports flashing binaries at runtime.

Required Methods§

Source

fn setup(&self, app_length: usize) -> Result<usize, ErrorCode>

Call to request flashing a new binary.

This informs the kernel we want to load a process, and the size of the entire process binary. The kernel will try to find a suitable location in flash to store said process.

Return value:

  • Ok(length): If there is a place to load the process, the function will return Ok() with the size of the region to store the process.
  • Err(ErrorCode): If there is nowhere to store the process a suitable ErrorCode will be returned.
Source

fn write( &self, buffer: SubSliceMut<'static, u8>, offset: usize, ) -> Result<(), ErrorCode>

Instruct the kernel to write data to the flash.

offset is where to start writing within the region allocated for the new process binary from the setup() call.

The caller must write the first 8 bytes of the process with valid header data. Writes must either be after the first 8 bytes or include the entire first 8 bytes.

Returns an error if the write is outside of the permitted region or is writing an invalid header.

Source

fn finalize(&self) -> Result<(), ErrorCode>

Signal to the kernel that the requesting process is done writing the new binary.

Source

fn abort(&self) -> Result<(), ErrorCode>

Call to abort the setup/writing process.

Source

fn set_storage_client(&self, client: &'static dyn DynamicBinaryStoreClient)

Sets a client for the SequentialDynamicBinaryStore Object

When the client operation is done, it calls the setup_done(), write_done() and abort_done() functions.

Implementors§

Source§

impl<'b, C: Chip + 'static, D: ProcessStandardDebug + 'static, F: NonvolatileStorage<'b>> DynamicBinaryStore for SequentialDynamicBinaryStorage<'_, 'b, C, D, F>

Storage interface exposed to the app_loader capsule