]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioBlk.h
OvmfPkg: Make the VirtIo devices use the new VIRTIO_DEVICE_PROTOCOL
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / VirtioBlk.h
CommitLineData
6b28fe9e 1/** @file\r
2\r
3 Virtio Block Device specific type and macro definitions corresponding to the\r
4 virtio-0.9.5 specification.\r
5\r
6 Copyright (C) 2012, Red Hat, Inc.\r
7\r
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _VIRTIO_BLK_H_\r
19#define _VIRTIO_BLK_H_\r
20\r
21#include <IndustryStandard/Virtio.h>\r
22\r
23\r
24//\r
25// virtio-0.9.5, Appendix D: Block Device\r
26//\r
27#pragma pack(1)\r
28typedef struct {\r
56f65ed8
OM
29 UINT64 Capacity;\r
30 UINT32 SizeMax;\r
31 UINT32 SegMax;\r
32 UINT16 Cylinders;\r
33 UINT8 Heads;\r
34 UINT8 Sectors;\r
35 UINT32 BlkSize;\r
36} VIRTIO_BLK_CONFIG;\r
6b28fe9e 37#pragma pack()\r
38\r
56f65ed8
OM
39#define OFFSET_OF_VBLK(Field) OFFSET_OF (VIRTIO_BLK_CONFIG, Field)\r
40#define SIZE_OF_VBLK(Field) (sizeof ((VIRTIO_BLK_CONFIG *) 0)->Field)\r
6b28fe9e 41\r
42#define VIRTIO_BLK_F_BARRIER BIT0\r
43#define VIRTIO_BLK_F_SIZE_MAX BIT1\r
44#define VIRTIO_BLK_F_SEG_MAX BIT2\r
45#define VIRTIO_BLK_F_GEOMETRY BIT4\r
46#define VIRTIO_BLK_F_RO BIT5\r
47#define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in\r
48 // practice; actual host side implementation\r
49 // negotiates "optimal" block size\r
50 // separately\r
51#define VIRTIO_BLK_F_SCSI BIT7\r
52#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r
53\r
54//\r
55// We keep the status byte separate from the rest of the virtio-blk request\r
56// header. See description of historical scattering at the end of Appendix D:\r
57// we're going to put the status byte in a separate VRING_DESC.\r
58//\r
59#pragma pack(1)\r
60typedef struct {\r
61 UINT32 Type;\r
62 UINT32 IoPrio;\r
63 UINT64 Sector;\r
64} VIRTIO_BLK_REQ;\r
65#pragma pack()\r
66\r
67#define VIRTIO_BLK_T_IN 0x00000000\r
68#define VIRTIO_BLK_T_OUT 0x00000001\r
69#define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r
70#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r
71#define VIRTIO_BLK_T_FLUSH 0x00000004\r
72#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r
73#define VIRTIO_BLK_T_BARRIER BIT31\r
74\r
75#define VIRTIO_BLK_S_OK 0x00\r
76#define VIRTIO_BLK_S_IOERR 0x01\r
77#define VIRTIO_BLK_S_UNSUPP 0x02\r
78\r
79#endif // _VIRTIO_BLK_H_\r