Skip to main content

Module virtio

Module virtio 

Source
Expand description

s9vm : virtio split-queue core (pure).

A virtio device exchanges buffers with its driver through a split virtqueue: a descriptor table, an available ring (driver → device) and a used ring (device → driver). The layout is transport-independent, which is why this module is a pure model: it only needs guest-physical memory access, and the transport layer (MMIO page or PCI BAR) is a thin register file on top.

Implemented here:

  • descriptor encoding/decoding (16 bytes: addr, len, flags, next);
  • available-ring consumption (idx and ring[]) with wrap-around;
  • chain walking, including one level of indirect descriptor tables;
  • used-ring completion (id + written length), with wrap-around;
  • modern feature negotiation (DeviceFeatures), device-status transitions (apply_status) and queue-programming validation (QueueState, QueueNotify);
  • used-ring event suppression (VIRTQ_AVAIL_F_NO_INTERRUPT).

The transport layer (MMIO page or PCI BAR) remains a thin register file on top of these primitives.

Re-exports§

use alloc::vec::Vec; 🔒

Modules§

status
Device-status bits (virtio specification, transport independent).

Structs§

Descriptor
One split-queue descriptor.
DeviceFeatures
Modern feature negotiation state: device offer, driver request and the mask committed when the driver writes FEATURES_OK.
QueueNotify
Validated value written to QUEUE_NOTIFY.
QueueState
Queue-programming state as written by the driver through the transport.
SplitQueue
One split virtqueue.

Enums§

FeatureError
Feature-negotiation failure.
QueueError
Queue configuration or access error.

Constants§

DESCRIPTOR_SIZE
Size of one descriptor in the table.
DESC_F_INDIRECT
Descriptor flag: addr points to an indirect descriptor table.
DESC_F_NEXT
Descriptor flag: the chain continues in next.
DESC_F_WRITE
Descriptor flag: the buffer is written by the device.
MAX_QUEUE_SIZE
Highest queue size accepted by the legacy interface.
STATUS_KNOWN
Mask of every status bit the models understand.
VERSION_1_MASK 🔒
64-bit mask of VIRTIO_F_VERSION_1.
VIRTIO_F_VERSION_1
Feature bit VIRTIO_F_VERSION_1 (modern interface), bit 32 of the device/driver feature space.
VIRTQ_AVAIL_F_NO_INTERRUPT
Available-ring flag: the driver does not want used-ring interrupts.

Traits§

QueueMemory
Guest physical memory access for the queue.

Functions§

apply_status
Applies one guest write to the device-status register.
feature_word 🔒
One 32-bit half of a 64-bit feature mask.