]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/IndustryStandard/VirtioBlk.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
b26f0cf9 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6b28fe9e 9\r
10**/\r
11\r
12#ifndef _VIRTIO_BLK_H_\r
13#define _VIRTIO_BLK_H_\r
14\r
15#include <IndustryStandard/Virtio.h>\r
16\r
6b28fe9e 17//\r
18// virtio-0.9.5, Appendix D: Block Device\r
19//\r
20#pragma pack(1)\r
5cf69d48 21typedef struct {\r
ac0a286f
MK
22 UINT8 PhysicalBlockExp; // # of logical blocks per physical block (log2)\r
23 UINT8 AlignmentOffset; // offset of first aligned logical block\r
24 UINT16 MinIoSize; // suggested minimum I/O size in blocks\r
25 UINT32 OptIoSize; // optimal (suggested maximum) I/O size in blocks\r
5cf69d48
LE
26} VIRTIO_BLK_TOPOLOGY;\r
27\r
6b28fe9e 28typedef struct {\r
ac0a286f
MK
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_TOPOLOGY Topology;\r
56f65ed8 37} VIRTIO_BLK_CONFIG;\r
6b28fe9e 38#pragma pack()\r
39\r
ac0a286f
MK
40#define OFFSET_OF_VBLK(Field) OFFSET_OF (VIRTIO_BLK_CONFIG, Field)\r
41#define SIZE_OF_VBLK(Field) (sizeof ((VIRTIO_BLK_CONFIG *) 0)->Field)\r
6b28fe9e 42\r
ac0a286f
MK
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
1d17076b
LE
49 // practice; actual host side\r
50 // implementation negotiates "optimal"\r
5cf69d48
LE
51 // block size separately, via\r
52 // VIRTIO_BLK_F_TOPOLOGY\r
ac0a286f
MK
53#define VIRTIO_BLK_F_SCSI BIT7\r
54#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r
55#define VIRTIO_BLK_F_TOPOLOGY BIT10 // information on optimal I/O alignment\r
6b28fe9e 56\r
57//\r
58// We keep the status byte separate from the rest of the virtio-blk request\r
59// header. See description of historical scattering at the end of Appendix D:\r
60// we're going to put the status byte in a separate VRING_DESC.\r
61//\r
62#pragma pack(1)\r
63typedef struct {\r
ac0a286f
MK
64 UINT32 Type;\r
65 UINT32 IoPrio;\r
66 UINT64 Sector;\r
6b28fe9e 67} VIRTIO_BLK_REQ;\r
68#pragma pack()\r
69\r
ac0a286f
MK
70#define VIRTIO_BLK_T_IN 0x00000000\r
71#define VIRTIO_BLK_T_OUT 0x00000001\r
72#define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r
73#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r
74#define VIRTIO_BLK_T_FLUSH 0x00000004\r
75#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r
76#define VIRTIO_BLK_T_BARRIER BIT31\r
6b28fe9e 77\r
ac0a286f
MK
78#define VIRTIO_BLK_S_OK 0x00\r
79#define VIRTIO_BLK_S_IOERR 0x01\r
80#define VIRTIO_BLK_S_UNSUPP 0x02\r
6b28fe9e 81\r
82#endif // _VIRTIO_BLK_H_\r