]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Include/IndustryStandard/Virtio.h
OvmfPkg/MemEncryptSevLib: find pages of initial SMRAM save state map
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / Virtio.h
index 600d3d272b6a1865d5a348b1a91517415b6351d0..dddec388318e6274c3123aaaef6346a516c2eded 100644 (file)
@@ -1,8 +1,10 @@
 /** @file\r
 \r
-  Type and macro definitions corresponding to the virtio-0.9.5 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
   under the terms and conditions of the BSD License which accompanies this\r
 #ifndef _VIRTIO_H_\r
 #define _VIRTIO_H_\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) OFFSET_OF (VBLK_HDR, 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 <IndustryStandard/Virtio10.h>\r
 \r
 #endif // _VIRTIO_H_\r