]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/ScsiIo.h
Update the copyright notice format
[mirror_edk2.git] / MdePkg / Include / Protocol / ScsiIo.h
1 /** @file
2 EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.
3 This protocol is used by code, typically drivers, running in the EFI boot
4 services environment to access SCSI devices. In particular, functions for
5 managing devices on SCSI buses are defined here.
6
7 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __EFI_SCSI_IO_PROTOCOL_H__
19 #define __EFI_SCSI_IO_PROTOCOL_H__
20
21 #define EFI_SCSI_IO_PROTOCOL_GUID \
22 { \
23 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
24 }
25
26 ///
27 /// Forward reference for pure ANSI compatability
28 ///
29 typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;
30
31 //
32 // SCSI Data Direction definition
33 //
34 #define EFI_SCSI_IO_DATA_DIRECTION_READ 0
35 #define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1
36 #define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2
37
38 //
39 // SCSI Host Adapter Status definition
40 //
41 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00
42 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 ///< timeout when processing the command
43 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b ///< timeout when waiting for the command processing
44 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d ///< a message reject was received when processing command
45 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e ///< a bus reset was detected
46 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
47 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 ///< the adapter failed in issuing request sense command
48 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 ///< selection timeout
49 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 ///< data overrun or data underrun
50 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 ///< Unexepected bus free
51 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 ///< Target bus phase sequence failure
52 #define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f
53
54
55 //
56 // SCSI Target Status definition
57 //
58 #define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00
59 #define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 ///< check condition
60 #define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 ///< condition met
61 #define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 ///< busy
62 #define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 ///< intermediate
63 #define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 ///< intermediate-condition met
64 #define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 ///< reservation conflict
65 #define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 ///< command terminated
66 #define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 ///< queue full
67
68 typedef struct {
69 ///
70 /// The timeout, in 100 ns units, to use for the execution of this SCSI
71 /// Request Packet. A Timeout value of 0 means that this function
72 /// will wait indefinitely for the SCSI Request Packet to execute. If
73 /// Timeout is greater than zero, then this function will return
74 /// EFI_TIMEOUT if the time required to execute the SCSI Request
75 /// Packet is greater than Timeout.
76 ///
77 UINT64 Timeout;
78 ///
79 /// A pointer to the data buffer to transfer between the SCSI
80 /// controller and the SCSI device for SCSI READ command
81 ///
82 VOID *InDataBuffer;
83 ///
84 /// A pointer to the data buffer to transfer between the SCSI
85 /// controller and the SCSI device for SCSI WRITE command.
86 ///
87 VOID *OutDataBuffer;
88 ///
89 /// A pointer to the sense data that was generated by the execution of
90 /// the SCSI Request Packet.
91 ///
92 VOID *SenseData;
93 ///
94 /// A pointer to buffer that contains the Command Data Block to
95 /// send to the SCSI device.
96 ///
97 VOID *Cdb;
98 ///
99 /// On Input, the size, in bytes, of InDataBuffer. On output, the
100 /// number of bytes transferred between the SCSI controller and the SCSI device.
101 ///
102 UINT32 InTransferLength;
103 ///
104 /// On Input, the size, in bytes of OutDataBuffer. On Output, the
105 /// Number of bytes transferred between SCSI Controller and the SCSI device.
106 ///
107 UINT32 OutTransferLength;
108 ///
109 /// The length, in bytes, of the buffer Cdb. The standard values are
110 /// 6, 10, 12, and 16, but other values are possible if a variable length CDB is used.
111 ///
112 UINT8 CdbLength;
113 ///
114 /// The direction of the data transfer. 0 for reads, 1 for writes. A
115 /// value of 2 is Reserved for Bi-Directional SCSI commands.
116 ///
117 UINT8 DataDirection;
118 ///
119 /// The status of the SCSI Host Controller that produces the SCSI
120 /// bus where the SCSI device attached when the SCSI Request
121 /// Packet was executed on the SCSI Controller.
122 ///
123 UINT8 HostAdapterStatus;
124 ///
125 /// The status returned by the SCSI device when the SCSI Request
126 /// Packet was executed.
127 ///
128 UINT8 TargetStatus;
129 ///
130 /// On input, the length in bytes of the SenseData buffer. On
131 /// output, the number of bytes written to the SenseData buffer.
132 ///
133 UINT8 SenseDataLength;
134 } EFI_SCSI_IO_SCSI_REQUEST_PACKET;
135
136 /**
137 Retrieves the device type information of the SCSI Controller.
138
139 @param This Protocol instance pointer.
140 @param DeviceType A pointer to the device type information
141 retrieved from the SCSI Controller.
142
143 @retval EFI_SUCCESS Retrieved the device type information successfully.
144 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.
145
146 **/
147 typedef
148 EFI_STATUS
149 (EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE)(
150 IN EFI_SCSI_IO_PROTOCOL *This,
151 OUT UINT8 *DeviceType
152 );
153
154 /**
155 Retrieves the device location in the SCSI channel.
156
157 @param This Protocol instance pointer.
158 @param Target A pointer to the Target ID of a SCSI device
159 on the SCSI channel.
160 @param Lun A pointer to the LUN of the SCSI device on
161 the SCSI channel.
162
163 @retval EFI_SUCCESS Retrieves the device location successfully.
164 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL.
165
166 **/
167 typedef
168 EFI_STATUS
169 (EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION)(
170 IN EFI_SCSI_IO_PROTOCOL *This,
171 IN OUT UINT8 **Target,
172 OUT UINT64 *Lun
173 );
174
175 /**
176 Resets the SCSI Bus that the SCSI Controller is attached to.
177
178 @param This Protocol instance pointer.
179
180 @retval EFI_SUCCESS The SCSI bus is reset successfully.
181 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.
182 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the
183 SCSI Host Controller.
184 @retval EFI_TIMEOUT A timeout occurred while attempting to reset
185 the SCSI bus.
186
187 **/
188 typedef
189 EFI_STATUS
190 (EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS)(
191 IN EFI_SCSI_IO_PROTOCOL *This
192 );
193
194 /**
195 Resets the SCSI Controller that the device handle specifies.
196
197 @param This Protocol instance pointer.
198
199 @retval EFI_SUCCESS Reset the SCSI controller successfully.
200 @retval EFI_DEVICE_ERROR Errors were encountered when resetting the
201 SCSI Controller.
202 @retval EFI_UNSUPPORTED The SCSI bus does not support a device
203 reset operation.
204 @retval EFI_TIMEOUT A timeout occurred while attempting to
205 reset the SCSI Controller.
206
207 **/
208 typedef
209 EFI_STATUS
210 (EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE)(
211 IN EFI_SCSI_IO_PROTOCOL *This
212 );
213
214
215 /**
216 Sends a SCSI Request Packet to the SCSI Controller for execution.
217
218 @param This Protocol instance pointer.
219 @param Packet The SCSI request packet to send to the SCSI
220 Controller specified by the device handle.
221 @param Event If the SCSI bus to which the SCSI device is attached
222 does not support non-blocking I/O, then Event is
223 ignored, and blocking I/O is performed.
224 If Event is NULL, then blocking I/O is performed.
225 If Event is not NULL and non-blocking I/O is
226 supported, then non-blocking I/O is performed,
227 and Event will be signaled when the SCSI Request
228 Packet completes.
229
230 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host
231 successfully, and TransferLength bytes were
232 transferred to/from DataBuffer. See
233 HostAdapterStatus, TargetStatus,
234 SenseDataLength, and SenseData in that order
235 for additional status information.
236 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
237 but the entire DataBuffer could not be transferred.
238 The actual number of bytes transferred is returned
239 in TransferLength. See HostAdapterStatus,
240 TargetStatus, SenseDataLength, and SenseData in
241 that order for additional status information.
242 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
243 there are too many SCSI Command Packets already
244 queued.The caller may retry again later.
245 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
246 the SCSI Request Packet. See HostAdapterStatus,
247 TargetStatus, SenseDataLength, and SenseData in
248 that order for additional status information.
249 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
250 The SCSI Request Packet was not sent, so no
251 additional status information is available.
252 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
253 is not supported by the SCSI initiator(i.e., SCSI
254 Host Controller). The SCSI Request Packet was not
255 sent, so no additional status information is
256 available.
257 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
258 Request Packet to execute. See HostAdapterStatus,
259 TargetStatus, SenseDataLength, and SenseData in
260 that order for additional status information.
261
262 **/
263 typedef
264 EFI_STATUS
265 (EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND)(
266 IN EFI_SCSI_IO_PROTOCOL *This,
267 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet,
268 IN EFI_EVENT Event OPTIONAL
269 );
270
271 ///
272 /// Provides services to manage and communicate with SCSI devices.
273 ///
274 struct _EFI_SCSI_IO_PROTOCOL {
275 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType;
276 EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation;
277 EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus;
278 EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice;
279 EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand;
280
281 ///
282 /// Supplies the alignment requirement for any buffer used in a data transfer.
283 /// IoAlign values of 0 and 1 mean that the buffer can be placed anywhere in memory.
284 /// Otherwise, IoAlign must be a power of 2, and the requirement is that the
285 /// start address of a buffer must be evenly divisible by IoAlign with no remainder.
286 ///
287 UINT32 IoAlign;
288 };
289
290 extern EFI_GUID gEfiScsiIoProtocolGuid;
291
292 #endif