]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/IndustryStandard/VirtioScsi.h
59ce97e070fbe5b322e9b29e288ca11ea99d922c
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / VirtioScsi.h
1 /** @file
2
3 Virtio SCSI Host Device specific type and macro definitions corresponding to
4 the 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_SCSI_H_
19 #define _VIRTIO_SCSI_H_
20
21 #include <IndustryStandard/Virtio.h>
22
23
24 //
25 // virtio-0.9.5, Appendix I: SCSI Host Device
26 //
27 #pragma pack(1)
28 typedef struct {
29 VIRTIO_HDR Generic;
30 UINT32 VhdrNumQueues;
31 UINT32 VhdrSegMax;
32 UINT32 VhdrMaxSectors;
33 UINT32 VhdrCmdPerLun;
34 UINT32 VhdrEventInfoSize;
35 UINT32 VhdrSenseSize;
36 UINT32 VhdrCdbSize;
37 UINT16 VhdrMaxChannel;
38 UINT16 VhdrMaxTarget;
39 UINT32 VhdrMaxLun;
40 } VSCSI_HDR;
41 #pragma pack()
42
43 #define OFFSET_OF_VSCSI(Field) OFFSET_OF (VSCSI_HDR, Field)
44 #define SIZE_OF_VSCSI(Field) (sizeof ((VSCSI_HDR *) 0)->Field)
45
46 #define VIRTIO_SCSI_F_INOUT BIT0
47 #define VIRTIO_SCSI_F_HOTPLUG BIT1
48
49 //
50 // We expect these maximum sizes from the host. Also we force the CdbLength and
51 // SenseDataLength parameters of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() not
52 // to exceed these limits. See UEFI 2.3.1 errata C 14.7.
53 //
54 #define VIRTIO_SCSI_CDB_SIZE 32
55 #define VIRTIO_SCSI_SENSE_SIZE 96
56
57 //
58 // We pass the dynamically sized buffers ("dataout", "datain") in separate ring
59 // descriptors.
60 //
61 #pragma pack(1)
62 typedef struct {
63 UINT8 Lun[8];
64 UINT64 Id;
65 UINT8 TaskAttr;
66 UINT8 Prio;
67 UINT8 Crn;
68 UINT8 Cdb[VIRTIO_SCSI_CDB_SIZE];
69 } VIRTIO_SCSI_REQ;
70
71 typedef struct {
72 UINT32 SenseLen;
73 UINT32 Residual;
74 UINT16 StatusQualifier;
75 UINT8 Status;
76 UINT8 Response;
77 UINT8 Sense[VIRTIO_SCSI_SENSE_SIZE];
78 } VIRTIO_SCSI_RESP;
79 #pragma pack()
80
81 //
82 // selector of first virtio queue usable for request transfer
83 //
84 #define VIRTIO_SCSI_REQUEST_QUEUE 2
85
86 //
87 // host response codes
88 //
89 #define VIRTIO_SCSI_S_OK 0
90 #define VIRTIO_SCSI_S_OVERRUN 1
91 #define VIRTIO_SCSI_S_ABORTED 2
92 #define VIRTIO_SCSI_S_BAD_TARGET 3
93 #define VIRTIO_SCSI_S_RESET 4
94 #define VIRTIO_SCSI_S_BUSY 5
95 #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
96 #define VIRTIO_SCSI_S_TARGET_FAILURE 7
97 #define VIRTIO_SCSI_S_NEXUS_FAILURE 8
98 #define VIRTIO_SCSI_S_FAILURE 9
99
100 #endif // _VIRTIO_SCSI_H_