]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/ScsiPassThruExt.h
b522792848877f86b67cf5c9b50d7cfb61e2f442
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiPassThruExt.h
1 /** @file
2 EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: ScsiPassThruExt.h
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 0x1d3de7f0, 0x0807, 0x424f, {0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } \
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 /**
142 Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
143 can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
144 Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
145 Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
146 channel.
147
148 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
149 @param Target On input, a pointer to the Target ID (an array of size
150 TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
151 On output, a pointer to the Target ID (an array of
152 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
153 channel. An input value of 0xF(all bytes in the array are 0xF) in the
154 Target array retrieves the Target ID of the first SCSI device present on a
155 SCSI channel.
156 @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
157 channel. On output, a pointer to the LUN of the next SCSI device present
158 on a SCSI channel.
159
160 @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
161 channel was returned in Target and Lun.
162 @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
163 not returned on a previous call to GetNextTargetLun().
164 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
165
166 **/
167 typedef
168 EFI_STATUS
169 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN) (
170 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
171 IN OUT UINT8 **Target,
172 IN OUT UINT64 *Lun
173 )
174 ;
175
176 /**
177 Used to allocate and build a device path node for a SCSI device on a SCSI channel.
178
179 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
180 @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the
181 Target ID of the SCSI device for which a device path node is to be
182 allocated and built. Transport drivers may chose to utilize a subset of
183 this size to suit the representation of targets. For example, a Fibre
184 Channel driver may use only 8 bytes (WWN) in the array to represent a
185 FC target.
186 @param Lun The LUN of the SCSI device for which a device path node is to be
187 allocated and built.
188
189 @param DevicePath A pointer to a single device path node that describes the SCSI device
190 specified by Target and Lun. This function is responsible for
191 allocating the buffer DevicePath with the boot service
192 AllocatePool(). It is the caller's responsibility to free
193 DevicePath when the caller is finished with DevicePath.
194
195 @retval EFI_SUCCESS The device path node that describes the SCSI device specified by
196 Target and Lun was allocated and returned in
197 DevicePath.
198 @retval EFI_INVALID_PARAMETER DevicePath is NULL.
199 @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist
200 on the SCSI channel.
201 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
202
203 **/
204 typedef
205 EFI_STATUS
206 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (
207 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
208 IN UINT8 *Target,
209 IN UINT64 Lun,
210 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
211 )
212 ;
213
214 /**
215 Used to translate a device path node to a Target ID and LUN.
216
217 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
218 @param DevicePath A pointer to a single device path node that describes the SCSI device
219 on the SCSI channel.
220 @param Target A pointer to the Target Array which represents the ID of a SCSI device
221 on the SCSI channel.
222 @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.
223
224 @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and
225 LUN, and they were returned in Target and Lun.
226 @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
227 @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN
228 does not exist.
229 @retval EFI_UNSUPPORTED This driver does not support the device path node type in
230 DevicePath.
231
232 **/
233 typedef
234 EFI_STATUS
235 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN) (
236 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
237 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
238 OUT UINT8 **Target,
239 OUT UINT64 *Lun
240 )
241 ;
242
243 /**
244 Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
245
246 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
247
248 @retval EFI_SUCCESS The SCSI channel was reset.
249 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.
250 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.
251 @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.
252
253 **/
254 typedef
255 EFI_STATUS
256 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL) (
257 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
258 )
259 ;
260
261 /**
262 Resets a SCSI logical unit that is connected to a SCSI channel.
263
264 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
265 @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the
266 target port ID of the SCSI device containing the SCSI logical unit to
267 reset. Transport drivers may chose to utilize a subset of this array to suit
268 the representation of their targets.
269 @param Lun The LUN of the SCSI device to reset.
270
271 @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.
272 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
273 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device
274 specified by Target and Lun.
275 @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.
276 @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device
277 specified by Target and Lun.
278
279 **/
280 typedef
281 EFI_STATUS
282 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN) (
283 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
284 IN UINT8 *Target,
285 IN UINT64 Lun
286 )
287 ;
288
289 /**
290 Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
291 be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
292 for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
293 see if a SCSI device is actually present at that location on the SCSI channel.
294
295 @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
296 @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
297 On output, a pointer to the Target ID (an array of
298 TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
299 channel. An input value of 0xF(all bytes in the array are 0xF) in the
300 Target array retrieves the Target ID of the first SCSI device present on a
301 SCSI channel.
302
303 @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI
304 channel was returned in Target.
305 @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
306 @retval EFI_TIMEOUT Target array is not all 0xF, and Target were not
307 returned on a previous call to GetNextTarget().
308 @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
309
310 **/
311 typedef
312 EFI_STATUS
313 (EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET) (
314 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
315 IN OUT UINT8 **Target
316 )
317 ;
318
319 struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL {
320 EFI_EXT_SCSI_PASS_THRU_MODE *Mode;
321 EFI_EXT_SCSI_PASS_THRU_PASSTHRU PassThru;
322 EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun;
323 EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
324 EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun;
325 EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel;
326 EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN ResetTargetLun;
327 EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET GetNextTarget;
328 };
329
330 extern EFI_GUID gEfiExtScsiPassThruProtocolGuid;
331
332 #endif