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