]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioBlk.h
OvmfPkg: Include/IndustryStandard: extract VirtioBlk.h from Virtio.h
[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
29 VIRTIO_HDR Generic;\r
30 UINT64 VhdrCapacity;\r
31 UINT32 VhdrSizeMax;\r
32 UINT32 VhdrSegMax;\r
33 UINT16 VhdrCylinders;\r
34 UINT8 VhdrHeads;\r
35 UINT8 VhdrSectors;\r
36 UINT32 VhdrBlkSize;\r
37} VBLK_HDR;\r
38#pragma pack()\r
39\r
40#define OFFSET_OF_VBLK(Field) OFFSET_OF (VBLK_HDR, Field)\r
41#define SIZE_OF_VBLK(Field) (sizeof ((VBLK_HDR *) 0)->Field)\r
42\r
43#define VIRTIO_BLK_F_BARRIER BIT0\r
44#define VIRTIO_BLK_F_SIZE_MAX BIT1\r
45#define VIRTIO_BLK_F_SEG_MAX BIT2\r
46#define VIRTIO_BLK_F_GEOMETRY BIT4\r
47#define VIRTIO_BLK_F_RO BIT5\r
48#define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in\r
49 // practice; actual host side implementation\r
50 // negotiates "optimal" block size\r
51 // separately\r
52#define VIRTIO_BLK_F_SCSI BIT7\r
53#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r
54\r
55//\r
56// We keep the status byte separate from the rest of the virtio-blk request\r
57// header. See description of historical scattering at the end of Appendix D:\r
58// we're going to put the status byte in a separate VRING_DESC.\r
59//\r
60#pragma pack(1)\r
61typedef struct {\r
62 UINT32 Type;\r
63 UINT32 IoPrio;\r
64 UINT64 Sector;\r
65} VIRTIO_BLK_REQ;\r
66#pragma pack()\r
67\r
68#define VIRTIO_BLK_T_IN 0x00000000\r
69#define VIRTIO_BLK_T_OUT 0x00000001\r
70#define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r
71#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r
72#define VIRTIO_BLK_T_FLUSH 0x00000004\r
73#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r
74#define VIRTIO_BLK_T_BARRIER BIT31\r
75\r
76#define VIRTIO_BLK_S_OK 0x00\r
77#define VIRTIO_BLK_S_IOERR 0x01\r
78#define VIRTIO_BLK_S_UNSUPP 0x02\r
79\r
80#endif // _VIRTIO_BLK_H_\r