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