diff options
Diffstat (limited to 'OvmfPkg/Include/IndustryStandard/Virtio095.h')
-rw-r--r-- | OvmfPkg/Include/IndustryStandard/Virtio095.h | 124 |
1 files changed, 60 insertions, 64 deletions
diff --git a/OvmfPkg/Include/IndustryStandard/Virtio095.h b/OvmfPkg/Include/IndustryStandard/Virtio095.h index fe886d223e..e06f87db79 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio095.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio095.h @@ -32,9 +32,8 @@ //
// Virtio IDs
//
-#define VIRTIO_VENDOR_ID 0x1AF4
-#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt"
-
+#define VIRTIO_VENDOR_ID 0x1AF4
+#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt"
//
// VirtIo Device Specific Configuration Offsets
@@ -46,36 +45,36 @@ //
// PCI VirtIo Header Offsets
//
-#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES 0x00
-#define VIRTIO_PCI_OFFSET_GUEST_FEATURES 0x04
-#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS 0x08
-#define VIRTIO_PCI_OFFSET_QUEUE_SIZE 0x0C
-#define VIRTIO_PCI_OFFSET_QUEUE_SELECT 0x0E
-#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY 0x10
-#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS 0x12
-#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR 0x13
+#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES 0x00
+#define VIRTIO_PCI_OFFSET_GUEST_FEATURES 0x04
+#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS 0x08
+#define VIRTIO_PCI_OFFSET_QUEUE_SIZE 0x0C
+#define VIRTIO_PCI_OFFSET_QUEUE_SELECT 0x0E
+#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY 0x10
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS 0x12
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR 0x13
//
// MMIO VirtIo Header Offsets
//
-#define VIRTIO_MMIO_OFFSET_MAGIC 0x00
-#define VIRTIO_MMIO_OFFSET_VERSION 0x04
-#define VIRTIO_MMIO_OFFSET_DEVICE_ID 0x08
-#define VIRTIO_MMIO_OFFSET_VENDOR_ID 0x0C
-#define VIRTIO_MMIO_OFFSET_HOST_FEATURES 0x10
-#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL 0x14
-#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES 0x20
-#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL 0x24
-#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE 0x28
-#define VIRTIO_MMIO_OFFSET_QUEUE_SEL 0x30
-#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX 0x34
-#define VIRTIO_MMIO_OFFSET_QUEUE_NUM 0x38
-#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN 0x3C
-#define VIRTIO_MMIO_OFFSET_QUEUE_PFN 0x40
-#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY 0x50
-#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS 0x60
-#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK 0x64
-#define VIRTIO_MMIO_OFFSET_STATUS 0x70
+#define VIRTIO_MMIO_OFFSET_MAGIC 0x00
+#define VIRTIO_MMIO_OFFSET_VERSION 0x04
+#define VIRTIO_MMIO_OFFSET_DEVICE_ID 0x08
+#define VIRTIO_MMIO_OFFSET_VENDOR_ID 0x0C
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES 0x10
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL 0x14
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES 0x20
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL 0x24
+#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE 0x28
+#define VIRTIO_MMIO_OFFSET_QUEUE_SEL 0x30
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX 0x34
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM 0x38
+#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN 0x3C
+#define VIRTIO_MMIO_OFFSET_QUEUE_PFN 0x40
+#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY 0x50
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS 0x60
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK 0x64
+#define VIRTIO_MMIO_OFFSET_STATUS 0x70
//
// Data in the communication area is defined as packed and accessed as
@@ -94,76 +93,73 @@ //
// virtio-0.9.5, 2.3.4 Available Ring
//
-#define VRING_AVAIL_F_NO_INTERRUPT BIT0
+#define VRING_AVAIL_F_NO_INTERRUPT BIT0
typedef struct {
- volatile UINT16 *Flags;
- volatile UINT16 *Idx;
+ volatile UINT16 *Flags;
+ volatile UINT16 *Idx;
- volatile UINT16 *Ring; // QueueSize elements
- volatile UINT16 *UsedEvent; // unused as per negotiation
+ volatile UINT16 *Ring; // QueueSize elements
+ volatile UINT16 *UsedEvent; // unused as per negotiation
} VRING_AVAIL;
-
//
// virtio-0.9.5, 2.3.5 Used Ring
//
-#define VRING_USED_F_NO_NOTIFY BIT0
+#define VRING_USED_F_NO_NOTIFY BIT0
#pragma pack(1)
typedef struct {
- UINT32 Id;
- UINT32 Len;
+ UINT32 Id;
+ UINT32 Len;
} VRING_USED_ELEM;
#pragma pack()
typedef struct {
- volatile UINT16 *Flags;
- volatile UINT16 *Idx;
- volatile VRING_USED_ELEM *UsedElem; // QueueSize elements
- volatile UINT16 *AvailEvent; // unused as per negotiation
+ volatile UINT16 *Flags;
+ volatile UINT16 *Idx;
+ volatile VRING_USED_ELEM *UsedElem; // QueueSize elements
+ volatile UINT16 *AvailEvent; // unused as per negotiation
} VRING_USED;
-
//
// virtio-0.9.5, 2.3.2 Descriptor Table
//
-#define VRING_DESC_F_NEXT BIT0 // more descriptors in this request
-#define VRING_DESC_F_WRITE BIT1 // buffer to be written *by the host*
-#define VRING_DESC_F_INDIRECT BIT2 // unused
+#define VRING_DESC_F_NEXT BIT0 // more descriptors in this request
+#define VRING_DESC_F_WRITE BIT1 // buffer to be written *by the host*
+#define VRING_DESC_F_INDIRECT BIT2 // unused
#pragma pack(1)
typedef struct {
- UINT64 Addr;
- UINT32 Len;
- UINT16 Flags;
- UINT16 Next;
+ UINT64 Addr;
+ UINT32 Len;
+ UINT16 Flags;
+ UINT16 Next;
} VRING_DESC;
#pragma pack()
typedef struct {
- UINTN NumPages;
- VOID *Base; // deallocate only this field
- volatile VRING_DESC *Desc; // QueueSize elements
- VRING_AVAIL Avail;
- VRING_USED Used;
- UINT16 QueueSize;
+ UINTN NumPages;
+ VOID *Base; // deallocate only this field
+ volatile VRING_DESC *Desc; // QueueSize elements
+ VRING_AVAIL Avail;
+ VRING_USED Used;
+ UINT16 QueueSize;
} VRING;
//
// virtio-0.9.5, 2.2.2.1 Device Status
//
-#define VSTAT_ACK BIT0
-#define VSTAT_DRIVER BIT1
-#define VSTAT_DRIVER_OK BIT2
-#define VSTAT_FAILED BIT7
+#define VSTAT_ACK BIT0
+#define VSTAT_DRIVER BIT1
+#define VSTAT_DRIVER_OK BIT2
+#define VSTAT_FAILED BIT7
//
// virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits
//
-#define VIRTIO_F_NOTIFY_ON_EMPTY BIT24
-#define VIRTIO_F_RING_INDIRECT_DESC BIT28
-#define VIRTIO_F_RING_EVENT_IDX BIT29
-
+#define VIRTIO_F_NOTIFY_ON_EMPTY BIT24
+#define VIRTIO_F_RING_INDIRECT_DESC BIT28
+#define VIRTIO_F_RING_EVENT_IDX BIT29
#endif // _VIRTIO_0_9_5_H_
|