axdevice_base
Basic device abstraction library for AxVisor virtual device subsystem, designed for no_std environments.
Overview
axdevice_base provides core traits, structures, and type definitions for virtual device development, including:
BaseDeviceOpstrait: Common interface that all virtual devices must implement.EmulatedDeviceConfig: Device initialization and configuration structure.- Device type enumeration
EmuDeviceType(re-exported fromaxvmconfigcrate). - Trait aliases for various device types:
BaseMmioDeviceOps: For MMIO (Memory-Mapped I/O) devices.BaseSysRegDeviceOps: For system register devices (ARM).BasePortDeviceOps: For port I/O devices (x86).
map_device_of_type: Helper function for runtime device type checking and casting.
Features
no_stdcompatible: Designed for bare-metal and hypervisor environments.- Multi-architecture support: x86_64, AArch64, RISC-V64.
- Type-safe addressing: Different address range types for different device access methods.
- Serialization support: Device configuration can be serialized/deserialized via
serde.
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Implementing a Custom Device
use ;
use ;
use AxResult;
Device Configuration
use EmulatedDeviceConfig;
let config = EmulatedDeviceConfig ;
Type Checking with map_device_of_type
use ;
use Arc;
Supported Platforms
| Architecture | MMIO Devices | Port I/O Devices | System Register Devices |
|---|---|---|---|
| x86_64 | ✓ | ✓ | - |
| AArch64 | ✓ | - | ✓ |
| RISC-V64 | ✓ | - | - |
Documentation
For detailed API documentation, visit docs.rs/axdevice_base.
Contributing
Issues and PRs are welcome! Please follow the ArceOS-hypervisor project guidelines.
License
Axdevice_base is licensed under the Apache License, Version 2.0. See the LICENSE file for details.