capsules_core::virtualizers

Module virtual_flash

Source
Expand description

Virtualize writing flash.

MuxFlash provides shared access to a flash interface from multiple clients in the kernel. For instance, a board may wish to expose the internal MCU flash for multiple uses, like allowing userland apps to write their own flash space, and to provide a “scratch space” as the end of flash for all apps to use. Each of these requires a capsule to support the operation, and must use a FlashUser instance to contain the per-user state for the virtualization.

§Usage


// Create the mux.
let mux_flash = static_init!(
    capsules_core::virtual_flash::MuxFlash<'static, sam4l::flashcalw::FLASHCALW>,
    capsules_core::virtual_flash::MuxFlash::new(&sam4l::flashcalw::FLASH_CONTROLLER));
hil::flash::HasClient::set_client(&sam4l::flashcalw::FLASH_CONTROLLER, mux_flash);

// Everything that then uses the virtualized flash must use one of these.
let virtual_flash = static_init!(
    capsules_core::virtual_flash::FlashUser<'static, sam4l::flashcalw::FLASHCALW>,
    capsules_core::virtual_flash::FlashUser::new(mux_flash));

Structs§

  • Keeps state for each flash user.
  • Handle keeping a list of active users of flash hardware and serialize their requests.