]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/ScsiPassThru.h
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiPassThru.h
CommitLineData
d1f95000 1/** @file\r
4ca9b6c4 2 SCSI Pass Through protocol as defined in EFI 1.1.\r
9095d37b 3 This protocol allows information about a SCSI channel to be collected,\r
4ca9b6c4 4 and allows SCSI Request Packets to be sent to any SCSI devices on a SCSI\r
9095d37b
LG
5 channel even if those devices are not boot devices. This protocol is attached\r
6 to the device handle of each SCSI channel in a system that the protocol\r
7 supports, and can be used for diagnostics. It may also be used to build\r
4ca9b6c4
LG
8 a Block I/O driver for SCSI hard drives and SCSI CD-ROM or DVD drives to\r
9 allow those devices to become boot devices.\r
10\r
9095d37b 11 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 12 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d1f95000 13\r
d1f95000 14**/\r
15\r
16#ifndef __SCSI_PASS_THROUGH_H__\r
17#define __SCSI_PASS_THROUGH_H__\r
18\r
19#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \\r
20 { \\r
21 0xa59e8fcf, 0xbda0, 0x43bb, {0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77 } \\r
22 }\r
23\r
99e8ed21 24///\r
25/// Forward reference for pure ANSI compatability\r
26///\r
2f88bd3a 27typedef struct _EFI_SCSI_PASS_THRU_PROTOCOL EFI_SCSI_PASS_THRU_PROTOCOL;\r
d1f95000 28\r
29#define EFI_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001\r
30#define EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002\r
31#define EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004\r
32\r
33//\r
34// SCSI Host Adapter Status definition\r
35//\r
36#define EFI_SCSI_STATUS_HOST_ADAPTER_OK 0x00\r
37#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command\r
38#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing\r
39#define EFI_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command\r
40#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected\r
41#define EFI_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f\r
42#define EFI_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command\r
43#define EFI_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout\r
44#define EFI_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun\r
45#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free\r
46#define EFI_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure\r
47#define EFI_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f\r
48\r
49//\r
50// SCSI Target Status definition\r
51//\r
2f88bd3a
MK
52#define EFI_SCSI_STATUS_TARGET_GOOD 0x00\r
53#define EFI_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition\r
54#define EFI_SCSI_STATUS_TARGET_CONDITION_MET 0x04 // condition met\r
55#define EFI_SCSI_STATUS_TARGET_BUSY 0x08 // busy\r
56#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate\r
57#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met\r
58#define EFI_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict\r
59#define EFI_SCSI_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated\r
60#define EFI_SCSI_STATUS_TARGET_QUEUE_FULL 0x28 // queue full\r
d1f95000 61\r
62typedef struct {\r
992f22b9
LG
63 ///\r
64 /// The timeout, in 100 ns units, to use for the execution of this SCSI\r
65 /// Request Packet. A Timeout value of 0 means that this function\r
66 /// will wait indefinitely for the SCSI Request Packet to execute. If\r
67 /// Timeout is greater than zero, then this function will return\r
68 /// EFI_TIMEOUT if the time required to execute the SCSI Request\r
69 /// Packet is greater than Timeout.\r
70 ///\r
2f88bd3a 71 UINT64 Timeout;\r
992f22b9
LG
72 ///\r
73 /// A pointer to the data buffer to transfer between the SCSI\r
74 /// controller and the SCSI device. Must be aligned to the boundary\r
75 /// specified in the IoAlign field of the\r
76 /// EFI_SCSI_PASS_THRU_MODE structure.\r
77 ///\r
2f88bd3a 78 VOID *DataBuffer;\r
992f22b9
LG
79 ///\r
80 /// A pointer to the sense data that was generated by the execution of\r
81 /// the SCSI Request Packet.\r
82 ///\r
2f88bd3a 83 VOID *SenseData;\r
992f22b9
LG
84 ///\r
85 /// A pointer to buffer that contains the Command Data Block to\r
86 /// send to the SCSI device.\r
87 ///\r
2f88bd3a 88 VOID *Cdb;\r
992f22b9
LG
89 ///\r
90 /// On Input, the size, in bytes, of InDataBuffer. On output, the\r
91 /// number of bytes transferred between the SCSI controller and the SCSI device.\r
92 ///\r
2f88bd3a 93 UINT32 TransferLength;\r
992f22b9
LG
94 ///\r
95 /// The length, in bytes, of the buffer Cdb. The standard values are\r
96 /// 6, 10, 12, and 16, but other values are possible if a variable length CDB is used.\r
97 ///\r
2f88bd3a 98 UINT8 CdbLength;\r
992f22b9
LG
99 ///\r
100 /// The direction of the data transfer. 0 for reads, 1 for writes. A\r
101 /// value of 2 is Reserved for Bi-Directional SCSI commands.\r
102 ///\r
2f88bd3a 103 UINT8 DataDirection;\r
992f22b9
LG
104 ///\r
105 /// The status of the SCSI Host Controller that produces the SCSI\r
106 /// bus where the SCSI device attached when the SCSI Request\r
107 /// Packet was executed on the SCSI Controller.\r
108 ///\r
2f88bd3a 109 UINT8 HostAdapterStatus;\r
992f22b9
LG
110 ///\r
111 /// The status returned by the SCSI device when the SCSI Request\r
112 /// Packet was executed.\r
113 ///\r
2f88bd3a 114 UINT8 TargetStatus;\r
992f22b9
LG
115 ///\r
116 /// On input, the length in bytes of the SenseData buffer. On\r
117 /// output, the number of bytes written to the SenseData buffer.\r
118 ///\r
2f88bd3a 119 UINT8 SenseDataLength;\r
d1f95000 120} EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;\r
121\r
122typedef struct {\r
992f22b9
LG
123 ///\r
124 /// A Null-terminated Unicode string that represents the printable name of the SCSI controller.\r
125 ///\r
2f88bd3a 126 CHAR16 *ControllerName;\r
992f22b9
LG
127 ///\r
128 /// A Null-terminated Unicode string that represents the printable name of the SCSI channel.\r
129 ///\r
2f88bd3a 130 CHAR16 *ChannelName;\r
992f22b9
LG
131 ///\r
132 /// The Target ID of the host adapter on the SCSI channel.\r
133 ///\r
2f88bd3a 134 UINT32 AdapterId;\r
992f22b9
LG
135 ///\r
136 /// Additional information on the attributes of the SCSI channel.\r
137 ///\r
2f88bd3a 138 UINT32 Attributes;\r
992f22b9
LG
139 ///\r
140 /// Supplies the alignment requirement for any buffer used in a data transfer.\r
141 ///\r
2f88bd3a 142 UINT32 IoAlign;\r
d1f95000 143} EFI_SCSI_PASS_THRU_MODE;\r
144\r
145/**\r
9095d37b
LG
146 Sends a SCSI Request Packet to a SCSI device that is attached to\r
147 the SCSI channel. This function supports both blocking I/O and\r
148 non-blocking I/O. The blocking I/O functionality is required,\r
d1f95000 149 and the non-blocking I/O functionality is optional.\r
150\r
151 @param This Protocol instance pointer.\r
152 @param Target The Target ID of the SCSI device to\r
153 send the SCSI Request Packet.\r
154 @param Lun The LUN of the SCSI device to send the\r
155 SCSI Request Packet.\r
156 @param Packet A pointer to the SCSI Request Packet to send\r
157 to the SCSI device specified by Target and Lun.\r
158 @param Event If non-blocking I/O is not supported then Event\r
159 is ignored, and blocking I/O is performed.\r
160 If Event is NULL, then blocking I/O is performed.\r
161 If Event is not NULL and non blocking I/O is\r
162 supported, then non-blocking I/O is performed,\r
163 and Event will be signaled when the SCSI Request\r
164 Packet completes\r
165\r
166 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host, and\r
167 TransferLength bytes were transferred to/from\r
630b4187 168 DataBuffer. See HostAdapterStatus, TargetStatus,\r
169 SenseDataLength, and SenseData in that order\r
d1f95000 170 for additional status information.\r
c7a54f25 171 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the\r
d1f95000 172 entire DataBuffer could not be transferred.\r
173 The actual number of bytes transferred is returned\r
174 in TransferLength. See HostAdapterStatus,\r
175 TargetStatus, SenseDataLength, and SenseData in\r
176 that order for additional status information.\r
177 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
178 there are too many SCSI Request Packets already\r
179 queued. The caller may retry again later.\r
180 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
181 the SCSI Request Packet. See HostAdapterStatus,\r
182 TargetStatus, SenseDataLength, and SenseData in\r
183 that order for additional status information.\r
184 @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket\r
185 are invalid. The SCSI Request Packet was not sent,\r
186 so no additional status information is available.\r
187 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
188 is not supported by the host adapter. The SCSI\r
189 Request Packet was not sent, so no additional\r
190 status information is available.\r
191 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI\r
192 Request Packet to execute. See HostAdapterStatus,\r
193 TargetStatus, SenseDataLength, and SenseData in\r
194 that order for additional status information.\r
9095d37b 195\r
d1f95000 196**/\r
197typedef\r
198EFI_STATUS\r
8b13229b 199(EFIAPI *EFI_SCSI_PASS_THRU_PASSTHRU)(\r
d1f95000 200 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,\r
201 IN UINT32 Target,\r
202 IN UINT64 Lun,\r
203 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,\r
204 IN EFI_EVENT Event OPTIONAL\r
ed66e1bc 205 );\r
d1f95000 206\r
207/**\r
9095d37b 208 Used to retrieve the list of legal Target IDs for SCSI devices\r
d1f95000 209 on a SCSI channel.\r
210\r
211 @param This Protocol instance pointer.\r
212 @param Target On input, a pointer to the Target ID of a\r
213 SCSI device present on the SCSI channel.\r
214 On output, a pointer to the Target ID of\r
215 the next SCSI device present on a SCSI channel.\r
216 An input value of 0xFFFFFFFF retrieves the\r
217 Target ID of the first SCSI device present on\r
218 a SCSI channel.\r
219 @param Lun On input, a pointer to the LUN of a SCSI device\r
630b4187 220 present on the SCSI channel. On output, a pointer\r
d1f95000 221 to the LUN of the next SCSI device present on a\r
222 SCSI channel.\r
223\r
224 @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI\r
225 channel was returned in Target and Lun.\r
226 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.\r
227 @retval EFI_INVALID_PARAMETER Target is not 0xFFFFFFFF, and Target and Lun were\r
228 not returned on a previous call to GetNextDevice().\r
229\r
230**/\r
231typedef\r
232EFI_STATUS\r
8b13229b 233(EFIAPI *EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE)(\r
d1f95000 234 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,\r
235 IN OUT UINT32 *Target,\r
236 IN OUT UINT64 *Lun\r
ed66e1bc 237 );\r
d1f95000 238\r
239/**\r
9095d37b 240 Used to allocate and build a device path node for a SCSI device\r
d1f95000 241 on a SCSI channel.\r
242\r
243 @param This Protocol instance pointer.\r
244 @param Target The Target ID of the SCSI device for which\r
245 a device path node is to be allocated and built.\r
246 @param Lun The LUN of the SCSI device for which a device\r
247 path node is to be allocated and built.\r
248 @param DevicePath A pointer to a single device path node that\r
249 describes the SCSI device specified by\r
250 Target and Lun. This function is responsible\r
251 for allocating the buffer DevicePath with the boot\r
252 service AllocatePool(). It is the caller's\r
253 responsibility to free DevicePath when the caller\r
254 is finished with DevicePath.\r
255\r
256 @retval EFI_SUCCESS The device path node that describes the SCSI device\r
257 specified by Target and Lun was allocated and\r
258 returned in DevicePath.\r
259 @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does\r
260 not exist on the SCSI channel.\r
261 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
262 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate\r
263 DevicePath.\r
264\r
265**/\r
266typedef\r
267EFI_STATUS\r
8b13229b 268(EFIAPI *EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH)(\r
d1f95000 269 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,\r
270 IN UINT32 Target,\r
271 IN UINT64 Lun,\r
272 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
ed66e1bc 273 );\r
d1f95000 274\r
275/**\r
276 Used to translate a device path node to a Target ID and LUN.\r
277\r
278 @param This Protocol instance pointer.\r
279 @param DevicePath A pointer to the device path node that\r
280 describes a SCSI device on the SCSI channel.\r
281 @param Target A pointer to the Target ID of a SCSI device\r
282 on the SCSI channel.\r
283 @param Lun A pointer to the LUN of a SCSI device on\r
284 the SCSI channel.\r
285\r
286 @retval EFI_SUCCESS DevicePath was successfully translated to a\r
287 Target ID and LUN, and they were returned\r
288 in Target and Lun.\r
289 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
290 @retval EFI_INVALID_PARAMETER Target is NULL.\r
291 @retval EFI_INVALID_PARAMETER Lun is NULL.\r
292 @retval EFI_UNSUPPORTED This driver does not support the device path\r
293 node type in DevicePath.\r
294 @retval EFI_NOT_FOUND A valid translation from DevicePath to a\r
295 Target ID and LUN does not exist.\r
296\r
297**/\r
298typedef\r
299EFI_STATUS\r
8b13229b 300(EFIAPI *EFI_SCSI_PASS_THRU_GET_TARGET_LUN)(\r
d1f95000 301 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,\r
302 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
303 OUT UINT32 *Target,\r
304 OUT UINT64 *Lun\r
ed66e1bc 305 );\r
d1f95000 306\r
307/**\r
9095d37b 308 Resets a SCSI channel.This operation resets all the\r
d1f95000 309 SCSI devices connected to the SCSI channel.\r
310\r
311 @param This Protocol instance pointer.\r
312\r
313 @retval EFI_SUCCESS The SCSI channel was reset.\r
314 @retval EFI_UNSUPPORTED The SCSI channel does not support\r
315 a channel reset operation.\r
316 @retval EFI_DEVICE_ERROR A device error occurred while\r
317 attempting to reset the SCSI channel.\r
318 @retval EFI_TIMEOUT A timeout occurred while attempting\r
319 to reset the SCSI channel.\r
320\r
321**/\r
322typedef\r
323EFI_STATUS\r
8b13229b 324(EFIAPI *EFI_SCSI_PASS_THRU_RESET_CHANNEL)(\r
d1f95000 325 IN EFI_SCSI_PASS_THRU_PROTOCOL *This\r
ed66e1bc 326 );\r
d1f95000 327\r
328/**\r
329 Resets a SCSI device that is connected to a SCSI channel.\r
330\r
331 @param This Protocol instance pointer.\r
332 @param Target The Target ID of the SCSI device to reset.\r
333 @param Lun The LUN of the SCSI device to reset.\r
334\r
335 @retval EFI_SUCCESS The SCSI device specified by Target and\r
336 Lun was reset.\r
337 @retval EFI_UNSUPPORTED The SCSI channel does not support a target\r
338 reset operation.\r
339 @retval EFI_INVALID_PARAMETER Target or Lun are invalid.\r
340 @retval EFI_DEVICE_ERROR A device error occurred while attempting\r
341 to reset the SCSI device specified by Target\r
342 and Lun.\r
343 @retval EFI_TIMEOUT A timeout occurred while attempting to reset\r
344 the SCSI device specified by Target and Lun.\r
345\r
346**/\r
347typedef\r
348EFI_STATUS\r
8b13229b 349(EFIAPI *EFI_SCSI_PASS_THRU_RESET_TARGET)(\r
d1f95000 350 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,\r
351 IN UINT32 Target,\r
352 IN UINT64 Lun\r
ed66e1bc 353 );\r
d1f95000 354\r
44717a39 355///\r
356/// The EFI_SCSI_PASS_THRU_PROTOCOL provides information about a SCSI channel and\r
630b4187 357/// the ability to send SCSI Request Packets to any SCSI device attached to that SCSI channel. The\r
44717a39 358/// information includes the Target ID of the host controller on the SCSI channel, the attributes of\r
359/// the SCSI channel, the printable name for the SCSI controller, and the printable name of the\r
360/// SCSI channel.\r
361///\r
d1f95000 362struct _EFI_SCSI_PASS_THRU_PROTOCOL {\r
44717a39 363 ///\r
364 /// A pointer to the EFI_SCSI_PASS_THRU_MODE data for this SCSI channel.\r
365 ///\r
2f88bd3a
MK
366 EFI_SCSI_PASS_THRU_MODE *Mode;\r
367 EFI_SCSI_PASS_THRU_PASSTHRU PassThru;\r
368 EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE GetNextDevice;\r
369 EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
370 EFI_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun;\r
371 EFI_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel;\r
372 EFI_SCSI_PASS_THRU_RESET_TARGET ResetTarget;\r
d1f95000 373};\r
374\r
2f88bd3a 375extern EFI_GUID gEfiScsiPassThruProtocolGuid;\r
d1f95000 376\r
377#endif\r