RDrive - Rust Dynamic Driver Framework
A dynamic driver management framework for embedded systems written in Rust.
Architecture Overview
rdif-* Interface Crates
Hardware abstraction interface crates with Any for dynamic dispatch:
rdif-base: Core driver traits and error typesrdif-intc: Interrupt controller interfacerdif-clk: Clock management interfacerdif-serial: Serial communication interfacerdif-timer: Timer/counter interfacerdif-block: Block device interfacerdif-power: Power management interfacerdif-systick: System tick interfacerdif-net: Network interface
rdrive-macros
Procedural macros to simplify driver registration and module generation.
rdrive Core
The main driver container responsible for:
- Driver registration and discovery
- Device probing and initialization
- Device lifecycle management
- Type-safe device access
Device Ownership Model
Devices are managed through a long-term borrowing model using Device<T> wrappers. Unlike Mutex<T>, when a task borrows a device, it gains exclusive ownership. Other tasks attempting to borrow will receive an error with the owner's task ID, enabling forced task termination if needed.
Key features:
- Lock-free operations once ownership is acquired
- Weak pointer support for interrupt handlers
- Cloning
Device<T>creates weak references for fast indexing
Driver Registration
Drivers can be registered from different crates using the module_driver! macro:
use ;
module_driver!
System Integration
1. Linker Script Configuration
Add the following section to your linker script:
.driver.register : ALIGN(4K) {
_sdriver = .;
*(.driver.register .driver.register.*)
_edriver = .;
. = ALIGN(4K);
}
2. Driver Registration Discovery
use DriverRegisterSlice;
3. System Initialization
use ;
use NonNull;
4. Device Access
use ;
Supported Probe Methods
- Device Tree (FDT): Automatic device discovery from device tree
- Static Configuration: Manual device registration (planned)
Examples
See the examples/ directory for complete usage examples:
examples/enumerate/: Basic driver enumeration and device tree parsing
References
For complete integration examples, see: