7 releases

Uses new Rust 2024

new 0.2.2-preview.2 Feb 8, 2026
0.2.2-preview.1 Feb 6, 2026
0.2.2-hv.5 Feb 12, 2026
0.2.2-hv.4 Feb 11, 2026
0.2.2-hv.3 Feb 9, 2026

#699 in Operating systems


Used in 24 crates (10 directly)

GPL-3.0-or-later OR Apache-2… and maybe GPL-2.0-only

93KB
2K SLoC

ArceOS device drivers.

Usage

All detected devices are composed into a large struct AllDevices and returned by the init_drivers function. The upperlayer subsystems (e.g., the network stack) may unpack the struct to get the specified device driver they want.

For each device category (i.e., net, block, display, etc.), an unified type is used to represent all devices in that category. Currently, there are 3 categories: AxNetDevice, AxBlockDevice, and AxDisplayDevice.

Concepts

This crate supports two device models depending on the dyn feature:

  • Static: The type of all devices is static, it is determined at compile time by corresponding cargo features. For example, AxNetDevice will be an alias of VirtioNetDev if the virtio-net feature is enabled. This model provides the best performance as it avoids dynamic dispatch. But on limitation, only one device instance is supported for each device category.
  • Dynamic: All device instance is using trait objects and wrapped in a Box<dyn Trait>. For example, AxNetDevice will be Box<dyn NetDriverOps>. When call a method provided by the device, it uses dynamic dispatch that may introduce a little overhead. But on the other hand, it is more flexible, multiple instances of each device category are supported.

Supported Devices

Device Category Cargo Feature Description
Block ramdisk A RAM disk that stores data in a vector
Block virtio-blk VirtIO block device
Network virtio-net VirtIO network device
Display virtio-gpu VirtIO graphics device

Other Cargo Features

  • dyn: use the dynamic device model (see above).
  • bus-mmio: use device tree to probe all MMIO devices.
  • bus-pci: use PCI bus to probe all PCI devices. This feature is enabled by default.
  • virtio: use VirtIO devices. This is enabled if any of virtio-blk, virtio-net or virtio-gpu is enabled.
  • net: use network devices. This is enabled if any feature of network devices is selected. If this feature is enabled without any network device features, a dummy struct is used for AxNetDevice.
  • block: use block storage devices. Similar to the net feature.
  • display: use graphics display devices. Similar to the net feature.

Dependencies

~0.2–3.5MB
~51K SLoC