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