--- /dev/null
+/** @file\r
+\r
+ Type and macro definitions corresponding to the virtio-0.9.5 specification.\r
+\r
+ Copyright (C) 2012, Red Hat, Inc.\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
+#include <Base.h>\r
+\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
+//\r
+// virtio-0.9.5, 2.2.2 Virtio Header -- no MSI-X\r
+// virtio-0.9.5, Appendix D\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+ UINT32 VhdrDeviceFeatureBits;\r
+ UINT32 VhdrGuestFeatureBits;\r
+ UINT32 VhdrQueueAddress;\r
+ UINT16 VhdrQueueSize;\r
+ UINT16 VhdrQueueSelect;\r
+ UINT16 VhdrQueueNotify;\r
+ UINT8 VhdrDeviceStatus;\r
+ UINT8 VhdrISR;\r
+ UINT64 VhdrCapacity;\r
+ UINT32 VhdrSizeMax;\r
+ UINT32 VhdrSegMax;\r
+ UINT16 VhdrCylinders;\r
+ UINT8 VhdrHeads;\r
+ UINT8 VhdrSectors;\r
+ UINT32 VhdrBlkSize;\r
+} VBLK_HDR;\r
+#pragma pack()\r
+\r
+#define OFFSET_OF_VHDR(Field) ((UINTN)(UINT8 *)&((VBLK_HDR *) 0)->Field)\r
+#define SIZE_OF_VHDR(Field) (sizeof ((VBLK_HDR *) 0)->Field)\r
+\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
+// virtio-0.9.5, Appendix D: Block Device\r
+//\r
+#define VIRTIO_BLK_F_BARRIER BIT0\r
+#define VIRTIO_BLK_F_SIZE_MAX BIT1\r
+#define VIRTIO_BLK_F_SEG_MAX BIT2\r
+#define VIRTIO_BLK_F_GEOMETRY BIT4\r
+#define VIRTIO_BLK_F_RO BIT5\r
+#define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in\r
+ // practice; actual host side implementation\r
+ // negotiates "optimal" block size\r
+ // separately\r
+#define VIRTIO_BLK_F_SCSI BIT7\r
+#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r
+\r
+\r
+//\r
+// We keep the status byte separate from the rest of the virtio-blk request\r
+// header. See description of historical scattering at the end of Appendix D:\r
+// we're going to put the status byte in a separate VRING_DESC.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+ UINT32 Type;\r
+ UINT32 IoPrio;\r
+ UINT64 Sector;\r
+} VIRTIO_BLK_REQ;\r
+#pragma pack()\r
+\r
+#define VIRTIO_BLK_T_IN 0x00000000\r
+#define VIRTIO_BLK_T_OUT 0x00000001\r
+#define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r
+#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r
+#define VIRTIO_BLK_T_FLUSH 0x00000004\r
+#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r
+#define VIRTIO_BLK_T_BARRIER BIT31\r
+\r
+#define VIRTIO_BLK_S_OK 0x00\r
+#define VIRTIO_BLK_S_IOERR 0x01\r
+#define VIRTIO_BLK_S_UNSUPP 0x02\r
+++ /dev/null
-/** @file\r
-\r
- Type and macro definitions corresponding to the virtio-0.9.5 specification.\r
-\r
- Copyright (C) 2012, Red Hat, Inc.\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
-#include <Base.h>\r
-\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
-//\r
-// virtio-0.9.5, 2.2.2 Virtio Header -- no MSI-X\r
-// virtio-0.9.5, Appendix D\r
-//\r
-#pragma pack(1)\r
-typedef struct {\r
- UINT32 VhdrDeviceFeatureBits;\r
- UINT32 VhdrGuestFeatureBits;\r
- UINT32 VhdrQueueAddress;\r
- UINT16 VhdrQueueSize;\r
- UINT16 VhdrQueueSelect;\r
- UINT16 VhdrQueueNotify;\r
- UINT8 VhdrDeviceStatus;\r
- UINT8 VhdrISR;\r
- UINT64 VhdrCapacity;\r
- UINT32 VhdrSizeMax;\r
- UINT32 VhdrSegMax;\r
- UINT16 VhdrCylinders;\r
- UINT8 VhdrHeads;\r
- UINT8 VhdrSectors;\r
- UINT32 VhdrBlkSize;\r
-} VBLK_HDR;\r
-#pragma pack()\r
-\r
-#define OFFSET_OF_VHDR(Field) ((UINTN)(UINT8 *)&((VBLK_HDR *) 0)->Field)\r
-#define SIZE_OF_VHDR(Field) (sizeof ((VBLK_HDR *) 0)->Field)\r
-\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
-// virtio-0.9.5, Appendix D: Block Device\r
-//\r
-#define VIRTIO_BLK_F_BARRIER BIT0\r
-#define VIRTIO_BLK_F_SIZE_MAX BIT1\r
-#define VIRTIO_BLK_F_SEG_MAX BIT2\r
-#define VIRTIO_BLK_F_GEOMETRY BIT4\r
-#define VIRTIO_BLK_F_RO BIT5\r
-#define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in\r
- // practice; actual host side implementation\r
- // negotiates "optimal" block size\r
- // separately\r
-#define VIRTIO_BLK_F_SCSI BIT7\r
-#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r
-\r
-\r
-//\r
-// We keep the status byte separate from the rest of the virtio-blk request\r
-// header. See description of historical scattering at the end of Appendix D:\r
-// we're going to put the status byte in a separate VRING_DESC.\r
-//\r
-#pragma pack(1)\r
-typedef struct {\r
- UINT32 Type;\r
- UINT32 IoPrio;\r
- UINT64 Sector;\r
-} VIRTIO_BLK_REQ;\r
-#pragma pack()\r
-\r
-#define VIRTIO_BLK_T_IN 0x00000000\r
-#define VIRTIO_BLK_T_OUT 0x00000001\r
-#define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r
-#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r
-#define VIRTIO_BLK_T_FLUSH 0x00000004\r
-#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r
-#define VIRTIO_BLK_T_BARRIER BIT31\r
-\r
-#define VIRTIO_BLK_S_OK 0x00\r
-#define VIRTIO_BLK_S_IOERR 0x01\r
-#define VIRTIO_BLK_S_UNSUPP 0x02\r
#include <Protocol/DriverBinding.h>\r
#include <Protocol/PciIo.h>\r
\r
-#include "Virtio.h"\r
+#include <IndustryStandard/Virtio.h>\r
\r
\r
#define VBLK_SIG SIGNATURE_32 ('V', 'B', 'L', 'K')\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
\r
[LibraryClasses]\r
BaseMemoryLib\r