Expand description
MMIO operation injection support for intercepting MMIO access.
This module provides a framework for injecting side-effects on VMO access.
§Usage
VmoMemory is the main entry type for injection in regular usages of the
mmio crate. It replaces mmio::vmo::VmoMemory as the main implementer
of UnsafeMmio backing the operations for an MmioRegion.
See the documentation of VmoMemory for more details.
§Conditional Compilation
For conditional compilation, the pattern to use is:
#[cfg(test)]
mod memory {
// Wrapper is a type implementing `VmoMemoryWrapper`.
pub type VmoMemory = fake_mmio::inject::VmoMemory<Wrapper>;
}
#[cfg(not(test))]
mod memory {
pub type VmoMemory = mmio::vmo::VmoMemory;
}§Type parameters
VmoMemory implements VmoMapper like mmio::vmo::VmoMemory so it
can also be used in type parameters instead.
pub fn create_driver<M: mmio::vmo::VmoMapper>() -> MyDriver<M> { ... };
#[cfg(test)]
fn test_fn() {
let driver = create_driver::<fake_mmio::injec::VmoMemory<Wrapper>>();
}
fn load_driver() {
let driver = create_driver::<mmio::vmo::VmoMemory>();
}Structs§
- After
Store - A handler wrapper that executes a callback after every store operation.
- Base
Registry - A VMO handler registry that retrieves registered handlers by VMO KOID.
- Dispatch
Builder - Builder for constructing a [
Dispatch] handler. - Dispatch
Node - A reference-counted MMIO handler node used in dispatch trees.
- Dispatch
Node Handler - A wrapper around
DispatchNodethat implementsDispatchHandler. - Offset
- An MMIO handler that applies an offset to operations before dispatching the call to the next handler.
- OpDispatcher
- Dispatches MMIO operations to specific handlers based on memory range.
- Passthrough
- An MMIO handler that directly passes loads and stores to the VMO memory.
- Range
Override - A handler that delegates matching ranges to a
MaybeVmoMemoryHandlerimplementation and falls back to a parent handler for unmatched ranges. - Register
Range - A helper struct for producing
Range<usize>from aRegisterdefinition. - Scoped
Registry - A helper to add VMOs to a global registry that removes all installed VMOs on drop.
- VmoMemory
- A wrapper around an
UnsafeMmiounderlying storage that permits injecting behavior on reads and writes to the underlying VMO. - VmoOp
Helper - Helper providing contextual information and operations for an MMIO access.
- Write
OneTo Clear - A handler implementation that fakes write-1-to-clear registers of width
T.
Traits§
- Dispatch
Handler - A trait marking a
VmoMemoryHandleras suitable for use within [Dispatch]. - Generic
VmoMemory Handler - A generic handler for MMIO operations parameterized by operand type.
- Maybe
VmoMemory Handler - A trait abstracting optional handling of a VMO range.
- Registry
Handler - A trait marking a
VmoMemoryHandleras suitable for use within aRegistry. - VmoMemory
Handler - Handles MMIO read and write operations on a VMO.
- VmoMemory
Wrapper - A factory trait for constructing a handler associated with a given VMO.
Type Aliases§
- Registry
- A registry that falls back to passthrough behavior for unregistered VMOs.
- Strict
Registry - A registry that panics when encountering an unregistered VMO.