Expand description
This provides kernel and userspace access to nonvolatile memory.
This is an initial implementation that does not provide safety for individual userland applications. Each application has full access to the entire memory space that has been provided to userland. Future revisions should update this to limit applications to only their allocated regions.
However, the kernel accessible memory does not have to be the same range as the userspace accessible address space. The kernel memory can overlap if desired, or can be a completely separate range.
Here is a diagram of the expected stack with this capsule: Boxes are components and between the boxes are the traits that are the interfaces between components. This capsule provides both a kernel and userspace interface.
+--------------------------------------------+ +--------------+
| | | |
| kernel | | userspace |
| | | |
+--------------------------------------------+ +--------------+
hil::nonvolatile_storage::NonvolatileStorage kernel::Driver
+-----------------------------------------------------------------+
| |
| capsules::nonvolatile_storage_driver::NonvolatileStorage (this) |
| |
+-----------------------------------------------------------------+
hil::nonvolatile_storage::NonvolatileStorage
+-----------------------------------------------------------------+
| |
| Physical nonvolatile storage driver |
| |
+-----------------------------------------------------------------+
Example instantiation:
let nonvolatile_storage = static_init!(
capsules::nonvolatile_storage_driver::NonvolatileStorage<'static>,
capsules::nonvolatile_storage_driver::NonvolatileStorage::new(
fm25cl, // The underlying storage driver.
board_kernel.create_grant(&grant_cap), // Storage for app-specific state.
3000, // The byte start address for the userspace
// accessible memory region.
2000, // The length of the userspace region.
0, // The byte start address of the region
// that is accessible by the kernel.
3000, // The length of the kernel region.
&mut capsules::nonvolatile_storage_driver::BUFFER));
hil::nonvolatile_storage::NonvolatileStorage::set_client(fm25cl, nonvolatile_storage);