]>
Commit | Line | Data |
---|---|---|
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 | |
17 | \r | |
18 | //\r | |
19 | // virtio-0.9.5, Appendix D: Block Device\r | |
20 | //\r | |
21 | #pragma pack(1)\r | |
5cf69d48 LE |
22 | typedef struct {\r |
23 | UINT8 PhysicalBlockExp; // # of logical blocks per physical block (log2)\r | |
24 | UINT8 AlignmentOffset; // offset of first aligned logical block\r | |
25 | UINT16 MinIoSize; // suggested minimum I/O size in blocks\r | |
26 | UINT32 OptIoSize; // optimal (suggested maximum) I/O size in blocks\r | |
27 | } VIRTIO_BLK_TOPOLOGY;\r | |
28 | \r | |
6b28fe9e | 29 | typedef struct {\r |
1d17076b LE |
30 | UINT64 Capacity;\r |
31 | UINT32 SizeMax;\r | |
32 | UINT32 SegMax;\r | |
33 | UINT16 Cylinders;\r | |
34 | UINT8 Heads;\r | |
35 | UINT8 Sectors;\r | |
36 | UINT32 BlkSize;\r | |
5cf69d48 | 37 | VIRTIO_BLK_TOPOLOGY Topology;\r |
56f65ed8 | 38 | } VIRTIO_BLK_CONFIG;\r |
6b28fe9e | 39 | #pragma pack()\r |
40 | \r | |
56f65ed8 OM |
41 | #define OFFSET_OF_VBLK(Field) OFFSET_OF (VIRTIO_BLK_CONFIG, Field)\r |
42 | #define SIZE_OF_VBLK(Field) (sizeof ((VIRTIO_BLK_CONFIG *) 0)->Field)\r | |
6b28fe9e | 43 | \r |
44 | #define VIRTIO_BLK_F_BARRIER BIT0\r | |
45 | #define VIRTIO_BLK_F_SIZE_MAX BIT1\r | |
46 | #define VIRTIO_BLK_F_SEG_MAX BIT2\r | |
47 | #define VIRTIO_BLK_F_GEOMETRY BIT4\r | |
48 | #define VIRTIO_BLK_F_RO BIT5\r | |
1d17076b LE |
49 | #define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in\r |
50 | // practice; actual host side\r | |
51 | // implementation negotiates "optimal"\r | |
5cf69d48 LE |
52 | // block size separately, via\r |
53 | // VIRTIO_BLK_F_TOPOLOGY\r | |
6b28fe9e | 54 | #define VIRTIO_BLK_F_SCSI BIT7\r |
1d17076b | 55 | #define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"\r |
5cf69d48 | 56 | #define VIRTIO_BLK_F_TOPOLOGY BIT10 // information on optimal I/O alignment\r |
6b28fe9e | 57 | \r |
58 | //\r | |
59 | // We keep the status byte separate from the rest of the virtio-blk request\r | |
60 | // header. See description of historical scattering at the end of Appendix D:\r | |
61 | // we're going to put the status byte in a separate VRING_DESC.\r | |
62 | //\r | |
63 | #pragma pack(1)\r | |
64 | typedef struct {\r | |
65 | UINT32 Type;\r | |
66 | UINT32 IoPrio;\r | |
67 | UINT64 Sector;\r | |
68 | } VIRTIO_BLK_REQ;\r | |
69 | #pragma pack()\r | |
70 | \r | |
71 | #define VIRTIO_BLK_T_IN 0x00000000\r | |
72 | #define VIRTIO_BLK_T_OUT 0x00000001\r | |
73 | #define VIRTIO_BLK_T_SCSI_CMD 0x00000002\r | |
74 | #define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003\r | |
75 | #define VIRTIO_BLK_T_FLUSH 0x00000004\r | |
76 | #define VIRTIO_BLK_T_FLUSH_OUT 0x00000005\r | |
77 | #define VIRTIO_BLK_T_BARRIER BIT31\r | |
78 | \r | |
79 | #define VIRTIO_BLK_S_OK 0x00\r | |
80 | #define VIRTIO_BLK_S_IOERR 0x01\r | |
81 | #define VIRTIO_BLK_S_UNSUPP 0x02\r | |
82 | \r | |
83 | #endif // _VIRTIO_BLK_H_\r |