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