3 * - By John Hodge (thePowersGang)
6 * - VirtIO Hardware Header
8 * Reference: LinuxKernel:/Documentation/virtual/virtio-spec.txt
10 #ifndef _VIRTIO__VIRTIO_HW_H_
11 #define _VIRTIO__VIRTIO_HW_H_
13 //#if _MODULE_NAME_ != "VirtIOCommon"
14 //#error "This header is a VirtIO internal"
18 typedef struct sVirtIO_Header tVirtIO_Header;
22 volatile Uint32 DeviceFeatures; // R
23 volatile Uint32 GuestFeatures; // RW
24 Uint32 QueueAddress; // RW
25 volatile Uint16 QueueSize; // R
26 volatile Uint16 QueueSelect; // RW
27 volatile Uint16 QueueNotify; // RW
28 volatile Uint8 DeviceStatus; // RW
29 volatile Uint8 ISRStatus; // R
34 VIRTIO_REG_DEVFEAT = 0x00, // R
35 VIRTIO_REG_GUESTFEAT = 0x04, // RW
36 VIRTIO_REG_QUEUEADDR = 0x08, // RW
37 VIRTIO_REG_QUEUESIZE = 0x0C, // R
38 VIRTIO_REG_QUEUESELECT = 0x0E, // RW
39 VIRTIO_REG_QUEUENOTIFY = 0x10, // RW
40 VIRTIO_REG_DEVSTS = 0x12, // RW
41 VIRTIO_REG_ISRSTS = 0x13, // R
43 VIRTIO_REG_DEVSPEC_0 = 0x14,
45 VIRTIO_REG_MSIX_CONFIGV = 0x14, // RW
46 VIRTIO_REG_MSIX_QUEUEV = 0x16, // RW
48 VIRTIO_REG_DEVSPEC_1 = 0x18,
51 enum eVirtIO_DeviceStatuses
53 VIRTIO_DEVSTS_RESET = 0x00, // Reset device
54 VIRTIO_DEVSTS_ACKNOWLEDGE = 0x01, // Acknowledged device
55 VIRTIO_DEVSTS_DRIVER = 0x02, // Driver avaliable
56 VIRTIO_DEVSTS_DRIVER_OK = 0x04, // Driver initialised
57 VIRTIO_DEVSTS_FAILED = 0x80, // Something went wrong
62 VIRTIO_ISR_QUEUE = 0x01,
65 // VirtIO Ring Structure
66 // +0 : Ring descriptors (given by tVirtIO_Header::QueueSize)
67 // +QS*16 : Avaliable ring
68 // +PAD[4096] : Used ring
70 #define VRING_AVAIL_F_NO_INTERRUPT 0x1
72 struct sVirtIO_AvailRing
74 // [0]: Disable IRQ on descriptor use
77 Uint16 Ring[]; // tVirtIO_Header::QueueSize entries
81 struct sVirtIO_UsedRing
83 // [0]: Do not notify when descriptors added
93 #define VRING_DESC_F_NEXT 0x1
94 #define VRING_DESC_F_WRITE 0x2
95 #define VRING_DESC_F_INDIRECT 0x4
97 struct sVirtIO_RingDesc
101 // [0]: Continue using the `Next` field
102 // [1]: Write-only (insead of Read-only)
103 // [2]: Indirect buffer (list of buffer descriptors)
105 Uint16 Next; // Index