]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Include/IndustryStandard: extract VirtioBlk.h from Virtio.h
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 12 Oct 2012 18:53:36 +0000 (18:53 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 12 Oct 2012 18:53:36 +0000 (18:53 +0000)
Separate virtio-blk related macro and type definitions from generic virtio
related ones. Adapt the virtio-blk driver since it needs the latter too.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13841 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/IndustryStandard/Virtio.h
OvmfPkg/Include/IndustryStandard/VirtioBlk.h [new file with mode: 0644]
OvmfPkg/VirtioBlkDxe/VirtioBlk.c

index a3307389991eb0e7cf043de4e9a2773c19d1dfcd..05c658fa548633acae7fe455695c2953a4ede4d8 100644 (file)
@@ -1,6 +1,7 @@
 /** @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-0.9.5\r
+  specification.\r
 \r
   Copyright (C) 2012, Red Hat, Inc.\r
 \r
@@ -108,25 +109,8 @@ typedef struct {
   UINT8  VhdrDeviceStatus;\r
   UINT8  VhdrISR;\r
 } VIRTIO_HDR;\r
-\r
-//\r
-// virtio-0.9.5, Appendix D: Block Device\r
-//\r
-typedef struct {\r
-  VIRTIO_HDR Generic;\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_VBLK(Field) OFFSET_OF (VBLK_HDR, Field)\r
-#define SIZE_OF_VBLK(Field)   (sizeof ((VBLK_HDR *) 0)->Field)\r
-\r
 \r
 //\r
 // virtio-0.9.5, 2.2.2.1 Device Status\r
@@ -143,45 +127,5 @@ typedef struct {
 #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
 \r
 #endif // _VIRTIO_H_\r
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioBlk.h b/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
new file mode 100644 (file)
index 0000000..b71f224
--- /dev/null
@@ -0,0 +1,80 @@
+/** @file\r
+\r
+  Virtio Block Device specific type and macro definitions corresponding to the\r
+  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
+#ifndef _VIRTIO_BLK_H_\r
+#define _VIRTIO_BLK_H_\r
+\r
+#include <IndustryStandard/Virtio.h>\r
+\r
+\r
+//\r
+// virtio-0.9.5, Appendix D: Block Device\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  VIRTIO_HDR Generic;\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_VBLK(Field) OFFSET_OF (VBLK_HDR, Field)\r
+#define SIZE_OF_VBLK(Field)   (sizeof ((VBLK_HDR *) 0)->Field)\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
+// 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
+\r
+#endif // _VIRTIO_BLK_H_\r
index 01a562d1655e1d9a5525cef83fef8d0c31ae9dff..ead98272a52800654460ff8ebeaae12e1aeaf7b2 100644 (file)
@@ -23,6 +23,7 @@
 **/\r
 \r
 #include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/VirtioBlk.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r