]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/UefiScsiLib.h
Code have been checked 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 pointer 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 Packet 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
86 **/
87 EFI_STATUS
88 EFIAPI
89 ScsiTestUnitReadyCommand (
90 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
91 IN UINT64 Timeout,
92 IN OUT VOID *SenseData, OPTIONAL
93 IN OUT UINT8 *SenseDataLength,
94 OUT UINT8 *HostAdapterStatus,
95 OUT UINT8 *TargetStatus
96 );
97
98
99 /**
100 Execute Inquiry SCSI command on a specific SCSI target.
101
102 Executes the Inquiry command on the SCSI target specified by ScsiIo.
103 If Timeout is zero, then this function waits indefinitely for the command to complete.
104 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
105 If ScsiIo is NULL, then ASSERT().
106 If SenseDataLength is NULL, then ASSERT().
107 If HostAdapterStatus is NULL, then ASSERT().
108 If TargetStatus is NULL, then ASSERT().
109 If InquiryDataLength is NULL, then ASSERT().
110
111 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance
112 for the specific SCSI target.
113 @param[in] Timeout The timeout in 100 ns units to use for the
114 execution of this SCSI Request Packet. A Timeout
115 value of zero means that this function will wait
116 indefinitely for the SCSI Request Packet to execute.
117 If Timeout is greater than zero, then this function
118 will return EFI_TIMEOUT if the time required to
119 execute the SCSI Request Packet is greater than Timeout.
120 @param[in, out] SenseData A pointer to sense data that was generated
121 by the execution of the SCSI Request Packet.
122 This buffer must be allocated by the caller.
123 If SenseDataLength is 0, then this parameter
124 is optional and may be NULL.
125 @param[in, out] SenseDataLength On input, the length in bytes of the SenseData buffer.
126 On output, the number of bytes written to the SenseData buffer.
127 @param[out] HostAdapterStatus The status of the SCSI Host Controller that
128 produces the SCSI bus containing the SCSI
129 target specified by ScsiIo when the SCSI
130 Request Packet was executed. See the EFI
131 SCSI I/O Protocol in the UEFI Specification
132 for details on the possible return values.
133 @param[out] TargetStatus The status returned by the SCSI target specified
134 by ScsiIo when the SCSI Request Packet was
135 executed on the SCSI Host Controller.
136 See the EFI SCSI I/O Protocol in the UEFI
137 Specification for details on the possible
138 return values.
139 @param[in, out] InquiryDataBuffer A pointer to inquiry data that was generated
140 by the execution of the SCSI Request Packet.
141 This buffer must be allocated by the caller.
142 If InquiryDataLength is 0, then this parameter
143 is optional and may be NULL.
144 @param[in, out] InquiryDataLength On input, a pointer to the length in bytes
145 of the InquiryDataBuffer buffer.
146 On output, a pointer to the number of bytes
147 written to the InquiryDataBuffer buffer.
148 @param[in] EnableVitalProductData If TRUE, then the supported vital product
149 data is returned in InquiryDataBuffer.
150 If FALSE, then the standard inquiry data is
151 returned in InquiryDataBuffer.
152
153 @retval EFI_SUCCESS The command was executed successfully. See HostAdapterStatus,
154 TargetStatus, SenseDataLength, and SenseData in that order
155 for additional status information.
156 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire
157 InquiryDataBuffer could not be transferred. The actual
158 number of bytes transferred is returned in InquiryDataLength.
159 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there
160 are too many SCSI Command Packets already queued.
161 The SCSI Request Packet was not sent, so no additional
162 status information is available. The caller may retry again later.
163 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI
164 Request Packet. See HostAdapterStatus, TargetStatus,
165 SenseDataLength, and SenseData in that order for additional
166 status information.
167 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not
168 supported by the SCSI initiator(i.e., SCSI Host Controller).
169 The SCSI Request Packet was not sent, so no additional
170 status information is available.
171 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request
172 Packet to execute. See HostAdapterStatus, TargetStatus,
173 SenseDataLength, and SenseData in that order for
174 additional status information.
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 ScsiInquiryCommand (
180 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
181 IN UINT64 Timeout,
182 IN OUT VOID *SenseData, OPTIONAL
183 IN OUT UINT8 *SenseDataLength,
184 OUT UINT8 *HostAdapterStatus,
185 OUT UINT8 *TargetStatus,
186 IN OUT VOID *InquiryDataBuffer, OPTIONAL
187 IN OUT UINT32 *InquiryDataLength,
188 IN BOOLEAN EnableVitalProductData
189 );
190
191
192 /**
193 Execute Mode Sense(10) SCSI command on a specific SCSI target.
194
195 Executes the SCSI Mode Sense(10) command on the SCSI target specified by ScsiIo.
196 If Timeout is zero, then this function waits indefinitely for the command to complete.
197 If Timeout is greater than zero, then the command is executed and will timeout
198 after Timeout 100 ns units. The DBDField, PageControl, and PageCode parameters
199 are used to construct the CDB for this SCSI command.
200 If ScsiIo is NULL, then ASSERT().
201 If SenseDataLength is NULL, then ASSERT().
202 If HostAdapterStatus is NULL, then ASSERT().
203 If TargetStatus is NULL, then ASSERT().
204 If DataLength is NULL, then ASSERT().
205
206
207 @param[in] ScsiIo A pointer to the SCSI I/O Protocol instance
208 for the specific SCSI target.
209 @param[in] Timeout The timeout in 100 ns units to use for the
210 execution of this SCSI Request Packet. A Timeout
211 value of zero means that this function will wait
212 indefinitely for the SCSI Request Packet to execute.
213 If Timeout is greater than zero, then this function
214 will return EFI_TIMEOUT if the time required to
215 execute the SCSI Request Packet is greater than Timeout.
216 @param[in, out] SenseData A pointer to sense data that was generated
217 by the execution of the SCSI Request Packet.
218 This buffer must be allocated by the caller.
219 If SenseDataLength is 0, then this parameter
220 is optional and may be NULL.
221 @param[in, out] SenseDataLength On input, the length in bytes of the SenseData buffer.
222 On output, the number of bytes written to the SenseData buffer.
223 @param[out] HostAdapterStatus The status of the SCSI Host Controller that
224 produces the SCSI bus containing the SCSI target
225 specified by ScsiIo when the SCSI Request Packet
226 was executed. See the EFI SCSI I/O Protocol in the
227 UEFI Specification for details on the possible
228 return values.
229 @param[out] TargetStatus The status returned by the SCSI target specified
230 by ScsiIo when the SCSI Request Packet was executed
231 on the SCSI Host Controller. See the EFI SCSI
232 I/O Protocol in the UEFI Specification for details
233 on the possible return values.
234 @param[in, out] DataBuffer A pointer to data that was generated by the
235 execution of the SCSI Request Packet. This
236 buffer must be allocated by the caller. If
237 DataLength is 0, then this parameter is optional
238 and may be NULL.
239 @param[in, out] DataLength On input, a pointer to the length in bytes of
240 the DataBuffer buffer. On output, a pointer
241 to the number of bytes written to the DataBuffer
242 buffer.
243 @param[in] DBDField Specifies the DBD field of the CDB for this SCSI Command.
244 @param[in] PageControl Specifies the PC field of the CDB for this SCSI Command.
245 @param[in] PageCode Specifies the Page Control field of the CDB for this SCSI Command.
246
247 @retval EFI_SUCCESS The command was executed successfully.
248 See HostAdapterStatus, TargetStatus, SenseDataLength,
249 and SenseData in that order for additional status information.
250 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the
251 entire DataBuffer could not be transferred.
252 The actual number of bytes transferred is returned
253 in DataLength.
254 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
255 there are too many SCSI Command Packets already queued.
256 The SCSI Request Packet was not sent, so no additional
257 status information is available. The caller may retry
258 again later.
259 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send
260 SCSI Request Packet. See HostAdapterStatus, TargetStatus,
261 SenseDataLength, and SenseData in that order for
262 additional status information.
263 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
264 is not supported by the SCSI initiator(i.e., SCSI
265 Host Controller). The SCSI Request Packet was not
266 sent, so no additional status information is available.
267 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
268 Request Packet to execute. See HostAdapterStatus,
269 TargetStatus, SenseDataLength, and SenseData in that
270 order for additional status information.
271
272 **/
273 EFI_STATUS
274 EFIAPI
275 ScsiModeSense10Command (
276 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
277 IN UINT64 Timeout,
278 IN OUT VOID *SenseData, OPTIONAL
279 IN OUT UINT8 *SenseDataLength,
280 OUT UINT8 *HostAdapterStatus,
281 OUT UINT8 *TargetStatus,
282 IN OUT VOID *DataBuffer, OPTIONAL
283 IN OUT UINT32 *DataLength,
284 IN UINT8 DBDField, OPTIONAL
285 IN UINT8 PageControl,
286 IN UINT8 PageCode
287 );
288
289
290
291 /**
292 Execute Request Sense SCSI command on a specific SCSI target.
293
294 Executes the Request Sense command on the SCSI target specified by ScsiIo.
295 If Timeout is zero, then this function waits indefinitely for the command to complete.
296 If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
297 If ScsiIo is NULL, then ASSERT().
298 If SenseDataLength is NULL, then ASSERT().
299 If HostAdapterStatus is NULL, then ASSERT().
300 If TargetStatus is NULL, then ASSERT().
301
302 @param[in] ScsiIo A pointer to SCSI IO protocol.
303 @param[in] Timeout The length of timeout period.
304 @param[in, out] SenseData A pointer to output sense data.
305 @param[in, out] SenseDataLength The length of output sense data.
306 @param[out] HostAdapterStatus The status of Host Adapter.
307 @param[out] TargetStatus The status of the target.
308
309 @retval EFI_SUCCESS Command is executed successfully.
310 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are
311 too many SCSI Command Packets already queued.
312 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send SCSI Request Packet.
313 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported by
314 the SCSI initiator(i.e., SCSI Host Controller)
315 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
316
317 **/
318 EFI_STATUS
319 EFIAPI
320 ScsiRequestSenseCommand (
321 IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
322 IN UINT64 Timeout,
323 IN OUT VOID *SenseData, OPTIONAL
324 IN OUT UINT8 *SenseDataLength,
325 OUT UINT8 *HostAdapterStatus,
326 OUT UINT8 *TargetStatus
327 );
328
329
330 /**
331 Execute Read Capacity SCSI command on a specific SCSI target.
332
333 Executes the SCSI Read Capacity command on the SCSI target specified by ScsiIo.
334 If Timeout is zero, then this function waits indefinitely for the command to complete.
335 If Timeout is greater than zero, then the command is executed and will timeout after
336 Timeout 100 ns units. The PMI parameter is used to construct the CDB for this SCSI command.
337 If ScsiIo is NULL, then ASSERT().
338 If SenseDataLength is NULL, then ASSERT().
339 If HostAdapterStatus is NULL, then ASSERT().
340 If TargetStatus is NULL, then ASSERT().
341 If DataLength is NULL, then ASSERT().
342
343 @param[in] ScsiIo A pointer to SCSI IO protocol.
344 @param[in] Timeout The length of timeout period.
345 @param[in, out] SenseData A pointer to output sense data.
346 @param[in, out] SenseDataLength The length of output sense data.
347 @param[out] HostAdapterStatus The status of Host Adapter.
348 @param[out] TargetStatus The status of the target.
349 @param[in, out] DataBuffer A pointer to a data buffer.
350 @param[in, out] DataLength The length of data buffer.
351 @param[in] PMI Partial medium indicator.
352
353 @retval EFI_SUCCESS Command is executed successfully.
354 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, but the entire
355 DataBuffer could not be transferred. The actual
356 number of bytes transferred is returned in DataLength.
357 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because
358 there are too many 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
361 is not supported by 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_BAD_BUFFER_SIZE 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_BAD_BUFFER_SIZE 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