Skip to main content

Module inject

Module inject 

Source
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§

AfterStore
A handler wrapper that executes a callback after every store operation.
BaseRegistry
A VMO handler registry that retrieves registered handlers by VMO KOID.
DispatchBuilder
Builder for constructing a [Dispatch] handler.
DispatchNode
A reference-counted MMIO handler node used in dispatch trees.
DispatchNodeHandler
A wrapper around DispatchNode that implements DispatchHandler.
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.
RangeOverride
A handler that delegates matching ranges to a MaybeVmoMemoryHandler implementation and falls back to a parent handler for unmatched ranges.
RegisterRange
A helper struct for producing Range<usize> from a Register definition.
ScopedRegistry
A helper to add VMOs to a global registry that removes all installed VMOs on drop.
VmoMemory
A wrapper around an UnsafeMmio underlying storage that permits injecting behavior on reads and writes to the underlying VMO.
VmoOpHelper
Helper providing contextual information and operations for an MMIO access.
WriteOneToClear
A handler implementation that fakes write-1-to-clear registers of width T.

Traits§

DispatchHandler
A trait marking a VmoMemoryHandler as suitable for use within [Dispatch].
GenericVmoMemoryHandler
A generic handler for MMIO operations parameterized by operand type.
MaybeVmoMemoryHandler
A trait abstracting optional handling of a VMO range.
RegistryHandler
A trait marking a VmoMemoryHandler as suitable for use within a Registry.
VmoMemoryHandler
Handles MMIO read and write operations on a VMO.
VmoMemoryWrapper
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.
StrictRegistry
A registry that panics when encountering an unregistered VMO.