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