]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: IndustryStandard: factor out Virtio095.h
authorLaszlo Ersek <lersek@redhat.com>
Wed, 6 Apr 2016 08:29:00 +0000 (10:29 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 6 Apr 2016 17:21:16 +0000 (19:21 +0200)
In the upcoming virtio-1.0 series, we'll introduce "Virtio10.h". However,
the "Virtio.h" header file should continue to expose the generic type and
macro definitions for all virtio versions that OvmfPkg supports. Therefore
extract "Virtio095.h" like this:

  Virtio.h -> Virtio095.h

so that in the upcoming patches, we can insert "Virtio10.h" in the middle
of the inclusion chain.

This follows the example of "Acpi.h" and "Pci.h" under
"MdePkg/Include/IndustryStandard".

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Suggested-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/Include/IndustryStandard/Virtio.h
OvmfPkg/Include/IndustryStandard/Virtio095.h [new file with mode: 0644]

index fcf7b67431f9eab29b99d2a18ca4c81de618b7ca..e1682fc69a42ce7661f42621b61203fc8cfecc56 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
 \r
-  Generic type and macro definitions corresponding to the virtio-0.9.5\r
-  specification.\r
+  Generic type and macro definitions corresponding to the virtio\r
+  specifications.\r
 \r
-  Copyright (C) 2012, Red Hat, Inc.\r
+  Copyright (C) 2012-2016, Red Hat, Inc.\r
   Portion of Copyright (C) 2013, ARM Ltd.\r
 \r
   This program and the accompanying materials are licensed and made available\r
 #ifndef _VIRTIO_H_\r
 #define _VIRTIO_H_\r
 \r
-#include <Base.h>\r
-\r
-//\r
-// VirtIo Subsystem Device IDs\r
-//\r
-#define VIRTIO_SUBSYSTEM_NETWORK_CARD       1\r
-#define VIRTIO_SUBSYSTEM_BLOCK_DEVICE       2\r
-#define VIRTIO_SUBSYSTEM_CONSOLE            3\r
-#define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE     4\r
-#define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING  5\r
-#define VIRTIO_SUBSYSTEM_IO_MEMORY          6\r
-#define VIRTIO_SUBSYSTEM_RPMSG              7\r
-#define VIRTIO_SUBSYSTEM_SCSI_HOST          8\r
-#define VIRTIO_SUBSYSTEM_9P_TRANSPORT       9\r
-#define VIRTIO_SUBSYSTEM_MAC80211_WLAN      10\r
-\r
-//\r
-// Virtio IDs\r
-//\r
-#define VIRTIO_VENDOR_ID                    0x1AF4\r
-#define VIRTIO_MMIO_MAGIC                   0x74726976 // "virt"\r
-\r
-\r
-//\r
-// VirtIo Device Specific Configuration Offsets\r
-//\r
-#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI             20\r
-#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI_WITH_MSI_X  24\r
-#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO            0x100\r
-\r
-//\r
-// PCI VirtIo Header Offsets\r
-//\r
-#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES           0x00\r
-#define VIRTIO_PCI_OFFSET_GUEST_FEATURES            0x04\r
-#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS             0x08\r
-#define VIRTIO_PCI_OFFSET_QUEUE_SIZE                0x0C\r
-#define VIRTIO_PCI_OFFSET_QUEUE_SELECT              0x0E\r
-#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY              0x10\r
-#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS       0x12\r
-#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR          0x13\r
-\r
-//\r
-// MMIO VirtIo Header Offsets\r
-//\r
-#define VIRTIO_MMIO_OFFSET_MAGIC                    0x00\r
-#define VIRTIO_MMIO_OFFSET_VERSION                  0x04\r
-#define VIRTIO_MMIO_OFFSET_DEVICE_ID                0x08\r
-#define VIRTIO_MMIO_OFFSET_VENDOR_ID                0x0C\r
-#define VIRTIO_MMIO_OFFSET_HOST_FEATURES            0x10\r
-#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL        0x14\r
-#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES           0x20\r
-#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL       0x24\r
-#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE          0x28\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_SEL                0x30\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX            0x34\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_NUM                0x38\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN              0x3C\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_PFN                0x40\r
-#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY             0x50\r
-#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS         0x60\r
-#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK            0x64\r
-#define VIRTIO_MMIO_OFFSET_STATUS                   0x70\r
-\r
-//\r
-// Data in the communication area is defined as packed and accessed as\r
-// volatile.\r
-//\r
-// Some structures contain arrays with dynamically determined size. In such\r
-// cases the array and its sibling fields are replaced with pointers.\r
-//\r
-// All indices (variables and fields named *Idx) are free-running and wrap\r
-// around after 0xFFFF. The queue size reported by the host is always an\r
-// integral power of 2, not greater than 32768. Actual array indices are\r
-// consistently calculated by taking the remainder of a given Idx object modulo\r
-// QueueSize. Since 0x10000 is an integral multiple of the QueueSize, UINT16\r
-// wraparound is a correct wraparound modulo QueueSize too (it doesn't offset\r
-// the remainder class).\r
-//\r
-// virtio-0.9.5, 2.3.4 Available Ring\r
-//\r
-#define VRING_AVAIL_F_NO_INTERRUPT BIT0\r
-\r
-typedef struct {\r
-  volatile UINT16 *Flags;\r
-  volatile UINT16 *Idx;\r
-\r
-  volatile UINT16 *Ring;      // QueueSize elements\r
-  volatile UINT16 *UsedEvent; // unused as per negotiation\r
-} VRING_AVAIL;\r
-\r
-\r
-//\r
-// virtio-0.9.5, 2.3.5 Used Ring\r
-//\r
-#define VRING_USED_F_NO_NOTIFY BIT0\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT32 Id;\r
-  UINT32 Len;\r
-} VRING_USED_ELEM;\r
-#pragma pack()\r
-\r
-typedef struct {\r
-  volatile UINT16          *Flags;\r
-  volatile UINT16          *Idx;\r
-  volatile VRING_USED_ELEM *UsedElem;   // QueueSize elements\r
-  volatile UINT16          *AvailEvent; // unused as per negotiation\r
-} VRING_USED;\r
-\r
-\r
-//\r
-// virtio-0.9.5, 2.3.2 Descriptor Table\r
-//\r
-#define VRING_DESC_F_NEXT     BIT0 // more descriptors in this request\r
-#define VRING_DESC_F_WRITE    BIT1 // buffer to be written *by the host*\r
-#define VRING_DESC_F_INDIRECT BIT2 // unused\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  UINT64 Addr;\r
-  UINT32 Len;\r
-  UINT16 Flags;\r
-  UINT16 Next;\r
-} VRING_DESC;\r
-#pragma pack()\r
-\r
-typedef struct {\r
-  UINTN               NumPages;\r
-  VOID                *Base;     // deallocate only this field\r
-  volatile VRING_DESC *Desc;     // QueueSize elements\r
-  VRING_AVAIL         Avail;\r
-  VRING_USED          Used;\r
-  UINT16              QueueSize;\r
-} VRING;\r
-\r
-//\r
-// virtio-0.9.5, 2.2.2.1 Device Status\r
-//\r
-#define VSTAT_ACK       BIT0\r
-#define VSTAT_DRIVER    BIT1\r
-#define VSTAT_DRIVER_OK BIT2\r
-#define VSTAT_FAILED    BIT7\r
-\r
-//\r
-// virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits\r
-//\r
-#define VIRTIO_F_NOTIFY_ON_EMPTY    BIT24\r
-#define VIRTIO_F_RING_INDIRECT_DESC BIT28\r
-#define VIRTIO_F_RING_EVENT_IDX     BIT29\r
-\r
+#include <IndustryStandard/Virtio095.h>\r
 \r
 #endif // _VIRTIO_H_\r
