Skip to main content

virtio_accel_shared_queue/
lib.rs

1//! The protocol 1.0 split virtqueue, laid out in memory a driver and a device share.
2//!
3//! `virtio-accel-transport` says what a queue must do and names no memory. The reference model,
4//! `virtio-accel-split-queue`, does it with both halves in one value that owns every byte, which
5//! is what makes it an oracle and what keeps it from being a queue two parties can use. This crate
6//! is the same contracts over the real layout (Virtio 1.2 §2.7): a descriptor table, an available
7//! ring the driver writes and a used ring the device writes, at device addresses, reached through
8//! [`SharedMemory`] — the one thing a platform supplies.
9//!
10//! - [`DriverRing`] is the driver's half ([`DriverQueue`](virtio_accel_transport::DriverQueue)).
11//! - [`DeviceRing`] is the device's half ([`DeviceQueue`](virtio_accel_transport::DeviceQueue)).
12//!
13//! Each trusts nothing the other side wrote, allocates nothing, and contains no `unsafe`: the
14//! raw access is behind the trait, in the implementation that knows how its side maps the memory.
15//! Storage is inline and sized by const parameters. The profile is the protocol's — direct
16//! descriptors, no indirect tables, no event indices, the two suppression flags.
17
18#![no_std]
19#![forbid(unsafe_code)]
20
21mod device;
22mod driver;
23mod layout;
24mod memory;
25
26#[cfg(test)]
27extern crate std;
28#[cfg(test)]
29mod tests;
30
31pub use device::{DeviceRing, DeviceRingChain, DeviceRingError, RingSink, RingSource};
32pub use driver::{
33    ChainShapeError, DriverChain, DriverRing, DriverRingError, ReclaimedChains, Region,
34};
35pub use layout::{
36    RingAddresses, VIRTQ_AVAIL_F_NO_INTERRUPT, VIRTQ_DESC_F_INDIRECT, VIRTQ_DESC_F_NEXT,
37    VIRTQ_DESC_F_WRITE, VIRTQ_USED_F_NO_NOTIFY,
38};
39pub use memory::{Access, MemoryFault, SharedMemory};