]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/UefiScsiLib.h
Remove 4 obsolete macros in UefiScsiLib and we have equivalent macros to the UEFI...
[mirror_edk2.git] / MdePkg / Include / Library / UefiScsiLib.h
1 /** @file
2
3 Provides the functions to submit Scsi commands defined in SCSI-2 specification for scsi device.
4
5 Copyright (c) 2006 - 2008, Intel Corporation<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __SCSI_LIB_H__
17 #define __SCSI_LIB_H__
18
19 #include <Protocol/ScsiIo.h>
20
21 /**
22 Execute Test Unit Ready SCSI command on a specific SCSI target.
23
24 Executes the Test Unit Ready command on the SCSI target specified by ScsiIo.
25 If Timeout is zero, then this function waits indefinitely for the command to complete.
26 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
27 If ScsiIo is NULL, then ASSERT().
28 If SenseDataLength is NULL, then ASSERT().
29 If HostAdapterStatus is NULL, then ASSERT().
30 If TargetStatus is NULL, then ASSERT().
31
32
33 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance
34 for the specific SCSI target.
35 @param[in] Timeout The timeout in 100 ns units to use for the execution
36 of this SCSI Request Packet. A Timeout value of
37 zero means that this function will wait indefinitely
38 for the SCSI Request Packet to execute. If Timeout
39 is greater than zero, then this function will return
40 EFI_TIMEOUT if the time required to execute the SCSI
41 Request Packet is greater than Timeout.
42 @param[in, out] SenseData A pointer to sense data that was generated by
43 the execution of the SCSI Request Packet. This
44 buffer must be allocated by the caller.
45 If SenseDataLength is 0, then this parameter is
46 optional and may be NULL.
47 @param[in, out] SenseDataLength On input, a pointer to the length in bytes of
48 the SenseData buffer. On output, a poiinter to
49 the number of bytes written to the SenseData buffer.
50 @param[out] HostAdapterStatus The status of the SCSI Host Controller that produces
51 the SCSI bus containing the SCSI target specified by
52 ScsiIo when the SCSI Request Packet was executed.
53 See the EFI SCSI I/O Protocol in the UEFI Specification
54 for details on the possible return values.
55 @param[out] TargetStatus The status returned by the SCSI target specified
56 by ScsiIo when the SCSI Request Packat was executed
57 on the SCSI Host Controller. See the EFI SCSI I/O
58 Protocol in the UEFI Specification for details on
59 the possible return values.
60
61 @retval EFI_SUCCESS The command was executed successfully.
62 See HostAdapterStatus, TargetStatus, SenseDataLength,
63 and SenseData in that order for additional status
64 information.
65 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
66 there are too many SCSI Command Packets already
67 queued. The SCSI Request Packet was not sent, so
68 no additional status information is available.
69 The caller may retry again later.
70 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
71 SCSI Request Packet. See HostAdapterStatus,
72 TargetStatus, SenseDataLength, and SenseData in that
73 order for additional status information.
74 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
75 is not supported by the SCSI initiator(i.e., SCSI
76 Host Controller). The SCSI Request Packet was not
77 sent, so no additional status information is available.
78 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request
79 Packet to execute. See HostAdapterStatus, TargetStatus,
80 SenseDataLength, and SenseData in that order for
81 additional status information.
82 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
83 but the entire DataBuffer could not be transferred.
84 The actual number of bytes transferred is returned
85 in InTransferLength.
86
87 **/
88 EFI_STATUS
89 EFIAPI
90 ScsiTestUnitReadyCommand (
91 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
92 IN UINT64 Timeout,
93 IN OUT VOID *SenseData, OPTIONAL
94 IN OUT UINT8 *SenseDataLength,
95 OUT UINT8 *HostAdapterStatus,
96 OUT UINT8 *TargetStatus
97 );
98
99
100 /**
101 Execute Inquiry SCSI command on a specific SCSI target.
102
103 Executes the Inquiry command on the SCSI target specified by ScsiIo.
104 If Timeout is zero, then this function waits indefinitely for the command to complete.
105 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
106 If ScsiIo is NULL, then ASSERT().
107 If SenseDataLength is NULL, then ASSERT().
108 If HostAdapterStatus is NULL, then ASSERT().
109 If TargetStatus is NULL, then ASSERT().
110 If InquiryDataLength is NULL, then ASSERT().
111
112 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance
113 for the specific SCSI target.
114 @param[in] Timeout The timeout in 100 ns units to use for the
115 execution of this SCSI Request Packet. A Timeout
116 value of zero means that this function will wait
117 indefinitely for the SCSI Request Packet to execute.
118 If Timeout is greater than zero, then this function
119 will return EFI_TIMEOUT if the time required to
120 execute the SCSI Request Packet is greater than Timeout.
121 @param[in, out] SenseData A pointer to sense data that was generated
122 by the execution of the SCSI Request Packet.
123 This buffer must be allocated by the caller.
124 If SenseDataLength is 0, then this parameter
125 is optional and may be NULL.
126 @param[in, out] SenseDataLength On input, the length in bytes of the SenseData buffer.
127 On output, the number of bytes written to the SenseData buffer.
128 @param[out] HostAdapterStatus The status of the SCSI Host Controller that
129 produces the SCSI bus containing the SCSI
130 target specified by ScsiIo when the SCSI
131 Request Packet was executed. See the EFI
132 SCSI I/O Protocol in the UEFI Specification
133 for details on the possible return values.
134 @param[out] TargetStatus The status returned by the SCSI target specified
135 by ScsiIo when the SCSI Request Packat was
136 executed on the SCSI Host Controller.
137 See the EFI SCSI I/O Protocol in the UEFI
138 Specification for details on the possible
139 return values.
140 @param[in, out] InquiryDataBuffer A pointer to inquiry data that was generated
141 by the execution of the SCSI Request Packet.
142 This buffer must be allocated by the caller.
143 If InquiryDataLength is 0, then this parameter
144 is optional and may be NULL.
145 @param[in, out] InquiryDataLength On input, a pointer to the length in bytes
146 of the InquiryDataBuffer buffer.
147 On output, a pointer to the number of bytes
148 written to the InquiryDataBuffer buffer.
149 @param[in] EnableVitalProductData If TRUE, then the supported vital product
150 data is returned in InquiryDataBuffer.
151 If FALSE, then the standard inquiry data is
152 returned in InquiryDataBuffer.
153
154 @retval EFI_SUCCESS The command was executed successfully. See HostAdapterStatus,
155 TargetStatus, SenseDataLength, and SenseData in that order
156 for additional status information.
157 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire
158 InquiryDataBuffer could not be transferred. The actual
159 number of bytes transferred is returned in InquiryDataLength.
160 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there
161 are too many SCSI Command Packets already queued.
162 The SCSI Request Packet was not sent, so no additional
163 status information is available. The caller may retry again later.
164 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI
165 Request Packet. See HostAdapterStatus, TargetStatus,
166 SenseDataLength, and SenseData in that order for additional
167 status information.
168 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not
169 supported by the SCSI initiator(i.e., SCSI Host Controller).
170 The SCSI Request Packet was not sent, so no additional
171 status information is available.
172 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request
173 Packet to execute. See HostAdapterStatus, TargetStatus,
174 SenseDataLength, and SenseData in that order for
175 additional status information.
176
177 **/
178 EFI_STATUS
179 EFIAPI
180 ScsiInquiryCommand (
181 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
182 IN UINT64 Timeout,
183 IN OUT VOID *SenseData, OPTIONAL
184 IN OUT UINT8 *SenseDataLength,
185 OUT UINT8 *HostAdapterStatus,
186 OUT UINT8 *TargetStatus,
187 IN OUT VOID *InquiryDataBuffer, OPTIONAL
188 IN OUT UINT32 *InquiryDataLength,
189 IN BOOLEAN EnableVitalProductData
190 );
191
192
193 /**
194 Execute Mode Sense(10) SCSI command on a specific SCSI target.
195
196 Executes the SCSI Mode Sense(10) command on the SCSI target specified by ScsiIo.
197 If Timeout is zero, then this function waits indefinitely for the command to complete.
198 If Timeout is greater than zero, then the command is executed and will timeout
199 after Timeout 100 ns units. The DBDField, PageControl, and PageCode parameters
200 are used to construct the CDB for this SCSI command.
201 If ScsiIo is NULL, then ASSERT().
202 If SenseDataLength is NULL, then ASSERT().
203 If HostAdapterStatus is NULL, then ASSERT().
204 If TargetStatus is NULL, then ASSERT().
205 If DataLength is NULL, then ASSERT().
206
207
208 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance
209 for the specific SCSI target.
210 @param[in] Timeout The timeout in 100 ns units to use for the
211 execution of this SCSI Request Packet. A Timeout
212 value of zero means that this function will wait
213 indefinitely for the SCSI Request Packet to execute.
214 If Timeout is greater than zero, then this function
215 will return EFI_TIMEOUT if the time required to
216 execute the SCSI Request Packet is greater than Timeout.
217 @param[in,out] SenseData A pointer to sense data that was generated
218 by the execution of the SCSI Request Packet.
219 This buffer must be allocated by the caller.
220 If SenseDataLength is 0, then this parameter
221 is optional and may be NULL.
222 @param[in,out] SenseDataLength On input, the length in bytes of the SenseData buffer.
223 On output, the number of bytes written to the SenseData buffer.
224 @param[out] HostAdapterStatus The status of the SCSI Host Controller that
225 produces the SCSI bus containing the SCSI target
226 specified by ScsiIo when the SCSI Request Packet
227 was executed. See the EFI SCSI I/O Protocol in the
228 UEFI Specification for details on the possible
229 return values.
230 @param[out] TargetStatus The status returned by the SCSI target specified
231 by ScsiIo when the SCSI Request Packat was executed
232 on the SCSI Host Controller. See the EFI SCSI
233 I/O Protocol in the UEFI Specification for details
234 on the possible return values.
235 @param[in,out] DataBuffer A pointer to data that was generated by the
236 execution of the SCSI Request Packet. This
237 buffer must be allocated by the caller. If
238 DataLength is 0, then this parameter is optional
239 and may be NULL.
240 @param[in,out] DataLength On input, a pointer to the length in bytes of
241 the DataBuffer buffer. On output, a pointer
242 to the number of bytes written to the DataBuffer
243 buffer.
244 @param[in] DBDField Specifies the DBD field of the CDB for this SCSI Command.
245 @param[in] PageControl Specifies the PC field of the CDB for this SCSI Command.
246 @param[in] PageCode Specifies the Page Control field of the CDB for this SCSI Command.
247
248 @retval EFI_SUCCESS The command was executed successfully.
249 See HostAdapterStatus, TargetStatus, SenseDataLength,
250 and SenseData in that order for additional status information.
251 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the
252 entire DataBuffer could not be transferred.
253 The actual number of bytes transferred is returned
254 in DataLength.
255 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
256 there are too many SCSI Command Packets already queued.
257 The SCSI Request Packet was not sent, so no additional
258 status information is available. The caller may retry
259 again later.
260 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
261 SCSI Request Packet. See HostAdapterStatus, TargetStatus,
262 SenseDataLength, and SenseData in that order for
263 additional status information.
264 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
265 is not supported by the SCSI initiator(i.e., SCSI
266 Host Controller). The SCSI Request Packet was not
267 sent, so no additional status information is available.
268 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
269 Request Packet to execute. See HostAdapterStatus,
270 TargetStatus, SenseDataLength, and SenseData in that
271 order for additional status information.
272
273 **/
274 EFI_STATUS
275 EFIAPI
276 ScsiModeSense10Command (
277 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
278 IN UINT64 Timeout,
279 IN OUT VOID *SenseData, OPTIONAL
280 IN OUT UINT8 *SenseDataLength,
281 OUT UINT8 *HostAdapterStatus,
282 OUT UINT8 *TargetStatus,
283 IN OUT VOID *DataBuffer, OPTIONAL
284 IN OUT UINT32 *DataLength,
285 IN UINT8 DBDField, OPTIONAL
286 IN UINT8 PageControl,
287 IN UINT8 PageCode
288 );
289
290
291
292 /**
293 Execute Request Sense SCSI command on a specific SCSI target.
294
295 Executes the Request Sense command on the SCSI target specified by ScsiIo.
296 If Timeout is zero, then this function waits indefinitely for the command to complete.
297 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
298 If ScsiIo is NULL, then ASSERT().
299 If SenseDataLength is NULL, then ASSERT().
300 If HostAdapterStatus is NULL, then ASSERT().
301 If TargetStatus is NULL, then ASSERT().
302
303 @param[in] ScsiIo A pointer to SCSI IO protocol.
304 @param[in] Timeout The length of timeout period.
305 @param[in, out] SenseData A pointer to output sense data.
306 @param[in, out] SenseDataLength The length of output sense data.
307 @param[out] HostAdapterStatus The status of Host Adapter.
308 @param[out] TargetStatus The status of the target.
309
310 @retval EFI_SUCCESS Command is executed successfully.
311 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are
312 too many SCSI Command Packets already queued.
313 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.
314 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by
315 the SCSI initiator(i.e., SCSI Host Controller)
316 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
317
318 **/
319 EFI_STATUS
320 EFIAPI
321 ScsiRequestSenseCommand (
322 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
323 IN UINT64 Timeout,
324 IN OUT VOID *SenseData, OPTIONAL
325 IN OUT UINT8 *SenseDataLength,
326 OUT UINT8 *HostAdapterStatus,
327 OUT UINT8 *TargetStatus
328 );
329
330
331 /**
332 Execute Read Capacity SCSI command on a specific SCSI target.
333
334 Executes the SCSI Read Capacity command on the SCSI target specified by ScsiIo.
335 If Timeout is zero, then this function waits indefinitely for the command to complete.
336 If Timeout is greater than zero, then the command is executed and will timeout after
337 Timeout 100 ns units. The PMI parameter is used to construct the CDB for this SCSI command.
338 If ScsiIo is NULL, then ASSERT().
339 If SenseDataLength is NULL, then ASSERT().
340 If HostAdapterStatus is NULL, then ASSERT().
341 If TargetStatus is NULL, then ASSERT().
342 If DataLength is NULL, then ASSERT().
343
344 @param[in] ScsiIo A pointer to SCSI IO protocol.
345 @param[in] Timeout The length of timeout period.
346 @param[in, out] SenseData A pointer to output sense data.
347 @param[in, out] SenseDataLength The length of output sense data.
348 @param[out] HostAdapterStatus The status of Host Adapter.
349 @param[out] TargetStatus The status of the target.
350 @param[in, out] DataBuffer A pointer to a data buffer.
351 @param[in, out] DataLength The length of data buffer.
352 @param[in] PMI Partial medium indicator.
353
354 @retval EFI_SUCCESS Command is executed successfully.
355 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could
356 not be transferred. The actual number of bytes transferred is returned in DataLength.
357 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
358 SCSI Command Packets already queued.
359 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.
360 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by
361 the SCSI initiator(i.e., SCSI Host Controller)
362 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
363
364 **/
365 EFI_STATUS
366 EFIAPI
367 ScsiReadCapacityCommand (
368 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
369 IN UINT64 Timeout,
370 IN OUT VOID *SenseData, OPTIONAL
371 IN OUT UINT8 *SenseDataLength,
372 OUT UINT8 *HostAdapterStatus,
373 OUT UINT8 *TargetStatus,
374 IN OUT VOID *DataBuffer, OPTIONAL
375 IN OUT UINT32 *DataLength,
376 IN BOOLEAN PMI
377 );
378
379
380 /**
381 Execute Read(10) SCSI command on a specific SCSI target.
382
383 Executes the SCSI Read(10) command on the SCSI target specified by ScsiIo.
384 If Timeout is zero, then this function waits indefinitely for the command to complete.
385 If Timeout is greater than zero, then the command is executed and will timeout
386 after Timeout 100 ns units. The StartLba and SectorSize parameters are used to
387 construct the CDB for this SCSI command.
388 If ScsiIo is NULL, then ASSERT().
389 If SenseDataLength is NULL, then ASSERT().
390 If HostAdapterStatus is NULL, then ASSERT().
391 If TargetStatus is NULL, then ASSERT().
392 If DataLength is NULL, then ASSERT().
393
394
395 @param[in] ScsiIo A pointer to SCSI IO protocol.
396 @param[in] Timeout The length of timeout period.
397 @param[in, out] SenseData A pointer to output sense data.
398 @param[in, out] SenseDataLength The length of output sense data.
399 @param[out] HostAdapterStatus The status of Host Adapter.
400 @param[out] TargetStatus The status of the target.
401 @param[in, out] DataBuffer Read 10 command data.
402 @param[in, out] DataLength The length of data buffer.
403 @param[in] StartLba The start address of LBA.
404 @param[in] SectorSize The sector size.
405
406 @retval EFI_SUCCESS Command is executed successfully.
407 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could
408 not be transferred. The actual number of bytes transferred is returned in DataLength.
409 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
410 SCSI Command Packets already queued.
411 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.
412 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by
413 the SCSI initiator(i.e., SCSI Host Controller)
414 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
415
416 **/
417 EFI_STATUS
418 EFIAPI
419 ScsiRead10Command (
420 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
421 IN UINT64 Timeout,
422 IN OUT VOID *SenseData, OPTIONAL
423 IN OUT UINT8 *SenseDataLength,
424 OUT UINT8 *HostAdapterStatus,
425 OUT UINT8 *TargetStatus,
426 IN OUT VOID *DataBuffer, OPTIONAL
427 IN OUT UINT32 *DataLength,
428 IN UINT32 StartLba,
429 IN UINT32 SectorSize
430 );
431
432
433 /**
434 Execute Write(10) SCSI command on a specific SCSI target.
435
436 Executes the SCSI Write(10) command on the SCSI target specified by ScsiIo.
437 If Timeout is zero, then this function waits indefinitely for the command to complete.
438 If Timeout is greater than zero, then the command is executed and will timeout after
439 Timeout 100 ns units. The StartLba and SectorSize parameters are used to construct
440 the CDB for this SCSI command.
441 If ScsiIo is NULL, then ASSERT().
442 If SenseDataLength is NULL, then ASSERT().
443 If HostAdapterStatus is NULL, then ASSERT().
444 If TargetStatus is NULL, then ASSERT().
445 If DataLength is NULL, then ASSERT().
446
447 @param[in] ScsiIo SCSI IO Protocol to use
448 @param[in] Timeout The length of timeout period.
449 @param[in, out] SenseData A pointer to output sense data.
450 @param[in, out] SenseDataLength The length of output sense data.
451 @param[out] HostAdapterStatus The status of Host Adapter.
452 @param[out] TargetStatus The status of the target.
453 @param[in, out] DataBuffer A pointer to a data buffer.
454 @param[in, out] DataLength The length of data buffer.
455 @param[in] StartLba The start address of LBA.
456 @param[in] SectorSize The sector size.
457
458 @retval EFI_SUCCESS Command is executed successfully.
459 @retval EFI_WARN_BUFFER_TOO_SMALL The SCSI Request Packet was executed, but the entire DataBuffer could
460 not be transferred. The actual number of bytes transferred is returned in DataLength.
461 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
462 SCSI Command Packets already queued.
463 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.
464 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by
465 the SCSI initiator(i.e., SCSI Host Controller)
466 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
467
468 **/
469 EFI_STATUS
470 EFIAPI
471 ScsiWrite10Command (
472 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
473 IN UINT64 Timeout,
474 IN OUT VOID *SenseData, OPTIONAL
475 IN OUT UINT8 *SenseDataLength,
476 OUT UINT8 *HostAdapterStatus,
477 OUT UINT8 *TargetStatus,
478 IN OUT VOID *DataBuffer, OPTIONAL
479 IN OUT UINT32 *DataLength,
480 IN UINT32 StartLba,
481 IN UINT32 SectorSize
482 );
483
484
485 #endif