1 /** @file
2   Provides the functions to submit Scsi commands defined in SCSI-2 specification for SCSI devices.
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 - 2015, Intel Corporation. All rights reserved.<BR>
9 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   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
36   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
37   gets returned.
38 
39   @param[in]     ScsiIo             A pointer to the SCSI I/O Protocol instance
40                                     for the specific SCSI target.
41   @param[in]     Timeout            The timeout in 100 ns units to use for the execution
42                                     of this SCSI Request Packet. A Timeout value of
43                                     zero means that this function will wait indefinitely
44                                     for the SCSI Request Packet to execute. If Timeout
45                                     is greater than zero, then this function will return
46                                     EFI_TIMEOUT if the time required to execute the SCSI
47                                     Request Packet is greater than Timeout.
48   @param[in, out] SenseData         A pointer to sense data that was generated by
49                                     the execution of the SCSI Request Packet. This
50                                     buffer must be allocated by the caller.
51                                     If SenseDataLength is 0, then this parameter is
52                                     optional and may be NULL.
53   @param[in, out] SenseDataLength   On input, a pointer to the length in bytes of
54                                     the SenseData buffer. On output, a pointer to
55                                     the number of bytes written to the SenseData buffer.
56   @param[out]     HostAdapterStatus The status of the SCSI Host Controller that produces
57                                     the SCSI bus containing the SCSI target specified by
58                                     ScsiIo when the SCSI Request Packet was executed.
59                                     See the EFI SCSI I/O Protocol in the UEFI Specification
60                                     for details on the possible return values.
61   @param[out]     TargetStatus      The status returned by the SCSI target specified
62                                     by ScsiIo when the SCSI Request Packet was executed
63                                     on the SCSI Host Controller. See the EFI SCSI I/O
64                                     Protocol in the UEFI Specification for details on
65                                     the possible return values.
66 
67   @retval EFI_SUCCESS               The command was executed successfully.
68                                     See HostAdapterStatus, TargetStatus, SenseDataLength,
69                                     and SenseData in that order for additional status
70                                     information.
71   @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because
72                                     there are too many SCSI Command Packets already
73                                     queued. The SCSI Request Packet was not sent, so
74                                     no additional status information is available.
75                                     The caller may retry again later.
76   @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send
77                                     SCSI Request Packet.  See HostAdapterStatus,
78                                     TargetStatus, SenseDataLength, and SenseData in that
79                                     order for additional status information.
80   @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet
81                                     is not supported by the SCSI initiator(i.e., SCSI
82                                     Host Controller). The SCSI Request Packet was not
83                                     sent, so no additional status information is available.
84   @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI Request
85                                     Packet to execute.  See HostAdapterStatus, TargetStatus,
86                                     SenseDataLength, and SenseData in that order for
87                                     additional status information.
88   @retval EFI_INVALID_PARAMETER     The contents of the SCSI Request Packet are invalid.
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   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
116   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
117   gets returned.
118 
119   If InquiryDataLength is non-zero and InquiryDataBuffer is not NULL, InquiryDataBuffer
120   must meet buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
121   EFI_INVALID_PARAMETER gets returned.
122 
123   @param[in]      ScsiIo                 A pointer to the SCSI I/O Protocol instance
124                                          for the specific SCSI target.
125   @param[in]      Timeout                The timeout in 100 ns units to use for the
126                                          execution of this SCSI Request Packet. A Timeout
127                                          value of zero means that this function will wait
128                                          indefinitely for the SCSI Request Packet to execute.
129                                          If Timeout is greater than zero, then this function
130                                          will return EFI_TIMEOUT if the time required to
131                                          execute the SCSI Request Packet is greater than Timeout.
132   @param[in, out] SenseData              A pointer to sense data that was generated
133                                          by the execution of the SCSI Request Packet.
134                                          This buffer must be allocated by the caller.
135                                          If SenseDataLength is 0, then this parameter
136                                          is optional and may be NULL.
137   @param[in, out] SenseDataLength        On input, the length in bytes of the SenseData buffer.
138                                          On output, the number of bytes written to the SenseData buffer.
139   @param[out]     HostAdapterStatus      The status of the SCSI Host Controller that
140                                          produces the SCSI bus containing the SCSI
141                                          target specified by ScsiIo when the SCSI
142                                          Request Packet was executed.  See the EFI
143                                          SCSI I/O Protocol in the UEFI Specification
144                                          for details on the possible return values.
145   @param[out]     TargetStatus           The status returned by the SCSI target specified
146                                          by ScsiIo when the SCSI Request Packet was
147                                          executed on the SCSI Host Controller.
148                                          See the EFI SCSI I/O Protocol in the UEFI
149                                          Specification for details on the possible
150                                          return values.
151   @param[in, out] InquiryDataBuffer      A pointer to inquiry data that was generated
152                                          by the execution of the SCSI Request Packet.
153                                          This buffer must be allocated by the caller.
154                                          If InquiryDataLength is 0, then this parameter
155                                          is optional and may be NULL.
156   @param[in, out] InquiryDataLength      On input, a pointer to the length in bytes
157                                          of the InquiryDataBuffer buffer.
158                                          On output, a pointer to the number of bytes
159                                          written to the InquiryDataBuffer buffer.
160   @param[in]      EnableVitalProductData If TRUE, then the supported vital product
161                                          data is returned in InquiryDataBuffer.
162                                          If FALSE, then the standard inquiry data is
163                                          returned in InquiryDataBuffer.
164 
165   @retval EFI_SUCCESS                    The command was executed successfully. See HostAdapterStatus,
166                                          TargetStatus, SenseDataLength, and SenseData in that order
167                                          for additional status information.
168   @retval EFI_BAD_BUFFER_SIZE            The SCSI Request Packet was executed, but the entire
169                                          InquiryDataBuffer could not be transferred. The actual
170                                          number of bytes transferred is returned in InquiryDataLength.
171   @retval EFI_NOT_READY                  The SCSI Request Packet could not be sent because there
172                                          are too many SCSI Command Packets already queued.
173                                          The SCSI Request Packet was not sent, so no additional
174                                          status information is available. The caller may retry again later.
175   @retval EFI_DEVICE_ERROR               A device error occurred while attempting to send SCSI
176                                          Request Packet.  See HostAdapterStatus, TargetStatus,
177                                          SenseDataLength, and SenseData in that order for additional
178                                          status information.
179   @retval EFI_UNSUPPORTED                The command described by the SCSI Request Packet is not
180                                          supported by the SCSI initiator(i.e., SCSI  Host Controller).
181                                          The SCSI Request Packet was not sent, so no additional
182                                          status information is available.
183   @retval EFI_TIMEOUT                    A timeout occurred while waiting for the SCSI Request
184                                          Packet to execute.  See HostAdapterStatus, TargetStatus,
185                                          SenseDataLength, and SenseData in that order for
186                                          additional status information.
187   @retval EFI_INVALID_PARAMETER          The contents of the SCSI Request Packet are invalid.
188 
189 **/
190 EFI_STATUS
191 EFIAPI
192 ScsiInquiryCommand (
193   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
194   IN     UINT64                Timeout,
195   IN OUT VOID                  *SenseData,  OPTIONAL
196   IN OUT UINT8                 *SenseDataLength,
197      OUT UINT8                 *HostAdapterStatus,
198      OUT UINT8                 *TargetStatus,
199   IN OUT VOID                  *InquiryDataBuffer,    OPTIONAL
200   IN OUT UINT32                *InquiryDataLength,
201   IN     BOOLEAN               EnableVitalProductData
202   );
203 
204 
205 /**
206   Execute Inquiry SCSI command on a specific SCSI target.
207 
208   Executes the Inquiry command on the SCSI target specified by ScsiIo.
209   If Timeout is zero, then this function waits indefinitely for the command to complete.
210   If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
211   If ScsiIo is NULL, then ASSERT().
212   If SenseDataLength is NULL, then ASSERT().
213   If HostAdapterStatus is NULL, then ASSERT().
214   If TargetStatus is NULL, then ASSERT().
215   If InquiryDataLength is NULL, then ASSERT().
216 
217   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
218   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
219   gets returned.
220 
221   If InquiryDataLength is non-zero and InquiryDataBuffer is not NULL, InquiryDataBuffer
222   must meet buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
223   EFI_INVALID_PARAMETER gets returned.
224 
225   @param[in]      ScsiIo                 A pointer to the SCSI I/O Protocol instance
226                                          for the specific SCSI target.
227   @param[in]      Timeout                The timeout in 100 ns units to use for the
228                                          execution of this SCSI Request Packet. A Timeout
229                                          value of zero means that this function will wait
230                                          indefinitely for the SCSI Request Packet to execute.
231                                          If Timeout is greater than zero, then this function
232                                          will return EFI_TIMEOUT if the time required to
233                                          execute the SCSI Request Packet is greater than Timeout.
234   @param[in, out] SenseData              A pointer to sense data that was generated
235                                          by the execution of the SCSI Request Packet.
236                                          This buffer must be allocated by the caller.
237                                          If SenseDataLength is 0, then this parameter
238                                          is optional and may be NULL.
239   @param[in, out] SenseDataLength        On input, the length in bytes of the SenseData buffer.
240                                          On output, the number of bytes written to the SenseData buffer.
241   @param[out]     HostAdapterStatus      The status of the SCSI Host Controller that
242                                          produces the SCSI bus containing the SCSI
243                                          target specified by ScsiIo when the SCSI
244                                          Request Packet was executed.  See the EFI
245                                          SCSI I/O Protocol in the UEFI Specification
246                                          for details on the possible return values.
247   @param[out]     TargetStatus           The status returned by the SCSI target specified
248                                          by ScsiIo when the SCSI Request Packet was
249                                          executed on the SCSI Host Controller.
250                                          See the EFI SCSI I/O Protocol in the UEFI
251                                          Specification for details on the possible
252                                          return values.
253   @param[in, out] InquiryDataBuffer      A pointer to inquiry data that was generated
254                                          by the execution of the SCSI Request Packet.
255                                          This buffer must be allocated by the caller.
256                                          If InquiryDataLength is 0, then this parameter
257                                          is optional and may be NULL.
258   @param[in, out] InquiryDataLength      On input, a pointer to the length in bytes
259                                          of the InquiryDataBuffer buffer.
260                                          On output, a pointer to the number of bytes
261                                          written to the InquiryDataBuffer buffer.
262   @param[in]      EnableVitalProductData If TRUE, then the supported vital product
263                                          data for the PageCode is returned in InquiryDataBuffer.
264                                          If FALSE, then the standard inquiry data is
265                                          returned in InquiryDataBuffer and PageCode is ignored.
266   @param[in]      PageCode               The page code of the vital product data.
267                                          It's ignored if EnableVitalProductData is FALSE.
268 
269   @retval EFI_SUCCESS                    The command executed successfully. See HostAdapterStatus,
270                                          TargetStatus, SenseDataLength, and SenseData in that order
271                                          for additional status information.
272   @retval EFI_BAD_BUFFER_SIZE            The SCSI Request Packet was executed, but the entire
273                                          InquiryDataBuffer could not be transferred. The actual
274                                          number of bytes transferred is returned in InquiryDataLength.
275   @retval EFI_NOT_READY                  The SCSI Request Packet could not be sent because there
276                                          are too many SCSI Command Packets already queued.
277                                          The SCSI Request Packet was not sent, so no additional
278                                          status information is available. The caller may retry again later.
279   @retval EFI_DEVICE_ERROR               A device error occurred while attempting to send SCSI
280                                          Request Packet.  See HostAdapterStatus, TargetStatus,
281                                          SenseDataLength, and SenseData in that order for additional
282                                          status information.
283   @retval EFI_UNSUPPORTED                The command described by the SCSI Request Packet is not
284                                          supported by the SCSI initiator(i.e., SCSI  Host Controller).
285                                          The SCSI Request Packet was not sent, so no additional
286                                          status information is available.
287   @retval EFI_TIMEOUT                    A timeout occurred while waiting for the SCSI Request
288                                          Packet to execute.  See HostAdapterStatus, TargetStatus,
289                                          SenseDataLength, and SenseData in that order for
290                                          additional status information.
291   @retval EFI_INVALID_PARAMETER          The contents of the SCSI Request Packet are invalid.
292 
293 **/
294 EFI_STATUS
295 EFIAPI
296 ScsiInquiryCommandEx (
297   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
298   IN     UINT64                Timeout,
299   IN OUT VOID                  *SenseData,  OPTIONAL
300   IN OUT UINT8                 *SenseDataLength,
301      OUT UINT8                 *HostAdapterStatus,
302      OUT UINT8                 *TargetStatus,
303   IN OUT VOID                  *InquiryDataBuffer,    OPTIONAL
304   IN OUT UINT32                *InquiryDataLength,
305   IN     BOOLEAN               EnableVitalProductData,
306   IN     UINT8                 PageCode
307   );
308 
309 
310 /**
311   Execute Mode Sense(10) SCSI command on a specific SCSI target.
312 
313   Executes the SCSI Mode Sense(10) command on the SCSI target specified by ScsiIo.
314   If Timeout is zero, then this function waits indefinitely for the command to complete.
315   If Timeout is greater than zero, then the command is executed and will timeout
316   after Timeout 100 ns units.  The DBDField, PageControl, and PageCode parameters
317   are used to construct the CDB for this SCSI command.
318   If ScsiIo is NULL, then ASSERT().
319   If SenseDataLength is NULL, then ASSERT().
320   If HostAdapterStatus is NULL, then ASSERT().
321   If TargetStatus is NULL, then ASSERT().
322   If DataLength is NULL, then ASSERT().
323 
324   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
325   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
326   gets returned.
327 
328   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
329   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
330   gets returned.
331 
332   @param[in]      ScsiIo             A pointer to the SCSI I/O Protocol instance
333                                      for the specific SCSI target.
334   @param[in]      Timeout            The timeout in 100 ns units to use for the
335                                      execution of this SCSI Request Packet. A Timeout
336                                      value of zero means that this function will wait
337                                      indefinitely for the SCSI Request Packet to execute.
338                                      If Timeout is greater than zero, then this function
339                                      will return EFI_TIMEOUT if the time required to
340                                      execute the SCSI Request Packet is greater than Timeout.
341   @param[in, out]  SenseData         A pointer to sense data that was generated
342                                      by the execution of the SCSI Request Packet.
343                                      This buffer must be allocated by the caller.
344                                      If SenseDataLength is 0, then this parameter
345                                      is optional and may be NULL.
346   @param[in, out]  SenseDataLength   On input, the length in bytes of the SenseData buffer.
347                                      On output, the number of bytes written to the SenseData buffer.
348   @param[out]     HostAdapterStatus  The status of the SCSI Host Controller that
349                                      produces the SCSI bus containing the SCSI target
350                                      specified by ScsiIo when the SCSI Request Packet
351                                      was executed. See the EFI SCSI I/O Protocol in the
352                                      UEFI Specification for details on the possible
353                                      return values.
354   @param[out]     TargetStatus       The status returned by the SCSI target specified
355                                      by ScsiIo when the SCSI Request Packet was executed
356                                      on the SCSI Host Controller.  See the EFI SCSI
357                                      I/O Protocol in the UEFI Specification for details
358                                      on the possible return values.
359   @param[in, out]  DataBuffer        A pointer to data that was generated by the
360                                      execution of the SCSI Request Packet.  This
361                                      buffer must be allocated by the caller. If
362                                      DataLength is 0, then this parameter is optional
363                                      and may be NULL.
364   @param[in, out]  DataLength        On input, a pointer to the length in bytes of
365                                      the DataBuffer buffer.  On output, a pointer
366                                      to the number of bytes written to the DataBuffer
367                                      buffer.
368   @param[in]      DBDField           Specifies the DBD field of the CDB for this SCSI Command.
369   @param[in]      PageControl        Specifies the PC field of the CDB for this SCSI Command.
370   @param[in]      PageCode           Specifies the Page Control field of the CDB for this SCSI Command.
371 
372   @retval EFI_SUCCESS                The command was executed successfully.
373                                      See HostAdapterStatus, TargetStatus, SenseDataLength,
374                                      and SenseData in that order for additional status information.
375   @retval EFI_BAD_BUFFER_SIZE        The SCSI Request Packet was executed, but the
376                                      entire DataBuffer could not be transferred.
377                                      The actual number of bytes transferred is returned
378                                      in DataLength.
379   @retval EFI_NOT_READY              The SCSI Request Packet could not be sent because
380                                      there are too many SCSI Command Packets already queued.
381                                      The SCSI Request Packet was not sent, so no additional
382                                      status information is available.  The caller may retry
383                                      again later.
384   @retval EFI_DEVICE_ERROR           A device error occurred while attempting to send
385                                      SCSI Request Packet.  See HostAdapterStatus, TargetStatus,
386                                      SenseDataLength, and SenseData in that order for
387                                      additional status information.
388   @retval EFI_UNSUPPORTED            The command described by the SCSI Request Packet
389                                      is not supported by the SCSI initiator(i.e., SCSI
390                                      Host Controller). The SCSI Request Packet was not
391                                      sent, so no additional status information is available.
392   @retval EFI_TIMEOUT                A timeout occurred while waiting for the SCSI
393                                      Request Packet to execute.  See HostAdapterStatus,
394                                      TargetStatus, SenseDataLength, and SenseData in that
395                                      order for additional status information.
396   @retval EFI_INVALID_PARAMETER      The contents of the SCSI Request Packet are invalid.
397 
398 **/
399 EFI_STATUS
400 EFIAPI
401 ScsiModeSense10Command (
402   IN     EFI_SCSI_IO_PROTOCOL    *ScsiIo,
403   IN     UINT64                  Timeout,
404   IN OUT VOID                    *SenseData,  OPTIONAL
405   IN OUT UINT8                   *SenseDataLength,
406      OUT UINT8                   *HostAdapterStatus,
407      OUT UINT8                   *TargetStatus,
408   IN OUT VOID                    *DataBuffer, OPTIONAL
409   IN OUT UINT32                  *DataLength,
410   IN     UINT8                   DBDField,    OPTIONAL
411   IN     UINT8                   PageControl,
412   IN     UINT8                   PageCode
413   );
414 
415 
416 
417 /**
418   Execute Request Sense SCSI command on a specific SCSI target.
419 
420   Executes the Request Sense command on the SCSI target specified by ScsiIo.
421   If Timeout is zero, then this function waits indefinitely for the command to complete.
422   If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.
423   If ScsiIo is NULL, then ASSERT().
424   If SenseDataLength is NULL, then ASSERT().
425   If HostAdapterStatus is NULL, then ASSERT().
426   If TargetStatus is NULL, then ASSERT().
427 
428   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
429   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
430   gets returned.
431 
432   @param[in]       ScsiIo               A pointer to SCSI IO protocol.
433   @param[in]       Timeout              The length of timeout period.
434   @param[in, out]  SenseData            A pointer to output sense data.
435   @param[in, out]  SenseDataLength      The length of output sense data.
436   @param[out]      HostAdapterStatus    The status of Host Adapter.
437   @param[out]      TargetStatus         The status of the target.
438 
439   @retval EFI_SUCCESS                   Command is executed successfully.
440   @retval EFI_NOT_READY                 The SCSI Request Packet could not be sent because there are
441                                         too many SCSI Command Packets already queued.
442   @retval EFI_DEVICE_ERROR              A device error occurred while attempting to send SCSI Request Packet.
443   @retval EFI_UNSUPPORTED               The command described by the SCSI Request Packet is not supported by
444                                         the SCSI initiator(i.e., SCSI  Host Controller)
445   @retval EFI_TIMEOUT                   A timeout occurred while waiting for the SCSI Request Packet to execute.
446   @retval EFI_INVALID_PARAMETER         The contents of the SCSI Request Packet are invalid.
447 
448 **/
449 EFI_STATUS
450 EFIAPI
451 ScsiRequestSenseCommand (
452   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
453   IN     UINT64                Timeout,
454   IN OUT VOID                  *SenseData,  OPTIONAL
455   IN OUT UINT8                 *SenseDataLength,
456      OUT UINT8                 *HostAdapterStatus,
457      OUT UINT8                 *TargetStatus
458   );
459 
460 
461 /**
462   Execute Read Capacity SCSI command on a specific SCSI target.
463 
464   Executes the SCSI Read Capacity command on the SCSI target specified by ScsiIo.
465   If Timeout is zero, then this function waits indefinitely for the command to complete.
466   If Timeout is greater than zero, then the command is executed and will timeout after
467   Timeout 100 ns units.  The Pmi parameter is used to construct the CDB for this SCSI command.
468   If ScsiIo is NULL, then ASSERT().
469   If SenseDataLength is NULL, then ASSERT().
470   If HostAdapterStatus is NULL, then ASSERT().
471   If TargetStatus is NULL, then ASSERT().
472   If DataLength is NULL, then ASSERT().
473 
474   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
475   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
476   gets returned.
477 
478   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
479   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
480   gets returned.
481 
482   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
483   @param[in]      Timeout              The length of timeout period.
484   @param[in, out] SenseData            A pointer to output sense data.
485   @param[in, out] SenseDataLength      The length of output sense data.
486   @param[out]     HostAdapterStatus    The status of Host Adapter.
487   @param[out]     TargetStatus         The status of the target.
488   @param[in, out] DataBuffer           A pointer to a data buffer.
489   @param[in, out] DataLength           The length of data buffer.
490   @param[in]      Pmi                  Partial medium indicator.
491 
492   @retval  EFI_SUCCESS                 Command is executed successfully.
493   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire
494                                        DataBuffer could not be transferred. The actual
495                                        number of bytes transferred is returned in DataLength.
496   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because
497                                        there are too many SCSI Command Packets already queued.
498   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
499   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet
500                                        is not supported by the SCSI initiator(i.e., SCSI  Host Controller)
501   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
502   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
503 
504 **/
505 EFI_STATUS
506 EFIAPI
507 ScsiReadCapacityCommand (
508   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
509   IN     UINT64                Timeout,
510   IN OUT VOID                  *SenseData,    OPTIONAL
511   IN OUT UINT8                 *SenseDataLength,
512      OUT UINT8                 *HostAdapterStatus,
513      OUT UINT8                 *TargetStatus,
514   IN OUT VOID                  *DataBuffer,   OPTIONAL
515   IN OUT UINT32                *DataLength,
516   IN     BOOLEAN               Pmi
517   );
518 
519 
520 /**
521   Execute Read Capacity SCSI 16 command on a specific SCSI target.
522 
523   Executes the SCSI Read Capacity 16 command on the SCSI target specified by ScsiIo.
524   If Timeout is zero, then this function waits indefinitely for the command to complete.
525   If Timeout is greater than zero, then the command is executed and will timeout after
526   Timeout 100 ns units.  The Pmi parameter is used to construct the CDB for this SCSI command.
527   If ScsiIo is NULL, then ASSERT().
528   If SenseDataLength is NULL, then ASSERT().
529   If HostAdapterStatus is NULL, then ASSERT().
530   If TargetStatus is NULL, then ASSERT().
531   If DataLength is NULL, then ASSERT().
532 
533   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
534   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
535   gets returned.
536 
537   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
538   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
539   gets returned.
540 
541   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
542   @param[in]      Timeout              The length of timeout period.
543   @param[in, out] SenseData            A pointer to output sense data.
544   @param[in, out] SenseDataLength      The length of output sense data.
545   @param[out]     HostAdapterStatus    The status of Host Adapter.
546   @param[out]     TargetStatus         The status of the target.
547   @param[in, out] DataBuffer           A pointer to a data buffer.
548   @param[in, out] DataLength           The length of data buffer.
549   @param[in]      Pmi                  Partial medium indicator.
550 
551   @retval  EFI_SUCCESS                 Command is executed successfully.
552   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire
553                                        DataBuffer could not be transferred. The actual
554                                        number of bytes transferred is returned in DataLength.
555   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because
556                                        there are too many SCSI Command Packets already queued.
557   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
558   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet
559                                        is not supported by the SCSI initiator(i.e., SCSI  Host Controller)
560   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
561   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
562 
563 **/
564 EFI_STATUS
565 EFIAPI
566 ScsiReadCapacity16Command (
567   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
568   IN     UINT64                Timeout,
569   IN OUT VOID                  *SenseData,  OPTIONAL
570   IN OUT UINT8                 *SenseDataLength,
571      OUT UINT8                 *HostAdapterStatus,
572      OUT UINT8                 *TargetStatus,
573   IN OUT VOID                  *DataBuffer, OPTIONAL
574   IN OUT UINT32                *DataLength,
575   IN     BOOLEAN               Pmi
576   );
577 
578 
579 /**
580   Execute Read(10) SCSI command on a specific SCSI target.
581 
582   Executes the SCSI Read(10) command on the SCSI target specified by ScsiIo.
583   If Timeout is zero, then this function waits indefinitely for the command to complete.
584   If Timeout is greater than zero, then the command is executed and will timeout
585   after Timeout 100 ns units.  The StartLba and SectorSize parameters are used to
586   construct the CDB for this SCSI command.
587   If ScsiIo is NULL, then ASSERT().
588   If SenseDataLength is NULL, then ASSERT().
589   If HostAdapterStatus is NULL, then ASSERT().
590   If TargetStatus is NULL, then ASSERT().
591   If DataLength is NULL, then ASSERT().
592 
593   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
594   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
595   gets returned.
596 
597   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
598   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
599   gets returned.
600 
601   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
602   @param[in]      Timeout              The length of timeout period.
603   @param[in, out] SenseData            A pointer to output sense data.
604   @param[in, out] SenseDataLength      The length of output sense data.
605   @param[out]     HostAdapterStatus    The status of Host Adapter.
606   @param[out]     TargetStatus         The status of the target.
607   @param[in, out] DataBuffer           Read 10 command data.
608   @param[in, out] DataLength           The length of data buffer.
609   @param[in]      StartLba             The start address of LBA.
610   @param[in]      SectorSize           The number of contiguous logical blocks of data that shall be transferred.
611 
612   @retval  EFI_SUCCESS                 Command is executed successfully.
613   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
614                                        not be transferred. The actual number of bytes transferred is returned in DataLength.
615   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
616                                        SCSI Command Packets already queued.
617   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
618   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
619                                        the SCSI initiator(i.e., SCSI  Host Controller)
620   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
621   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
622 
623 **/
624 EFI_STATUS
625 EFIAPI
626 ScsiRead10Command (
627   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
628   IN     UINT64                Timeout,
629   IN OUT VOID                  *SenseData,   OPTIONAL
630   IN OUT UINT8                 *SenseDataLength,
631      OUT UINT8                 *HostAdapterStatus,
632      OUT UINT8                 *TargetStatus,
633   IN OUT VOID                  *DataBuffer,  OPTIONAL
634   IN OUT UINT32                *DataLength,
635   IN     UINT32                StartLba,
636   IN     UINT32                SectorSize
637   );
638 
639 
640 /**
641   Execute Write(10) SCSI command on a specific SCSI target.
642 
643   Executes the SCSI Write(10) command on the SCSI target specified by ScsiIo.
644   If Timeout is zero, then this function waits indefinitely for the command to complete.
645   If Timeout is greater than zero, then the command is executed and will timeout after
646   Timeout 100 ns units.  The StartLba and SectorSize parameters are used to construct
647   the CDB for this SCSI command.
648   If ScsiIo is NULL, then ASSERT().
649   If SenseDataLength is NULL, then ASSERT().
650   If HostAdapterStatus is NULL, then ASSERT().
651   If TargetStatus is NULL, then ASSERT().
652   If DataLength is NULL, then ASSERT().
653 
654   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
655   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
656   gets returned.
657 
658   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
659   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
660   gets returned.
661 
662   @param[in]      ScsiIo               SCSI IO Protocol to use
663   @param[in]      Timeout              The length of timeout period.
664   @param[in, out] SenseData            A pointer to output sense data.
665   @param[in, out] SenseDataLength      The length of output sense data.
666   @param[out]     HostAdapterStatus    The status of Host Adapter.
667   @param[out]     TargetStatus         The status of the target.
668   @param[in, out] DataBuffer           A pointer to a data buffer.
669   @param[in, out] DataLength           The length of data buffer.
670   @param[in]      StartLba             The start address of LBA.
671   @param[in]      SectorSize           The number of contiguous logical blocks of data that shall be transferred.
672 
673   @retval  EFI_SUCCESS                 Command is executed successfully.
674   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
675                                        not be transferred. The actual number of bytes transferred is returned in DataLength.
676   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
677                                        SCSI Command Packets already queued.
678   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
679   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
680                                        the SCSI initiator(i.e., SCSI  Host Controller)
681   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
682   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
683 
684 **/
685 EFI_STATUS
686 EFIAPI
687 ScsiWrite10Command (
688   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
689   IN     UINT64                Timeout,
690   IN OUT VOID                  *SenseData,   OPTIONAL
691   IN OUT UINT8                 *SenseDataLength,
692      OUT UINT8                 *HostAdapterStatus,
693      OUT UINT8                 *TargetStatus,
694   IN OUT VOID                  *DataBuffer,  OPTIONAL
695   IN OUT UINT32                *DataLength,
696   IN     UINT32                StartLba,
697   IN     UINT32                SectorSize
698   );
699 
700 /**
701   Execute Read(16) SCSI command on a specific SCSI target.
702 
703   Executes the SCSI Read(16) command on the SCSI target specified by ScsiIo.
704   If Timeout is zero, then this function waits indefinitely for the command to complete.
705   If Timeout is greater than zero, then the command is executed and will timeout
706   after Timeout 100 ns units.  The StartLba and SectorSize parameters are used to
707   construct the CDB for this SCSI command.
708   If ScsiIo is NULL, then ASSERT().
709   If SenseDataLength is NULL, then ASSERT().
710   If HostAdapterStatus is NULL, then ASSERT().
711   If TargetStatus is NULL, then ASSERT().
712   If DataLength is NULL, then ASSERT().
713 
714   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
715   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
716   gets returned.
717 
718   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
719   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
720   gets returned.
721 
722   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
723   @param[in]      Timeout              The length of timeout period.
724   @param[in, out] SenseData            A pointer to output sense data.
725   @param[in, out] SenseDataLength      The length of output sense data.
726   @param[out]     HostAdapterStatus    The status of Host Adapter.
727   @param[out]     TargetStatus         The status of the target.
728   @param[in, out] DataBuffer           Read 16 command data.
729   @param[in, out] DataLength           The length of data buffer.
730   @param[in]      StartLba             The start address of LBA.
731   @param[in]      SectorSize           The number of contiguous logical blocks of data that shall be transferred.
732 
733   @retval  EFI_SUCCESS                 Command is executed successfully.
734   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
735                                        not be transferred. The actual number of bytes transferred is returned in DataLength.
736   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
737                                        SCSI Command Packets already queued.
738   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
739   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
740                                        the SCSI initiator(i.e., SCSI  Host Controller)
741   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
742   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
743 
744 **/
745 EFI_STATUS
746 EFIAPI
747 ScsiRead16Command (
748   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
749   IN     UINT64                Timeout,
750   IN OUT VOID                  *SenseData,   OPTIONAL
751   IN OUT UINT8                 *SenseDataLength,
752      OUT UINT8                 *HostAdapterStatus,
753      OUT UINT8                 *TargetStatus,
754   IN OUT VOID                  *DataBuffer,  OPTIONAL
755   IN OUT UINT32                *DataLength,
756   IN     UINT64                StartLba,
757   IN     UINT32                SectorSize
758   );
759 
760 
761 /**
762   Execute Write(16) SCSI command on a specific SCSI target.
763 
764   Executes the SCSI Write(16) command on the SCSI target specified by ScsiIo.
765   If Timeout is zero, then this function waits indefinitely for the command to complete.
766   If Timeout is greater than zero, then the command is executed and will timeout after
767   Timeout 100 ns units.  The StartLba and SectorSize parameters are used to construct
768   the CDB for this SCSI command.
769   If ScsiIo is NULL, then ASSERT().
770   If SenseDataLength is NULL, then ASSERT().
771   If HostAdapterStatus is NULL, then ASSERT().
772   If TargetStatus is NULL, then ASSERT().
773   If DataLength is NULL, then ASSERT().
774 
775   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
776   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
777   gets returned.
778 
779   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
780   alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
781   gets returned.
782 
783   @param[in]      ScsiIo               SCSI IO Protocol to use
784   @param[in]      Timeout              The length of timeout period.
785   @param[in, out] SenseData            A pointer to output sense data.
786   @param[in, out] SenseDataLength      The length of output sense data.
787   @param[out]     HostAdapterStatus    The status of Host Adapter.
788   @param[out]     TargetStatus         The status of the target.
789   @param[in, out] DataBuffer           A pointer to a data buffer.
790   @param[in, out] DataLength           The length of data buffer.
791   @param[in]      StartLba             The start address of LBA.
792   @param[in]      SectorSize           The number of contiguous logical blocks of data that shall be transferred.
793 
794   @retval  EFI_SUCCESS                 Command is executed successfully.
795   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
796                                        not be transferred. The actual number of bytes transferred is returned in DataLength.
797   @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
798                                        SCSI Command Packets already queued.
799   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
800   @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
801                                        the SCSI initiator(i.e., SCSI  Host Controller)
802   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
803   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
804 
805 **/
806 EFI_STATUS
807 EFIAPI
808 ScsiWrite16Command (
809   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
810   IN     UINT64                Timeout,
811   IN OUT VOID                  *SenseData,   OPTIONAL
812   IN OUT UINT8                 *SenseDataLength,
813      OUT UINT8                 *HostAdapterStatus,
814      OUT UINT8                 *TargetStatus,
815   IN OUT VOID                  *DataBuffer,  OPTIONAL
816   IN OUT UINT32                *DataLength,
817   IN     UINT64                StartLba,
818   IN     UINT32                SectorSize
819   );
820 
821 
822 /**
823   Execute blocking/non-blocking Read(10) SCSI command on a specific SCSI
824   target.
825 
826   Executes the SCSI Read(10) command on the SCSI target specified by ScsiIo.
827   When Event is NULL, blocking command will be executed. Otherwise non-blocking
828   command will be executed.
829   For blocking I/O, if Timeout is zero, this function will wait indefinitely
830   for the command to complete. If Timeout is greater than zero, then the
831   command is executed and will timeout after Timeout 100 ns units.
832   For non-blocking I/O, if Timeout is zero, Event will be signaled only after
833   the command to completes. If Timeout is greater than zero, Event will also be
834   signaled after Timeout 100 ns units.
835   The StartLba and SectorSize parameters are used to construct the CDB for this
836   SCSI command.
837 
838   If ScsiIo is NULL, then ASSERT().
839   If SenseDataLength is NULL, then ASSERT().
840   If HostAdapterStatus is NULL, then ASSERT().
841   If TargetStatus is NULL, then ASSERT().
842   If DataLength is NULL, then ASSERT().
843 
844   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet
845   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
846   EFI_INVALID_PARAMETER gets returned.
847 
848   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet
849   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
850   EFI_INVALID_PARAMETER gets returned.
851 
852   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
853   @param[in]      Timeout              The length of timeout period.
854   @param[in, out] SenseData            A pointer to output sense data.
855   @param[in, out] SenseDataLength      The length of output sense data.
856   @param[out]     HostAdapterStatus    The status of Host Adapter.
857   @param[out]     TargetStatus         The status of the target.
858   @param[in, out] DataBuffer           Read 16 command data.
859   @param[in, out] DataLength           The length of data buffer.
860   @param[in]      StartLba             The start address of LBA.
861   @param[in]      SectorSize           The number of contiguous logical blocks
862                                        of data that shall be transferred.
863   @param[in]      Event                If the SCSI target does not support
864                                        non-blocking I/O, then Event is ignored,
865                                        and blocking I/O is performed. If Event
866                                        is NULL, then blocking I/O is performed.
867                                        If Event is not NULL and non-blocking
868                                        I/O is supported, then non-blocking I/O
869                                        is performed, and Event will be signaled
870                                        when the SCSI Read(10) command
871                                        completes.
872 
873   @retval  EFI_SUCCESS                 Command is executed successfully.
874   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed,
875                                        but the entire DataBuffer could not be
876                                        transferred. The actual number of bytes
877                                        transferred is returned in DataLength.
878   @retval  EFI_NOT_READY               The SCSI Request Packet could not be
879                                        sent because there are too many SCSI
880                                        Command Packets already queued.
881   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting
882                                        to send SCSI Request Packet.
883   @retval  EFI_UNSUPPORTED             The command described by the SCSI
884                                        Request Packet is not supported by the
885                                        SCSI initiator(i.e., SCSI  Host
886                                        Controller)
887   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the
888                                        SCSI Request Packet to execute.
889   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet
890                                        are invalid.
891   @retval  EFI_OUT_OF_RESOURCES        The request could not be completed due
892                                        to a lack of resources.
893 
894 **/
895 EFI_STATUS
896 EFIAPI
897 ScsiRead10CommandEx (
898   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
899   IN     UINT64                Timeout,
900   IN OUT VOID                  *SenseData,   OPTIONAL
901   IN OUT UINT8                 *SenseDataLength,
902      OUT UINT8                 *HostAdapterStatus,
903      OUT UINT8                 *TargetStatus,
904   IN OUT VOID                  *DataBuffer,  OPTIONAL
905   IN OUT UINT32                *DataLength,
906   IN     UINT32                StartLba,
907   IN     UINT32                SectorSize,
908   IN     EFI_EVENT             Event         OPTIONAL
909   );
910 
911 
912 /**
913   Execute blocking/non-blocking Write(10) SCSI command on a specific SCSI
914   target.
915 
916   Executes the SCSI Write(10) command on the SCSI target specified by ScsiIo.
917   When Event is NULL, blocking command will be executed. Otherwise non-blocking
918   command will be executed.
919   For blocking I/O, if Timeout is zero, this function will wait indefinitely
920   for the command to complete. If Timeout is greater than zero, then the
921   command is executed and will timeout after Timeout 100 ns units.
922   For non-blocking I/O, if Timeout is zero, Event will be signaled only after
923   the command to completes. If Timeout is greater than zero, Event will also be
924   signaled after Timeout 100 ns units.
925   The StartLba and SectorSize parameters are used to construct the CDB for this
926   SCSI command.
927 
928   If ScsiIo is NULL, then ASSERT().
929   If SenseDataLength is NULL, then ASSERT().
930   If HostAdapterStatus is NULL, then ASSERT().
931   If TargetStatus is NULL, then ASSERT().
932   If DataLength is NULL, then ASSERT().
933 
934   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet
935   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
936   EFI_INVALID_PARAMETER gets returned.
937 
938   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet
939   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
940   EFI_INVALID_PARAMETER gets returned.
941 
942   @param[in]      ScsiIo               SCSI IO Protocol to use
943   @param[in]      Timeout              The length of timeout period.
944   @param[in, out] SenseData            A pointer to output sense data.
945   @param[in, out] SenseDataLength      The length of output sense data.
946   @param[out]     HostAdapterStatus    The status of Host Adapter.
947   @param[out]     TargetStatus         The status of the target.
948   @param[in, out] DataBuffer           A pointer to a data buffer.
949   @param[in, out] DataLength           The length of data buffer.
950   @param[in]      StartLba             The start address of LBA.
951   @param[in]      SectorSize           The number of contiguous logical blocks
952                                        of data that shall be transferred.
953   @param[in]      Event                If the SCSI target does not support
954                                        non-blocking I/O, then Event is ignored,
955                                        and blocking I/O is performed. If Event
956                                        is NULL, then blocking I/O is performed.
957                                        If Event is not NULL and non-blocking
958                                        I/O is supported, then non-blocking I/O
959                                        is performed, and Event will be signaled
960                                        when the SCSI Write(10) command
961                                        completes.
962 
963   @retval  EFI_SUCCESS                 Command is executed successfully.
964   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed,
965                                        but the entire DataBuffer could not be
966                                        transferred. The actual number of bytes
967                                        transferred is returned in DataLength.
968   @retval  EFI_NOT_READY               The SCSI Request Packet could not be
969                                        sent because there are too many SCSI
970                                        Command Packets already queued.
971   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting
972                                        to send SCSI Request Packet.
973   @retval  EFI_UNSUPPORTED             The command described by the SCSI
974                                        Request Packet is not supported by the
975                                        SCSI initiator(i.e., SCSI  Host
976                                        Controller)
977   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the
978                                        SCSI Request Packet to execute.
979   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet
980                                        are invalid.
981   @retval  EFI_OUT_OF_RESOURCES        The request could not be completed due
982                                        to a lack of resources.
983 
984 **/
985 EFI_STATUS
986 EFIAPI
987 ScsiWrite10CommandEx (
988   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
989   IN     UINT64                Timeout,
990   IN OUT VOID                  *SenseData,   OPTIONAL
991   IN OUT UINT8                 *SenseDataLength,
992      OUT UINT8                 *HostAdapterStatus,
993      OUT UINT8                 *TargetStatus,
994   IN OUT VOID                  *DataBuffer,  OPTIONAL
995   IN OUT UINT32                *DataLength,
996   IN     UINT32                StartLba,
997   IN     UINT32                SectorSize,
998   IN     EFI_EVENT             Event         OPTIONAL
999   );
1000 
1001 
1002 /**
1003   Execute blocking/non-blocking Read(16) SCSI command on a specific SCSI
1004   target.
1005 
1006   Executes the SCSI Read(16) command on the SCSI target specified by ScsiIo.
1007   When Event is NULL, blocking command will be executed. Otherwise non-blocking
1008   command will be executed.
1009   For blocking I/O, if Timeout is zero, this function will wait indefinitely
1010   for the command to complete. If Timeout is greater than zero, then the
1011   command is executed and will timeout after Timeout 100 ns units.
1012   For non-blocking I/O, if Timeout is zero, Event will be signaled only after
1013   the command to completes. If Timeout is greater than zero, Event will also be
1014   signaled after Timeout 100 ns units.
1015   The StartLba and SectorSize parameters are used to construct the CDB for this
1016   SCSI command.
1017 
1018   If ScsiIo is NULL, then ASSERT().
1019   If SenseDataLength is NULL, then ASSERT().
1020   If HostAdapterStatus is NULL, then ASSERT().
1021   If TargetStatus is NULL, then ASSERT().
1022   If DataLength is NULL, then ASSERT().
1023 
1024   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet
1025   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
1026   EFI_INVALID_PARAMETER gets returned.
1027 
1028   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet
1029   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
1030   EFI_INVALID_PARAMETER gets returned.
1031 
1032   @param[in]      ScsiIo               A pointer to SCSI IO protocol.
1033   @param[in]      Timeout              The length of timeout period.
1034   @param[in, out] SenseData            A pointer to output sense data.
1035   @param[in, out] SenseDataLength      The length of output sense data.
1036   @param[out]     HostAdapterStatus    The status of Host Adapter.
1037   @param[out]     TargetStatus         The status of the target.
1038   @param[in, out] DataBuffer           Read 16 command data.
1039   @param[in, out] DataLength           The length of data buffer.
1040   @param[in]      StartLba             The start address of LBA.
1041   @param[in]      SectorSize           The number of contiguous logical blocks
1042                                        of data that shall be transferred.
1043   @param[in]      Event                If the SCSI target does not support
1044                                        non-blocking I/O, then Event is ignored,
1045                                        and blocking I/O is performed. If Event
1046                                        is NULL, then blocking I/O is performed.
1047                                        If Event is not NULL and non-blocking
1048                                        I/O is supported, then non-blocking I/O
1049                                        is performed, and Event will be signaled
1050                                        when the SCSI Read(16) command
1051                                        completes.
1052 
1053   @retval  EFI_SUCCESS                 Command is executed successfully.
1054   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed,
1055                                        but the entire DataBuffer could not be
1056                                        transferred. The actual number of bytes
1057                                        transferred is returned in DataLength.
1058   @retval  EFI_NOT_READY               The SCSI Request Packet could not be
1059                                        sent because there are too many SCSI
1060                                        Command Packets already queued.
1061   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting
1062                                        to send SCSI Request Packet.
1063   @retval  EFI_UNSUPPORTED             The command described by the SCSI
1064                                        Request Packet is not supported by the
1065                                        SCSI initiator(i.e., SCSI  Host
1066                                        Controller)
1067   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the
1068                                        SCSI Request Packet to execute.
1069   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet
1070                                        are invalid.
1071   @retval  EFI_OUT_OF_RESOURCES        The request could not be completed due
1072                                        to a lack of resources.
1073 
1074 **/
1075 EFI_STATUS
1076 EFIAPI
1077 ScsiRead16CommandEx (
1078   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
1079   IN     UINT64                Timeout,
1080   IN OUT VOID                  *SenseData,   OPTIONAL
1081   IN OUT UINT8                 *SenseDataLength,
1082      OUT UINT8                 *HostAdapterStatus,
1083      OUT UINT8                 *TargetStatus,
1084   IN OUT VOID                  *DataBuffer,  OPTIONAL
1085   IN OUT UINT32                *DataLength,
1086   IN     UINT64                StartLba,
1087   IN     UINT32                SectorSize,
1088   IN     EFI_EVENT             Event         OPTIONAL
1089   );
1090 
1091 
1092 /**
1093   Execute blocking/non-blocking Write(16) SCSI command on a specific SCSI
1094   target.
1095 
1096   Executes the SCSI Write(16) command on the SCSI target specified by ScsiIo.
1097   When Event is NULL, blocking command will be executed. Otherwise non-blocking
1098   command will be executed.
1099   For blocking I/O, if Timeout is zero, this function will wait indefinitely
1100   for the command to complete. If Timeout is greater than zero, then the
1101   command is executed and will timeout after Timeout 100 ns units.
1102   For non-blocking I/O, if Timeout is zero, Event will be signaled only after
1103   the command to completes. If Timeout is greater than zero, Event will also be
1104   signaled after Timeout 100 ns units.
1105   The StartLba and SectorSize parameters are used to construct the CDB for this
1106   SCSI command.
1107 
1108   If ScsiIo is NULL, then ASSERT().
1109   If SenseDataLength is NULL, then ASSERT().
1110   If HostAdapterStatus is NULL, then ASSERT().
1111   If TargetStatus is NULL, then ASSERT().
1112   If DataLength is NULL, then ASSERT().
1113 
1114   If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet
1115   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
1116   EFI_INVALID_PARAMETER gets returned.
1117 
1118   If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet
1119   buffer alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise
1120   EFI_INVALID_PARAMETER gets returned.
1121 
1122   @param[in]      ScsiIo               SCSI IO Protocol to use
1123   @param[in]      Timeout              The length of timeout period.
1124   @param[in, out] SenseData            A pointer to output sense data.
1125   @param[in, out] SenseDataLength      The length of output sense data.
1126   @param[out]     HostAdapterStatus    The status of Host Adapter.
1127   @param[out]     TargetStatus         The status of the target.
1128   @param[in, out] DataBuffer           A pointer to a data buffer.
1129   @param[in, out] DataLength           The length of data buffer.
1130   @param[in]      StartLba             The start address of LBA.
1131   @param[in]      SectorSize           The number of contiguous logical blocks
1132                                        of data that shall be transferred.
1133   @param[in]      Event                If the SCSI target does not support
1134                                        non-blocking I/O, then Event is ignored,
1135                                        and blocking I/O is performed. If Event
1136                                        is NULL, then blocking I/O is performed.
1137                                        If Event is not NULL and non-blocking
1138                                        I/O is supported, then non-blocking I/O
1139                                        is performed, and Event will be signaled
1140                                        when the SCSI Write(16) command
1141                                        completes.
1142 
1143   @retval  EFI_SUCCESS                 Command is executed successfully.
1144   @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed,
1145                                        but the entire DataBuffer could not be
1146                                        transferred. The actual number of bytes
1147                                        transferred is returned in DataLength.
1148   @retval  EFI_NOT_READY               The SCSI Request Packet could not be
1149                                        sent because there are too many SCSI
1150                                        Command Packets already queued.
1151   @retval  EFI_DEVICE_ERROR            A device error occurred while attempting
1152                                        to send SCSI Request Packet.
1153   @retval  EFI_UNSUPPORTED             The command described by the SCSI
1154                                        Request Packet is not supported by the
1155                                        SCSI initiator(i.e., SCSI  Host
1156                                        Controller)
1157   @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the
1158                                        SCSI Request Packet to execute.
1159   @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet
1160                                        are invalid.
1161   @retval  EFI_OUT_OF_RESOURCES        The request could not be completed due
1162                                        to a lack of resources.
1163 
1164 **/
1165 EFI_STATUS
1166 EFIAPI
1167 ScsiWrite16CommandEx (
1168   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
1169   IN     UINT64                Timeout,
1170   IN OUT VOID                  *SenseData,   OPTIONAL
1171   IN OUT UINT8                 *SenseDataLength,
1172      OUT UINT8                 *HostAdapterStatus,
1173      OUT UINT8                 *TargetStatus,
1174   IN OUT VOID                  *DataBuffer,  OPTIONAL
1175   IN OUT UINT32                *DataLength,
1176   IN     UINT64                StartLba,
1177   IN     UINT32                SectorSize,
1178   IN     EFI_EVENT             Event         OPTIONAL
1179   );
1180 
1181 #endif
1182