3 Generic type and macro definitions corresponding to the virtio-0.9.5
6 Copyright (C) 2012, Red Hat, Inc.
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 // VirtIo Subsystem Device IDs
26 #define VIRTIO_SUBSYSTEM_NETWORK_CARD 1
27 #define VIRTIO_SUBSYSTEM_BLOCK_DEVICE 2
28 #define VIRTIO_SUBSYSTEM_CONSOLE 3
29 #define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE 4
30 #define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING 5
31 #define VIRTIO_SUBSYSTEM_IO_MEMORY 6
32 #define VIRTIO_SUBSYSTEM_RPMSG 7
33 #define VIRTIO_SUBSYSTEM_SCSI_HOST 8
34 #define VIRTIO_SUBSYSTEM_9P_TRANSPORT 9
35 #define VIRTIO_SUBSYSTEM_MAC80211_WLAN 10
38 // Data in the communication area is defined as packed and accessed as
41 // Some structures contain arrays with dynamically determined size. In such
42 // cases the array and its sibling fields are replaced with pointers.
44 // All indices (variables and fields named *Idx) are free-running and wrap
45 // around after 0xFFFF. The queue size reported by the host is always an
46 // integral power of 2, not greater than 32768. Actual array indices are
47 // consistently calculated by taking the remainder of a given Idx object modulo
48 // QueueSize. Since 0x10000 is an integral multiple of the QueueSize, UINT16
49 // wraparound is a correct wraparound modulo QueueSize too (it doesn't offset
50 // the remainder class).
52 // virtio-0.9.5, 2.3.4 Available Ring
54 #define VRING_AVAIL_F_NO_INTERRUPT BIT0
57 volatile UINT16
*Flags
;
60 volatile UINT16
*Ring
; // QueueSize elements
61 volatile UINT16
*UsedEvent
; // unused as per negotiation
66 // virtio-0.9.5, 2.3.5 Used Ring
68 #define VRING_USED_F_NO_NOTIFY BIT0
78 volatile UINT16
*Flags
;
80 volatile VRING_USED_ELEM
*UsedElem
; // QueueSize elements
81 volatile UINT16
*AvailEvent
; // unused as per negotiation
86 // virtio-0.9.5, 2.3.2 Descriptor Table
88 #define VRING_DESC_F_NEXT BIT0 // more descriptors in this request
89 #define VRING_DESC_F_WRITE BIT1 // buffer to be written *by the host*
90 #define VRING_DESC_F_INDIRECT BIT2 // unused
103 VOID
*Base
; // deallocate only this field
104 volatile VRING_DESC
*Desc
; // QueueSize elements
112 // virtio-0.9.5, 2.2.2 Virtio Header -- no MSI-X
116 UINT32 VhdrDeviceFeatureBits
;
117 UINT32 VhdrGuestFeatureBits
;
118 UINT32 VhdrQueueAddress
;
119 UINT16 VhdrQueueSize
;
120 UINT16 VhdrQueueSelect
;
121 UINT16 VhdrQueueNotify
;
122 UINT8 VhdrDeviceStatus
;
129 // virtio-0.9.5, 2.2.2.1 Device Status
131 #define VSTAT_ACK BIT0
132 #define VSTAT_DRIVER BIT1
133 #define VSTAT_DRIVER_OK BIT2
134 #define VSTAT_FAILED BIT7
137 // virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits
139 #define VIRTIO_F_NOTIFY_ON_EMPTY BIT24
140 #define VIRTIO_F_RING_INDIRECT_DESC BIT28
141 #define VIRTIO_F_RING_EVENT_IDX BIT29