diff --git a/OvmfPkg/Include/IndustryStandard/Virtio095.h b/OvmfPkg/Include/IndustryStandard/Virtio095.h
new file mode 100644 (file)
index 0000000..6bf77cb
--- /dev/null
@@ -0,0 +1,175 @@
+/** @file\r
+\r
+  Generic type and macro definitions corresponding to the virtio-0.9.5\r
+  specification.\r
+\r
+  Copyright (C) 2012-2016, Red Hat, Inc.\r
+  Portion of Copyright (C) 2013, ARM Ltd.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _VIRTIO_0_9_5_H_\r
+#define _VIRTIO_0_9_5_H_\r
+\r
+#include <Base.h>\r
+\r
+//\r
+// VirtIo Subsystem Device IDs\r
+//\r
+#define VIRTIO_SUBSYSTEM_NETWORK_CARD       1\r
+#define VIRTIO_SUBSYSTEM_BLOCK_DEVICE       2\r
+#define VIRTIO_SUBSYSTEM_CONSOLE            3\r
+#define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE     4\r
+#define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING  5\r
+#define VIRTIO_SUBSYSTEM_IO_MEMORY          6\r
+#define VIRTIO_SUBSYSTEM_RPMSG              7\r
+#define VIRTIO_SUBSYSTEM_SCSI_HOST          8\r
+#define VIRTIO_SUBSYSTEM_9P_TRANSPORT       9\r
+#define VIRTIO_SUBSYSTEM_MAC80211_WLAN      10\r
+\r
+//\r
+// Virtio IDs\r
+//\r
+#define VIRTIO_VENDOR_ID                    0x1AF4\r
+#define VIRTIO_MMIO_MAGIC                   0x74726976 // "virt"\r
+\r
+\r
+//\r
+// VirtIo Device Specific Configuration Offsets\r
+//\r
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI             20\r
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI_WITH_MSI_X  24\r
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO            0x100\r
+\r
+//\r
+// PCI VirtIo Header Offsets\r
+//\r
+#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES           0x00\r
+#define VIRTIO_PCI_OFFSET_GUEST_FEATURES            0x04\r
+#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS             0x08\r
+#define VIRTIO_PCI_OFFSET_QUEUE_SIZE                0x0C\r
+#define VIRTIO_PCI_OFFSET_QUEUE_SELECT              0x0E\r
+#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY              0x10\r
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS       0x12\r
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR          0x13\r
+\r
+//\r
+// MMIO VirtIo Header Offsets\r
+//\r
+#define VIRTIO_MMIO_OFFSET_MAGIC                    0x00\r
+#define VIRTIO_MMIO_OFFSET_VERSION                  0x04\r
+#define VIRTIO_MMIO_OFFSET_DEVICE_ID                0x08\r
+#define VIRTIO_MMIO_OFFSET_VENDOR_ID                0x0C\r
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES            0x10\r
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL        0x14\r
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES           0x20\r
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL       0x24\r
+#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE          0x28\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_SEL                0x30\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX            0x34\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM                0x38\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN              0x3C\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_PFN                0x40\r
+#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY             0x50\r
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS         0x60\r
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK            0x64\r
+#define VIRTIO_MMIO_OFFSET_STATUS                   0x70\r
+\r
+//\r
+// Data in the communication area is defined as packed and accessed as\r
+// volatile.\r
+//\r
+// Some structures contain arrays with dynamically determined size. In such\r
+// cases the array and its sibling fields are replaced with pointers.\r
+//\r
+// All indices (variables and fields named *Idx) are free-running and wrap\r
+// around after 0xFFFF. The queue size reported by the host is always an\r
+// integral power of 2, not greater than 32768. Actual array indices are\r
+// consistently calculated by taking the remainder of a given Idx object modulo\r
+// QueueSize. Since 0x10000 is an integral multiple of the QueueSize, UINT16\r
+// wraparound is a correct wraparound modulo QueueSize too (it doesn't offset\r
+// the remainder class).\r
+//\r
+// virtio-0.9.5, 2.3.4 Available Ring\r
+//\r
+#define VRING_AVAIL_F_NO_INTERRUPT BIT0\r
+\r
+typedef struct {\r
+  volatile UINT16 *Flags;\r
+  volatile UINT16 *Idx;\r
+\r
+  volatile UINT16 *Ring;      // QueueSize elements\r
+  volatile UINT16 *UsedEvent; // unused as per negotiation\r
+} VRING_AVAIL;\r
+\r
+\r
+//\r
+// virtio-0.9.5, 2.3.5 Used Ring\r
+//\r
+#define VRING_USED_F_NO_NOTIFY BIT0\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT32 Id;\r
+  UINT32 Len;\r
+} VRING_USED_ELEM;\r
+#pragma pack()\r
+\r
+typedef struct {\r
+  volatile UINT16          *Flags;\r
+  volatile UINT16          *Idx;\r
+  volatile VRING_USED_ELEM *UsedElem;   // QueueSize elements\r
+  volatile UINT16          *AvailEvent; // unused as per negotiation\r
+} VRING_USED;\r
+\r
+\r
+//\r
+// virtio-0.9.5, 2.3.2 Descriptor Table\r
+//\r
+#define VRING_DESC_F_NEXT     BIT0 // more descriptors in this request\r
+#define VRING_DESC_F_WRITE    BIT1 // buffer to be written *by the host*\r
+#define VRING_DESC_F_INDIRECT BIT2 // unused\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  UINT64 Addr;\r
+  UINT32 Len;\r
+  UINT16 Flags;\r
+  UINT16 Next;\r
+} VRING_DESC;\r
+#pragma pack()\r
+\r
+typedef struct {\r
+  UINTN               NumPages;\r
+  VOID                *Base;     // deallocate only this field\r
+  volatile VRING_DESC *Desc;     // QueueSize elements\r
+  VRING_AVAIL         Avail;\r
+  VRING_USED          Used;\r
+  UINT16              QueueSize;\r
+} VRING;\r
+\r
+//\r
+// virtio-0.9.5, 2.2.2.1 Device Status\r
+//\r
+#define VSTAT_ACK       BIT0\r
+#define VSTAT_DRIVER    BIT1\r
+#define VSTAT_DRIVER_OK BIT2\r
+#define VSTAT_FAILED    BIT7\r
+\r
+//\r
+// virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits\r
+//\r
+#define VIRTIO_F_NOTIFY_ON_EMPTY    BIT24\r
+#define VIRTIO_F_RING_INDIRECT_DESC BIT28\r
+#define VIRTIO_F_RING_EVENT_IDX     BIT29\r
+\r
+\r
+#endif // _VIRTIO_0_9_5_H_\r