]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/ScsiIo.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiIo.h
CommitLineData
d1f95000 1/** @file\r
2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.\r
9095d37b
LG
3 This protocol is used by code, typically drivers, running in the EFI boot\r
4 services environment to access SCSI devices. In particular, functions for\r
4ca9b6c4 5 managing devices on SCSI buses are defined here.\r
d1f95000 6\r
9095d37b 7 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d1f95000 9\r
d1f95000 10**/\r
11\r
12#ifndef __EFI_SCSI_IO_PROTOCOL_H__\r
13#define __EFI_SCSI_IO_PROTOCOL_H__\r
14\r
15#define EFI_SCSI_IO_PROTOCOL_GUID \\r
16 { \\r
eecd469b 17 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \\r
d1f95000 18 }\r
19\r
99e8ed21 20///\r
21/// Forward reference for pure ANSI compatability\r
22///\r
d1f95000 23typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;\r
24\r
754739ec
FT
25//\r
26// SCSI Device type information, defined in the SCSI Primary Commands standard (e.g., SPC-4)\r
27//\r
28#define EFI_SCSI_IO_TYPE_DISK 0x00 ///< Disk device\r
29#define EFI_SCSI_IO_TYPE_TAPE 0x01 ///< Tape device\r
30#define EFI_SCSI_IO_TYPE_PRINTER 0x02 ///< Printer\r
31#define EFI_SCSI_IO_TYPE_PROCESSOR 0x03 ///< Processor\r
32#define EFI_SCSI_IO_TYPE_WORM 0x04 ///< Write-once read-multiple\r
33#define EFI_SCSI_IO_TYPE_CDROM 0x05 ///< CD or DVD device\r
34#define EFI_SCSI_IO_TYPE_SCANNER 0x06 ///< Scanner device\r
35#define EFI_SCSI_IO_TYPE_OPTICAL 0x07 ///< Optical memory device\r
36#define EFI_SCSI_IO_TYPE_MEDIUMCHANGER 0x08 ///< Medium Changer device\r
37#define EFI_SCSI_IO_TYPE_COMMUNICATION 0x09 ///< Communications device\r
38#define MFI_SCSI_IO_TYPE_A 0x0A ///< Obsolete\r
39#define MFI_SCSI_IO_TYPE_B 0x0B ///< Obsolete\r
40#define MFI_SCSI_IO_TYPE_RAID 0x0C ///< Storage array controller device (e.g., RAID)\r
41#define MFI_SCSI_IO_TYPE_SES 0x0D ///< Enclosure services device\r
42#define MFI_SCSI_IO_TYPE_RBC 0x0E ///< Simplified direct-access device (e.g., magnetic disk)\r
43#define MFI_SCSI_IO_TYPE_OCRW 0x0F ///< Optical card reader/writer device\r
44#define MFI_SCSI_IO_TYPE_BRIDGE 0x10 ///< Bridge Controller Commands\r
45#define MFI_SCSI_IO_TYPE_OSD 0x11 ///< Object-based Storage Device\r
46#define EFI_SCSI_IO_TYPE_RESERVED_LOW 0x12 ///< Reserved (low)\r
47#define EFI_SCSI_IO_TYPE_RESERVED_HIGH 0x1E ///< Reserved (high)\r
48#define EFI_SCSI_IO_TYPE_UNKNOWN 0x1F ///< Unknown no device type\r
49\r
d1f95000 50//\r
51// SCSI Data Direction definition\r
52//\r
53#define EFI_SCSI_IO_DATA_DIRECTION_READ 0\r
54#define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1\r
55#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2\r
56\r
57//\r
58// SCSI Host Adapter Status definition\r
59//\r
60#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00\r
992f22b9
LG
61#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 ///< timeout when processing the command\r
62#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b ///< timeout when waiting for the command processing\r
63#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d ///< a message reject was received when processing command\r
64#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e ///< a bus reset was detected\r
d1f95000 65#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f\r
992f22b9
LG
66#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 ///< the adapter failed in issuing request sense command\r
67#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 ///< selection timeout\r
68#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 ///< data overrun or data underrun\r
69#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 ///< Unexepected bus free\r
70#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 ///< Target bus phase sequence failure\r
d1f95000 71#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f\r
72\r
73\r
74//\r
75// SCSI Target Status definition\r
76//\r
77#define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00\r
992f22b9
LG
78#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 ///< check condition\r
79#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 ///< condition met\r
80#define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 ///< busy\r
81#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 ///< intermediate\r
82#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 ///< intermediate-condition met\r
83#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 ///< reservation conflict\r
84#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 ///< command terminated\r
85#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 ///< queue full\r
d1f95000 86\r
87typedef struct {\r
992f22b9
LG
88 ///\r
89 /// The timeout, in 100 ns units, to use for the execution of this SCSI\r
90 /// Request Packet. A Timeout value of 0 means that this function\r
91 /// will wait indefinitely for the SCSI Request Packet to execute. If\r
92 /// Timeout is greater than zero, then this function will return\r
93 /// EFI_TIMEOUT if the time required to execute the SCSI Request\r
94 /// Packet is greater than Timeout.\r
95 ///\r
d1f95000 96 UINT64 Timeout;\r
992f22b9
LG
97 ///\r
98 /// A pointer to the data buffer to transfer between the SCSI\r
99 /// controller and the SCSI device for SCSI READ command\r
100 ///\r
d1f95000 101 VOID *InDataBuffer;\r
992f22b9
LG
102 ///\r
103 /// A pointer to the data buffer to transfer between the SCSI\r
104 /// controller and the SCSI device for SCSI WRITE command.\r
105 ///\r
d1f95000 106 VOID *OutDataBuffer;\r
992f22b9
LG
107 ///\r
108 /// A pointer to the sense data that was generated by the execution of\r
109 /// the SCSI Request Packet.\r
110 ///\r
d1f95000 111 VOID *SenseData;\r
992f22b9
LG
112 ///\r
113 /// A pointer to buffer that contains the Command Data Block to\r
114 /// send to the SCSI device.\r
115 ///\r
d1f95000 116 VOID *Cdb;\r
992f22b9
LG
117 ///\r
118 /// On Input, the size, in bytes, of InDataBuffer. On output, the\r
119 /// number of bytes transferred between the SCSI controller and the SCSI device.\r
120 ///\r
d1f95000 121 UINT32 InTransferLength;\r
992f22b9
LG
122 ///\r
123 /// On Input, the size, in bytes of OutDataBuffer. On Output, the\r
124 /// Number of bytes transferred between SCSI Controller and the SCSI device.\r
125 ///\r
d1f95000 126 UINT32 OutTransferLength;\r
992f22b9
LG
127 ///\r
128 /// The length, in bytes, of the buffer Cdb. The standard values are\r
129 /// 6, 10, 12, and 16, but other values are possible if a variable length CDB is used.\r
130 ///\r
d1f95000 131 UINT8 CdbLength;\r
992f22b9
LG
132 ///\r
133 /// The direction of the data transfer. 0 for reads, 1 for writes. A\r
134 /// value of 2 is Reserved for Bi-Directional SCSI commands.\r
135 ///\r
d1f95000 136 UINT8 DataDirection;\r
992f22b9
LG
137 ///\r
138 /// The status of the SCSI Host Controller that produces the SCSI\r
139 /// bus where the SCSI device attached when the SCSI Request\r
140 /// Packet was executed on the SCSI Controller.\r
141 ///\r
d1f95000 142 UINT8 HostAdapterStatus;\r
992f22b9
LG
143 ///\r
144 /// The status returned by the SCSI device when the SCSI Request\r
145 /// Packet was executed.\r
146 ///\r
d1f95000 147 UINT8 TargetStatus;\r
992f22b9
LG
148 ///\r
149 /// On input, the length in bytes of the SenseData buffer. On\r
150 /// output, the number of bytes written to the SenseData buffer.\r
151 ///\r
d1f95000 152 UINT8 SenseDataLength;\r
153} EFI_SCSI_IO_SCSI_REQUEST_PACKET;\r
154\r
155/**\r
156 Retrieves the device type information of the SCSI Controller.\r
157\r
158 @param This Protocol instance pointer.\r
159 @param DeviceType A pointer to the device type information\r
160 retrieved from the SCSI Controller.\r
161\r
630b4187 162 @retval EFI_SUCCESS Retrieved the device type information successfully.\r
d1f95000 163 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.\r
164\r
165**/\r
166typedef\r
167EFI_STATUS\r
8b13229b 168(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE)(\r
d1f95000 169 IN EFI_SCSI_IO_PROTOCOL *This,\r
170 OUT UINT8 *DeviceType\r
ed66e1bc 171 );\r
d1f95000 172\r
173/**\r
174 Retrieves the device location in the SCSI channel.\r
175\r
176 @param This Protocol instance pointer.\r
177 @param Target A pointer to the Target ID of a SCSI device\r
178 on the SCSI channel.\r
179 @param Lun A pointer to the LUN of the SCSI device on\r
180 the SCSI channel.\r
181\r
182 @retval EFI_SUCCESS Retrieves the device location successfully.\r
183 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL.\r
184\r
185**/\r
186typedef\r
187EFI_STATUS\r
8b13229b 188(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION)(\r
d1f95000 189 IN EFI_SCSI_IO_PROTOCOL *This,\r
190 IN OUT UINT8 **Target,\r
191 OUT UINT64 *Lun\r
ed66e1bc 192 );\r
d1f95000 193\r
194/**\r
195 Resets the SCSI Bus that the SCSI Controller is attached to.\r
196\r
197 @param This Protocol instance pointer.\r
198\r
199 @retval EFI_SUCCESS The SCSI bus is reset successfully.\r
200 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.\r
201 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the\r
202 SCSI Host Controller.\r
203 @retval EFI_TIMEOUT A timeout occurred while attempting to reset\r
204 the SCSI bus.\r
205\r
206**/\r
207typedef\r
208EFI_STATUS\r
8b13229b 209(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS)(\r
d1f95000 210 IN EFI_SCSI_IO_PROTOCOL *This\r
ed66e1bc 211 );\r
d1f95000 212\r
213/**\r
214 Resets the SCSI Controller that the device handle specifies.\r
215\r
216 @param This Protocol instance pointer.\r
217\r
218 @retval EFI_SUCCESS Reset the SCSI controller successfully.\r
630b4187 219 @retval EFI_DEVICE_ERROR Errors were encountered when resetting the\r
d1f95000 220 SCSI Controller.\r
221 @retval EFI_UNSUPPORTED The SCSI bus does not support a device\r
222 reset operation.\r
223 @retval EFI_TIMEOUT A timeout occurred while attempting to\r
224 reset the SCSI Controller.\r
225\r
226**/\r
227typedef\r
228EFI_STATUS\r
8b13229b 229(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE)(\r
d1f95000 230 IN EFI_SCSI_IO_PROTOCOL *This\r
ed66e1bc 231 );\r
d1f95000 232\r
233\r
234/**\r
235 Sends a SCSI Request Packet to the SCSI Controller for execution.\r
236\r
237 @param This Protocol instance pointer.\r
238 @param Packet The SCSI request packet to send to the SCSI\r
239 Controller specified by the device handle.\r
630b4187 240 @param Event If the SCSI bus to which the SCSI device is attached\r
d1f95000 241 does not support non-blocking I/O, then Event is\r
242 ignored, and blocking I/O is performed.\r
243 If Event is NULL, then blocking I/O is performed.\r
244 If Event is not NULL and non-blocking I/O is\r
245 supported, then non-blocking I/O is performed,\r
246 and Event will be signaled when the SCSI Request\r
247 Packet completes.\r
248\r
249 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host\r
250 successfully, and TransferLength bytes were\r
630b4187 251 transferred to/from DataBuffer. See\r
d1f95000 252 HostAdapterStatus, TargetStatus,\r
253 SenseDataLength, and SenseData in that order\r
254 for additional status information.\r
c7a54f25 255 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,\r
d1f95000 256 but the entire DataBuffer could not be transferred.\r
257 The actual number of bytes transferred is returned\r
258 in TransferLength. See HostAdapterStatus,\r
259 TargetStatus, SenseDataLength, and SenseData in\r
260 that order for additional status information.\r
261 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
262 there are too many SCSI Command Packets already\r
263 queued.The caller may retry again later.\r
264 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
265 the SCSI Request Packet. See HostAdapterStatus,\r
266 TargetStatus, SenseDataLength, and SenseData in\r
267 that order for additional status information.\r
268 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.\r
269 The SCSI Request Packet was not sent, so no\r
270 additional status information is available.\r
271 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
272 is not supported by the SCSI initiator(i.e., SCSI\r
273 Host Controller). The SCSI Request Packet was not\r
274 sent, so no additional status information is\r
275 available.\r
276 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI\r
277 Request Packet to execute. See HostAdapterStatus,\r
278 TargetStatus, SenseDataLength, and SenseData in\r
279 that order for additional status information.\r
280\r
281**/\r
282typedef\r
283EFI_STATUS\r
8b13229b 284(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND)(\r
d1f95000 285 IN EFI_SCSI_IO_PROTOCOL *This,\r
286 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet,\r
287 IN EFI_EVENT Event OPTIONAL\r
ed66e1bc 288 );\r
d1f95000 289\r
44717a39 290///\r
291/// Provides services to manage and communicate with SCSI devices.\r
292///\r
d1f95000 293struct _EFI_SCSI_IO_PROTOCOL {\r
294 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType;\r
295 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation;\r
296 EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus;\r
297 EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice;\r
9095d37b 298 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand;\r
1f08a159 299\r
300 ///\r
9095d37b
LG
301 /// Supplies the alignment requirement for any buffer used in a data transfer.\r
302 /// IoAlign values of 0 and 1 mean that the buffer can be placed anywhere in memory.\r
303 /// Otherwise, IoAlign must be a power of 2, and the requirement is that the\r
1f08a159 304 /// start address of a buffer must be evenly divisible by IoAlign with no remainder.\r
305 ///\r
d1f95000 306 UINT32 IoAlign;\r
307};\r
308\r
309extern EFI_GUID gEfiScsiIoProtocolGuid;\r
310\r
311#endif\r