• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   UINT32     NumQueues;
30   UINT32     SegMax;
31   UINT32     MaxSectors;
32   UINT32     CmdPerLun;
33   UINT32     EventInfoSize;
34   UINT32     SenseSize;
35   UINT32     CdbSize;
36   UINT16     MaxChannel;
37   UINT16     MaxTarget;
38   UINT32     MaxLun;
39 } VIRTIO_SCSI_CONFIG;
40 #pragma pack()
41 
42 #define OFFSET_OF_VSCSI(Field) OFFSET_OF (VIRTIO_SCSI_CONFIG, Field)
43 #define SIZE_OF_VSCSI(Field)   (sizeof ((VIRTIO_SCSI_CONFIG *) 0)->Field)
44 
45 #define VIRTIO_SCSI_F_INOUT   BIT0
46 #define VIRTIO_SCSI_F_HOTPLUG BIT1
47 
48 //
49 // We expect these maximum sizes from the host. Also we force the CdbLength and
50 // SenseDataLength parameters of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() not
51 // to exceed these limits. See UEFI 2.3.1 errata C 14.7.
52 //
53 #define VIRTIO_SCSI_CDB_SIZE   32
54 #define VIRTIO_SCSI_SENSE_SIZE 96
55 
56 //
57 // We pass the dynamically sized buffers ("dataout", "datain") in separate ring
58 // descriptors.
59 //
60 #pragma pack(1)
61 typedef struct {
62   UINT8  Lun[8];
63   UINT64 Id;
64   UINT8  TaskAttr;
65   UINT8  Prio;
66   UINT8  Crn;
67   UINT8  Cdb[VIRTIO_SCSI_CDB_SIZE];
68 } VIRTIO_SCSI_REQ;
69 
70 typedef struct {
71   UINT32 SenseLen;
72   UINT32 Residual;
73   UINT16 StatusQualifier;
74   UINT8  Status;
75   UINT8  Response;
76   UINT8  Sense[VIRTIO_SCSI_SENSE_SIZE];
77 } VIRTIO_SCSI_RESP;
78 #pragma pack()
79 
80 //
81 // selector of first virtio queue usable for request transfer
82 //
83 #define VIRTIO_SCSI_REQUEST_QUEUE 2
84 
85 //
86 // host response codes
87 //
88 #define VIRTIO_SCSI_S_OK                0
89 #define VIRTIO_SCSI_S_OVERRUN           1
90 #define VIRTIO_SCSI_S_ABORTED           2
91 #define VIRTIO_SCSI_S_BAD_TARGET        3
92 #define VIRTIO_SCSI_S_RESET             4
93 #define VIRTIO_SCSI_S_BUSY              5
94 #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
95 #define VIRTIO_SCSI_S_TARGET_FAILURE    7
96 #define VIRTIO_SCSI_S_NEXUS_FAILURE     8
97 #define VIRTIO_SCSI_S_FAILURE           9
98 
99 #endif // _VIRTIO_SCSI_H_
100