Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
virtio_config.h File Reference

VIRTIO common definitions based on the specification. More...

Go to the source code of this file.

Macros

Virtio device status bits

Bit positions of the device status field.

These are described in 2.1 Device Status Field

#define DEVICE_STATUS_ACKNOWLEDGE   0
 Indicates the guest has found and recognized the device presence.
#define DEVICE_STATUS_DRIVER   1
 Indicates the guest driver is ready to drive the device.
#define DEVICE_STATUS_DRIVER_OK   2
 Indicates the driver has successfully set up the device and is ready.
#define DEVICE_STATUS_FEATURES_OK   3
 Indicates the driver and device agreed on the negotiated feature set.
#define DEVICE_STATUS_NEEDS_RESET   6
 Indicates the device requests a reset to recover from an error.
#define DEVICE_STATUS_FAILED   7
 Indicates the device has experienced a non-recoverable error.
Feature Bits

Negotiable device-independent feature bit positions.

These are described in 6 Reserved Feature Bits

#define VIRTIO_RING_F_INDIRECT_DESC   28
 Indicates descriptors can reference descriptor tables.
#define VIRTIO_RING_F_EVENT_IDX   29
 Indicates driver/device use event index for notifications.
#define VIRTIO_F_VERSION_1   32
 Indicates device complies with Virtio 1.0+ semantics.
#define VIRTIO_F_ACCESS_PLATFORM   33
 Indicates device needs platform-specific handling.
Ring Flag Bits

Available and used ring flag bit positions as described in

2.7.6 The Virtqueue Available Ring and 2.7.8 The Virtqueue Used Ring

#define VIRTQ_AVAIL_F_NO_INTERRUPT   1
 Driver requests the device to skip interrupts.
#define VIRTQ_USED_F_NO_NOTIFY   1
 Device requests the driver to suppress notifications.
Ranges of feature bits

These described in 2.2 Feature Bits

#define DEV_TYPE_FEAT_RANGE_0_BEGIN   0
 Start of the first device-specific feature range.
#define DEV_TYPE_FEAT_RANGE_0_END   23
 End of the first device-specific feature range.
#define DEV_TYPE_FEAT_RANGE_1_BEGIN   50
 Start of the second device-specific feature range.
#define DEV_TYPE_FEAT_RANGE_1_END   127
 End of the second device-specific feature range.
Transport interrupt bits

While defined separately in

4.1.4.5 ISR status capabilit for PCI and 4.2.2 MMIO Device Register Layout for MMIO

the same bits are responsible for the same interrupts, so defines with them can be unified

#define VIRTIO_QUEUE_INTERRUPT   1
 A virtqueue has pending used buffers.
#define VIRTIO_DEVICE_CONFIGURATION_INTERRUPT   2
 Device configuration space has changed.
VIRTIO-MMIO registers

The details are described in 4.2.2 MMIO Device Register Layout

#define VIRTIO_MMIO_MAGIC_VALUE   0x000
 Magic value identifying the virtio MMIO device.
#define VIRTIO_MMIO_VERSION   0x004
 Virtio specification version exposed by the device.
#define VIRTIO_MMIO_DEVICE_ID   0x008
 Device type identifier register.
#define VIRTIO_MMIO_VENDOR_ID   0x00c
 Vendor-specific identifier register.
#define VIRTIO_MMIO_DEVICE_FEATURES   0x010
 Lower 32 bits of the device feature bitmap.
#define VIRTIO_MMIO_DEVICE_FEATURES_SEL   0x014
 Selector choosing the device feature word.
#define VIRTIO_MMIO_DRIVER_FEATURES   0x020
 Lower 32 bits of the negotiated driver feature bitmap.
#define VIRTIO_MMIO_DRIVER_FEATURES_SEL   0x024
 Selector choosing the driver feature word.
#define VIRTIO_MMIO_QUEUE_SEL   0x030
 Virtqueue index selected for subsequent accesses.
#define VIRTIO_MMIO_QUEUE_SIZE_MAX   0x034
 Maximum queue size supported by the selected virtqueue.
#define VIRTIO_MMIO_QUEUE_SIZE   0x038
 Queue size chosen by the driver for the selected virtqueue.
#define VIRTIO_MMIO_QUEUE_READY   0x044
 Ready flag indicating driver ownership of the queue.
#define VIRTIO_MMIO_QUEUE_NOTIFY   0x050
 Doorbell register for queue notifications.
#define VIRTIO_MMIO_INTERRUPT_STATUS   0x060
 Pending interrupt summary bits.
#define VIRTIO_MMIO_INTERRUPT_ACK   0x064
 Interrupt acknowledgment register.
#define VIRTIO_MMIO_STATUS   0x070
 Device status.
#define VIRTIO_MMIO_QUEUE_DESC_LOW   0x080
 Lower 32 bits of the descriptor table address.
#define VIRTIO_MMIO_QUEUE_DESC_HIGH   0x084
 Upper 32 bits of the descriptor table address.
#define VIRTIO_MMIO_QUEUE_AVAIL_LOW   0x090
 Lower 32 bits of the available ring address.
