Module capsules_core::virtualizers::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§
- Keep state for each flash user. All uses of the virtualized flash interface need to create one of these to be a user of the flash. The
new()
function handles most of the work, a user only has to pass in a reference to the MuxFlash object. - Handle keeping a list of active users of flash hardware and serialize their requests. After each completed request the list is checked to see if there is another flash user with an outstanding read, write, or erase request.