Expand description
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 ofVirtioNetDev
if thevirtio-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 beBox<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 enabeld by default.virtio
: use VirtIO devices. This is enabled if any ofvirtio-blk
,virtio-net
orvirtio-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 forAxNetDevice
.block
: use block storage devices. Similar to thenet
feature.display
: use graphics display devices. Similar to thenet
feature.
Modules§
- Device driver prelude that includes some traits and types.
Structs§
- A structure that contains all device drivers, organized by their category.
- A structure that contains all device drivers of a certain category.
Enums§
- A unified enum that represents different categories of devices.
Functions§
- Probes and initializes all device drivers, returns the
AllDevices
struct.
Type Aliases§
- AxBlockDevice
block
The unified type of the block storage devices. - AxDisplayDevice
display
The unified type of the graphics display devices. - AxNetDevice
net
The unified type of the NIC devices.