#define VIRTIO_MMIO_QUEUE_AVAIL_HIGH   0x094
 Upper 32 bits of the available ring address.
#define VIRTIO_MMIO_QUEUE_USED_LOW   0x0a0
 Lower 32 bits of the used ring address.
#define VIRTIO_MMIO_QUEUE_USED_HIGH   0x0a4
 Upper 32 bits of the used ring address.
#define VIRTIO_MMIO_SHM_SEL   0x0ac
 Shared memory region selector.
#define VIRTIO_MMIO_SHM_LEN_LOW   0x0b0
 Lower 32 bits of the shared memory length.
#define VIRTIO_MMIO_SHM_LEN_HIGH   0x0b4
 Upper 32 bits of the shared memory length.
#define VIRTIO_MMIO_SHM_BASE_LOW   0x0b8
 Lower 32 bits of the shared memory base address.
#define VIRTIO_MMIO_SHM_BASE_HIGH   0x0bc
 Upper 32 bits of the shared memory base address.
#define VIRTIO_MMIO_QUEUE_RESET   0x0c0
 Queue reset control register.
#define VIRTIO_MMIO_CONFIG_GENERATION   0x0fc
 Generation counter for configuration space.
#define VIRTIO_MMIO_CONFIG   0x100
 Base offset of the device configuration structure.

Detailed Description

VIRTIO common definitions based on the specification.

Based on Virtual I/O Device (VIRTIO) Version 1.3 specification: https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.pdf

Macro Definition Documentation

◆ DEV_TYPE_FEAT_RANGE_0_BEGIN

#define DEV_TYPE_FEAT_RANGE_0_BEGIN   0

Start of the first device-specific feature range.

◆ DEV_TYPE_FEAT_RANGE_0_END

#define DEV_TYPE_FEAT_RANGE_0_END   23

End of the first device-specific feature range.

◆ DEV_TYPE_FEAT_RANGE_1_BEGIN

#define DEV_TYPE_FEAT_RANGE_1_BEGIN   50

Start of the second device-specific feature range.

◆ DEV_TYPE_FEAT_RANGE_1_END

#define DEV_TYPE_FEAT_RANGE_1_END   127

End of the second device-specific feature range.

◆ DEVICE_STATUS_ACKNOWLEDGE

#define DEVICE_STATUS_ACKNOWLEDGE   0

Indicates the guest has found and recognized the device presence.

◆ DEVICE_STATUS_DRIVER

#define DEVICE_STATUS_DRIVER   1

Indicates the guest driver is ready to drive the device.

◆ DEVICE_STATUS_DRIVER_OK

#define DEVICE_STATUS_DRIVER_OK   2

Indicates the driver has successfully set up the device and is ready.

◆ DEVICE_STATUS_FAILED

#define DEVICE_STATUS_FAILED   7

Indicates the device has experienced a non-recoverable error.

◆ DEVICE_STATUS_FEATURES_OK

#define DEVICE_STATUS_FEATURES_OK   3

Indicates the driver and device agreed on the negotiated feature set.

◆ DEVICE_STATUS_NEEDS_RESET

#define DEVICE_STATUS_NEEDS_RESET   6

Indicates the device requests a reset to recover from an error.

◆ VIRTIO_DEVICE_CONFIGURATION_INTERRUPT

#define VIRTIO_DEVICE_CONFIGURATION_INTERRUPT   2

Device configuration space has changed.

◆ VIRTIO_F_ACCESS_PLATFORM

#define VIRTIO_F_ACCESS_PLATFORM   33

Indicates device needs platform-specific handling.

◆ VIRTIO_F_VERSION_1

#define VIRTIO_F_VERSION_1   32

Indicates device complies with Virtio 1.0+ semantics.

◆ VIRTIO_MMIO_CONFIG

#define VIRTIO_MMIO_CONFIG   0x100

Base offset of the device configuration structure.

◆ VIRTIO_MMIO_CONFIG_GENERATION

#define VIRTIO_MMIO_CONFIG_GENERATION   0x0fc

Generation counter for configuration space.

◆ VIRTIO_MMIO_DEVICE_FEATURES

#define VIRTIO_MMIO_DEVICE_FEATURES   0x010

Lower 32 bits of the device feature bitmap.

◆ VIRTIO_MMIO_DEVICE_FEATURES_SEL

#define VIRTIO_MMIO_DEVICE_FEATURES_SEL   0x014

Selector choosing the device feature word.

◆ VIRTIO_MMIO_DEVICE_ID

#define VIRTIO_MMIO_DEVICE_ID   0x008

Device type identifier register.

◆ VIRTIO_MMIO_DRIVER_FEATURES

#define VIRTIO_MMIO_DRIVER_FEATURES   0x020

Lower 32 bits of the negotiated driver feature bitmap.

◆ VIRTIO_MMIO_DRIVER_FEATURES_SEL

#define VIRTIO_MMIO_DRIVER_FEATURES_SEL   0x024

Selector choosing the driver feature word.

◆ VIRTIO_MMIO_INTERRUPT_ACK

#define VIRTIO_MMIO_INTERRUPT_ACK   0x064

