1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! virtio-MMIO transport and per-device drivers for squib.
//!
//! This crate ports the virtio-MMIO state machine and per-device frontends
//! described in [14-virtio-and-devices.md](../../../specs/14-virtio-and-devices.md).
//! The transport speaks the [virtio v1.2 MMIO register layout][spec] and
//! adapts it to squib-native abstractions:
//!
//! - [`squib_bus::BusDevice`] for the MMIO-routed register surface.
//! - [`squib_core::GuestMemory`] for descriptor / payload reads and writes.
//! - [`squib_gic::Gic::pulse_spi`] for edge-rising IRQ delivery (D24).
//!
//! The crate intentionally avoids `vmm-sys-util`, `kvm-ioctls`, and the
//! upstream Linux-flavoured `EventFd` plumbing โ squib-vmm uses Tokio
//! channels for cross-thread queue notifications and the GIC's `pulse_spi` is
//! synchronous through `Arc<dyn Gic>`. See I-CRATE-3 in
//! [61-crates-and-features.md ยง 7](../../../specs/61-crates-and-features.md#7-invariants).
//!
//! ## Module layout
//!
//! | Module | Role |
//! |--------|------|
//! | [`device`] | Per-device-type trait surface ([`device::VirtioDevice`]) |
//! | [`device_id`] | Standard virtio device IDs (block=2, net=1, vsock=19, ...) |
//! | [`device_status`] | Status bits driving the driver-init state machine |
//! | [`feature_bits`] | Common feature bits (VIRTIO_F_VERSION_1, ...) |
//! | [`interrupt`] | [`interrupt::IrqLine`] โ wraps `Gic + IntId` for the device side |
//! | [`queue`] | Virtqueue: descriptors, avail/used rings, [`queue::DescriptorChain`] |
//! | [`slot`] | MMIO-slot allocator (32-slot ceiling, base `0x0F00_0000 + slot * 0x1000`) |
//! | [`transport`] | virtio-MMIO `BusDevice`: register layout + driver-init state machine |
//! | [`devices`] | Per-device frontends: block, net, vsock, balloon, rng, console, pmem, mem, boot-timer |
//!
//! [spec]: https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-1340002
// virtio wire shapes pin every register width: descriptor.len is u32,
// queue_size is u16, MMIO register payloads are u32. Casting between u64
// host computations and these wire widths is the device contract โ we keep
// the casts where they belong and trust the type system at the boundary
// (validation runs in `Queue::set_size` etc.). The clippy pedantic
// truncation/precision lints are too noisy to be useful here; the
// `cast_possible_truncation` lint is informative for app code, not for
// wire-shape code.
pub use ;
pub use VirtioError;
pub use IrqLine;
pub use ;
pub use ;
pub use ;