]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/ScsiPassThruExt.h
Formalize comments for Protocols and PPIs.
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiPassThruExt.h
1 /** @file
2 EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.
3 This protocol provides services that allow SCSI Pass Thru commands
4 to be sent to SCSI devices attached to a SCSI channel.
5
6 Copyright (c) 2006 - 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
18 #define __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
19
20 #define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \
21 { \
22 0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe } \
23 }
24
25 typedef struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL EFI_EXT_SCSI_PASS_THRU_PROTOCOL;
26
27 #define TARGET_MAX_BYTES 0x10
28
29 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
30 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
31 #define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
32
33 //
34 // DataDirection
35 //
36 #define EFI_EXT_SCSI_DATA_DIRECTION_READ 0
37 #define EFI_EXT_SCSI_DATA_DIRECTION_WRITE 1
38 #define EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL 2
39 //
40 // HostAdapterStatus
41 //
42 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK 0x00
43 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09
44 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b
45 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d
46 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e
47 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
48 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10
49 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11
50 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12
51 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13
52 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14
53 #define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f
54 //
55 // TargetStatus
56 //
57 #define EFI_EXT_SCSI_STATUS_TARGET_GOOD 0x00
58 #define EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02
59 #define EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET 0x04
60 #define EFI_EXT_SCSI_STATUS_TARGET_BUSY 0x08
61 #define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE 0x10
62 #define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14
63 #define EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18
64 #define EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL 0x28
65 #define EFI_EXT_SCSI_STATUS_TARGET_ACA_ACTIVE 0x30
66 #define EFI_EXT_SCSI_STATUS_TARGET_TASK_ABORTED 0x40
67
68 typedef struct {
69 UINT32 AdapterId;
70 UINT32 Attributes;
71 UINT32 IoAlign;
72 } EFI_EXT_SCSI_PASS_THRU_MODE;
73
74 typedef struct {
75 UINT64 Timeout;
76 VOID *InDataBuffer;
77 VOID *OutDataBuffer;
78 VOID *SenseData;
79 VOID *Cdb;
80 UINT32 InTransferLength;
81 UINT32 OutTransferLength;
82 UINT8 CdbLength;
83 UINT8 DataDirection;
84 UINT8 HostAdapterStatus;
85 UINT8 TargetStatus;
86 UINT8 SenseDataLength;
87 } EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;
88
89 /**
90 Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
91 supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
92 nonblocking I/O functionality is optional.
93
94 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
95 @param Target The Target is an array of size TARGET_MAX_BYTES and it represents
96 the id of the SCSI device to send the SCSI Request Packet. Each
97 transport driver may chose to utilize a subset of this size to suit the needs
98 of transport target representation. For example, a Fibre Channel driver
99 may use only 8 bytes (WWN) to represent an FC target.
100 @param Lun The LUN of the SCSI device to send the SCSI Request Packet.
101 @param Packet A pointer to the SCSI Request Packet to send to the SCSI device
102 specified by Target and Lun.
103 @param Event If nonblocking I/O is not supported then Event is ignored, and blocking
104 I/O is performed. If Event is NULL, then blocking I/O is performed. If
105 Event is not NULL and non blocking I/O is supported, then
106 nonblocking I/O is performed, and Event will be signaled when the
107 SCSI Request Packet completes.
108
109 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional
110 commands, InTransferLength bytes were transferred from
111 InDataBuffer. For write and bi-directional commands,
112 OutTransferLength bytes were transferred by
113 OutDataBuffer.
114 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that
115 could be transferred is returned in InTransferLength. For write
116 and bi-directional commands, OutTransferLength bytes were
117 transferred by OutDataBuffer.
118 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
119 SCSI Request Packets already queued. The caller may retry again later.
120 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request
121 Packet.
122 @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.
123 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported
124 by the host adapter. This includes the case of Bi-directional SCSI
125 commands not supported by the implementation. The SCSI Request
126 Packet was not sent, so no additional status information is available.
127 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
128
129 **/
130 typedef
131 EFI_STATUS
132 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_PASSTHRU)(
133 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
134 IN UINT8 *Target,
135 IN UINT64 Lun,
136 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
137 IN EFI_EVENT Event OPTIONAL
138 );
139
140 /**
141 Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
142 can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
143 Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
144 Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
145 channel.
146
147 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
148 @param Target On input, a pointer to the Target ID (an array of size
149 TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
150 On output, a pointer to the Target ID (an array of
151 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
152 channel. An input value of 0xF(all bytes in the array are 0xF) in the
153 Target array retrieves the Target ID of the first SCSI device present on a
154 SCSI channel.
155 @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
156 channel. On output, a pointer to the LUN of the next SCSI device present
157 on a SCSI channel.
158
159 @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
160 channel was returned in Target and Lun.
161 @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
162 not returned on a previous call to GetNextTargetLun().
163 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
164
165 **/
166 typedef
167 EFI_STATUS
168 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN)(
169 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
170 IN OUT UINT8 **Target,
171 IN OUT UINT64 *Lun
172 );
173
174 /**
175 Used to allocate and build a device path node for a SCSI device on a SCSI channel.
176
177 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
178 @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the
179 Target ID of the SCSI device for which a device path node is to be
180 allocated and built. Transport drivers may chose to utilize a subset of
181 this size to suit the representation of targets. For example, a Fibre
182 Channel driver may use only 8 bytes (WWN) in the array to represent a
183 FC target.
184 @param Lun The LUN of the SCSI device for which a device path node is to be
185 allocated and built.
186 @param DevicePath A pointer to a single device path node that describes the SCSI device
187 specified by Target and Lun. This function is responsible for
188 allocating the buffer DevicePath with the boot service
189 AllocatePool(). It is the caller's responsibility to free
190 DevicePath when the caller is finished with DevicePath.
191
192 @retval EFI_SUCCESS The device path node that describes the SCSI device specified by
193 Target and Lun was allocated and returned in
194 DevicePath.
195 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
196 @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist
197 on the SCSI channel.
198 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
199
200 **/
201 typedef
202 EFI_STATUS
203 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH)(
204 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
205 IN UINT8 *Target,
206 IN UINT64 Lun,
207 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
208 );
209
210 /**
211 Used to translate a device path node to a Target ID and LUN.
212
213 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
214 @param DevicePath A pointer to a single device path node that describes the SCSI device
215 on the SCSI channel.
216 @param Target A pointer to the Target Array which represents the ID of a SCSI device
217 on the SCSI channel.
218 @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.
219
220 @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and
221 LUN, and they were returned in Target and Lun.
222 @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
223 @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN
224 does not exist.
225 @retval EFI_UNSUPPORTED This driver does not support the device path node type in
226 DevicePath.
227
228 **/
229 typedef
230 EFI_STATUS
231 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN)(
232 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
233 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
234 OUT UINT8 **Target,
235 OUT UINT64 *Lun
236 );
237
238 /**
239 Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
240
241 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
242
243 @retval EFI_SUCCESS The SCSI channel was reset.
244 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.
245 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.
246 @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.
247
248 **/
249 typedef
250 EFI_STATUS
251 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL)(
252 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
253 );
254
255 /**
256 Resets a SCSI logical unit that is connected to a SCSI channel.
257
258 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
259 @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the
260 target port ID of the SCSI device containing the SCSI logical unit to
261 reset. Transport drivers may chose to utilize a subset of this array to suit
262 the representation of their targets.
263 @param Lun The LUN of the SCSI device to reset.
264
265 @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.
266 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
267 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device
268 specified by Target and Lun.
269 @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.
270 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device
271 specified by Target and Lun.
272
273 **/
274 typedef
275 EFI_STATUS
276 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN)(
277 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
278 IN UINT8 *Target,
279 IN UINT64 Lun
280 );
281
282 /**
283 Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
284 be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
285 for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
286 see if a SCSI device is actually present at that location on the SCSI channel.
287
288 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
289 @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
290 On output, a pointer to the Target ID (an array of
291 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
292 channel. An input value of 0xF(all bytes in the array are 0xF) in the
293 Target array retrieves the Target ID of the first SCSI device present on a
294 SCSI channel.
295
296 @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI
297 channel was returned in Target.
298 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
299 @retval EFI_TIMEOUT Target array is not all 0xF, and Target were not
300 returned on a previous call to GetNextTarget().
301 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
302
303 **/
304 typedef
305 EFI_STATUS
306 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET)(
307 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
308 IN OUT UINT8 **Target
309 );
310
311 ///
312 /// The EFI_EXT_SCSI_PASS_THRU_PROTOCOL provides information about a SCSI channel
313 /// and the ability to send SCI Request Packets to any SCSI device attached to
314 /// that SCSI channel. The information includes the Target ID of the host controller
315 /// on the SCSI channel and the attributes of the SCSI channel.
316 ///
317 struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL {
318 ///
319 /// A pointer to the EFI_EXT_SCSI_PASS_THRU_MODE data for this SCSI channel.
320 ///
321 EFI_EXT_SCSI_PASS_THRU_MODE *Mode;
322 EFI_EXT_SCSI_PASS_THRU_PASSTHRU PassThru;
323 EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun;
324 EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
325 EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun;
326 EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel;
327 EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN ResetTargetLun;
328 EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET GetNextTarget;
329 };
330
331 extern EFI_GUID gEfiExtScsiPassThruProtocolGuid;
332
333 #endif