Interrupt acknowledgment register.

◆ VIRTIO_MMIO_INTERRUPT_STATUS

#define VIRTIO_MMIO_INTERRUPT_STATUS   0x060

Pending interrupt summary bits.

◆ VIRTIO_MMIO_MAGIC_VALUE

#define VIRTIO_MMIO_MAGIC_VALUE   0x000

Magic value identifying the virtio MMIO device.

◆ VIRTIO_MMIO_QUEUE_AVAIL_HIGH

#define VIRTIO_MMIO_QUEUE_AVAIL_HIGH   0x094

Upper 32 bits of the available ring address.

◆ VIRTIO_MMIO_QUEUE_AVAIL_LOW

#define VIRTIO_MMIO_QUEUE_AVAIL_LOW   0x090

Lower 32 bits of the available ring address.

◆ VIRTIO_MMIO_QUEUE_DESC_HIGH

#define VIRTIO_MMIO_QUEUE_DESC_HIGH   0x084

Upper 32 bits of the descriptor table address.

◆ VIRTIO_MMIO_QUEUE_DESC_LOW

#define VIRTIO_MMIO_QUEUE_DESC_LOW   0x080

Lower 32 bits of the descriptor table address.

◆ VIRTIO_MMIO_QUEUE_NOTIFY

#define VIRTIO_MMIO_QUEUE_NOTIFY   0x050

Doorbell register for queue notifications.

◆ VIRTIO_MMIO_QUEUE_READY

#define VIRTIO_MMIO_QUEUE_READY   0x044

Ready flag indicating driver ownership of the queue.

◆ VIRTIO_MMIO_QUEUE_RESET

#define VIRTIO_MMIO_QUEUE_RESET   0x0c0

Queue reset control register.

◆ VIRTIO_MMIO_QUEUE_SEL

#define VIRTIO_MMIO_QUEUE_SEL   0x030

Virtqueue index selected for subsequent accesses.

◆ VIRTIO_MMIO_QUEUE_SIZE

#define VIRTIO_MMIO_QUEUE_SIZE   0x038

Queue size chosen by the driver for the selected virtqueue.

◆ VIRTIO_MMIO_QUEUE_SIZE_MAX

#define VIRTIO_MMIO_QUEUE_SIZE_MAX   0x034

Maximum queue size supported by the selected virtqueue.

◆ VIRTIO_MMIO_QUEUE_USED_HIGH

#define VIRTIO_MMIO_QUEUE_USED_HIGH   0x0a4

Upper 32 bits of the used ring address.

◆ VIRTIO_MMIO_QUEUE_USED_LOW

#define VIRTIO_MMIO_QUEUE_USED_LOW   0x0a0

Lower 32 bits of the used ring address.

◆ VIRTIO_MMIO_SHM_BASE_HIGH

#define VIRTIO_MMIO_SHM_BASE_HIGH   0x0bc

Upper 32 bits of the shared memory base address.

◆ VIRTIO_MMIO_SHM_BASE_LOW

#define VIRTIO_MMIO_SHM_BASE_LOW   0x0b8

Lower 32 bits of the shared memory base address.

◆ VIRTIO_MMIO_SHM_LEN_HIGH

#define VIRTIO_MMIO_SHM_LEN_HIGH   0x0b4

Upper 32 bits of the shared memory length.

◆ VIRTIO_MMIO_SHM_LEN_LOW

#define VIRTIO_MMIO_SHM_LEN_LOW   0x0b0

Lower 32 bits of the shared memory length.

◆ VIRTIO_MMIO_SHM_SEL

#define VIRTIO_MMIO_SHM_SEL   0x0ac

Shared memory region selector.

◆ VIRTIO_MMIO_STATUS

#define VIRTIO_MMIO_STATUS   0x070

Device status.

◆ VIRTIO_MMIO_VENDOR_ID

#define VIRTIO_MMIO_VENDOR_ID   0x00c

Vendor-specific identifier register.

◆ VIRTIO_MMIO_VERSION

#define VIRTIO_MMIO_VERSION   0x004

Virtio specification version exposed by the device.

◆ VIRTIO_QUEUE_INTERRUPT

#define VIRTIO_QUEUE_INTERRUPT   1

A virtqueue has pending used buffers.

◆ VIRTIO_RING_F_EVENT_IDX

#define VIRTIO_RING_F_EVENT_IDX   29

Indicates driver/device use event index for notifications.

◆ VIRTIO_RING_F_INDIRECT_DESC

#define VIRTIO_RING_F_INDIRECT_DESC   28

Indicates descriptors can reference descriptor tables.

◆ VIRTQ_AVAIL_F_NO_INTERRUPT

#define VIRTQ_AVAIL_F_NO_INTERRUPT   1

Driver requests the device to skip interrupts.

This is valid if VIRTIO_RING_F_EVENT_IDX negotiated.

◆ VIRTQ_USED_F_NO_NOTIFY

#define VIRTQ_USED_F_NO_NOTIFY   1

Device requests the driver to suppress notifications.

This is valid if VIRTIO_RING_F_EVENT_IDX negotiated.