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