]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
Fix the comments to follow UEFI Spec regarding how to check an EFI_HANDLE is valid...
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaBusDxe / AtaBus.h
index 034da90939ce9c3397a534b0adbbc6a7b6790f09..6a4b2576b2d57720550d477644025dc170de77e7 100644 (file)
@@ -4,7 +4,7 @@
   This file defines common data structures, macro definitions and some module\r
   internal function header files.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #ifndef _ATA_BUS_H_\r
 #define _ATA_BUS_H_\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/AtaPassThru.h>\r
 #include <Protocol/BlockIo.h>\r
+#include <Protocol/BlockIo2.h>\r
 #include <Protocol/DiskInfo.h>\r
 #include <Protocol/DevicePath.h>\r
+#include <Protocol/StorageSecurityCommand.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -39,7 +41,7 @@
 //\r
 // Time out value for ATA pass through protocol\r
 //\r
-#define ATA_TIMEOUT                       EFI_TIMER_PERIOD_SECONDS (1)\r
+#define ATA_TIMEOUT                       EFI_TIMER_PERIOD_SECONDS (3)\r
 \r
 //\r
 // Maximum number of times to retry ATA command\r
 //\r
 // The maximum ATA transaction sector count in 48 bit addressing mode. \r
 //\r
-#define MAX_48BIT_TRANSFER_BLOCK_NUM      0x10000\r
+//#define MAX_48BIT_TRANSFER_BLOCK_NUM      0x10000\r
+\r
+//\r
+// BugBug: if the TransferLength is equal with 0x10000 (the 48bit max length),\r
+// there is a bug that even the register interrupt bit has been sit, the buffer\r
+// seems not ready. Change the Maximum Sector Numbers to 0xFFFF to work round\r
+// this issue.\r
+//\r
+#define MAX_48BIT_TRANSFER_BLOCK_NUM      0xFFFF\r
 \r
 //\r
 // The maximum model name in ATA identify data  \r
 //\r
 #define MAX_MODEL_NAME_LEN                40\r
 \r
+#define ATA_TASK_SIGNATURE                SIGNATURE_32 ('A', 'T', 'S', 'K')\r
+#define ATA_DEVICE_SIGNATURE              SIGNATURE_32 ('A', 'B', 'I', 'D')\r
+\r
+#define IS_ALIGNED(addr, size)            (((UINTN) (addr) & (size - 1)) == 0)\r
+\r
+//\r
+// Task for the non blocking I/O\r
+//\r
+typedef struct {\r
+  UINT32                            Signature;\r
+  EFI_BLOCK_IO2_TOKEN               *Token;\r
+  UINTN                             *UnsignalledEventCount;\r
+  EFI_ATA_PASS_THRU_COMMAND_PACKET  Packet;\r
+  BOOLEAN                           *IsError;// Indicate whether meeting error during source allocation for new task.\r
+  LIST_ENTRY                        TaskEntry;\r
+} ATA_BUS_ASYN_TASK;\r
 \r
 //\r
 // ATA bus data structure for ATA controller\r
@@ -77,46 +103,50 @@ typedef struct {
   EFI_HANDLE                  DriverBindingHandle;\r
 } ATA_BUS_DRIVER_DATA;\r
 \r
-#define ATA_DEVICE_SIGNATURE  SIGNATURE_32 ('A', 'B', 'I', 'D')\r
-\r
 //\r
 // ATA device data structure for each child device\r
 //\r
 typedef struct {\r
-  UINT32                            Signature;\r
+  UINT32                                Signature;\r
 \r
-  EFI_HANDLE                        Handle;\r
-  EFI_BLOCK_IO_PROTOCOL             BlockIo;\r
-  EFI_BLOCK_IO_MEDIA                BlockMedia;\r
-  EFI_DISK_INFO_PROTOCOL            DiskInfo;\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
+  EFI_HANDLE                            Handle;\r
+  EFI_BLOCK_IO_PROTOCOL                 BlockIo;\r
+  EFI_BLOCK_IO2_PROTOCOL                BlockIo2;\r
+  EFI_BLOCK_IO_MEDIA                    BlockMedia;\r
+  EFI_DISK_INFO_PROTOCOL                DiskInfo;\r
+  EFI_DEVICE_PATH_PROTOCOL              *DevicePath;\r
+  EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;\r
 \r
-  ATA_BUS_DRIVER_DATA               *AtaBusDriverData;\r
-  UINT16                            Port;\r
-  UINT16                            PortMultiplierPort;\r
+  ATA_BUS_DRIVER_DATA                   *AtaBusDriverData;\r
+  UINT16                                Port;\r
+  UINT16                                PortMultiplierPort;\r
 \r
   //\r
   // Buffer for the execution of ATA pass through protocol\r
   //\r
-  EFI_ATA_PASS_THRU_COMMAND_PACKET  Packet;\r
-  EFI_ATA_COMMAND_BLOCK             Acb;\r
-  EFI_ATA_STATUS_BLOCK              *Asb;\r
+  EFI_ATA_PASS_THRU_COMMAND_PACKET      Packet;\r
+  EFI_ATA_COMMAND_BLOCK                 Acb;\r
+  EFI_ATA_STATUS_BLOCK                  *Asb;\r
 \r
-  BOOLEAN                           UdmaValid;\r
-  BOOLEAN                           Lba48Bit;\r
+  BOOLEAN                               UdmaValid;\r
+  BOOLEAN                               Lba48Bit;\r
 \r
   //\r
   // Cached data for ATA identify data\r
   //\r
-  ATA_IDENTIFY_DATA                 *IdentifyData;\r
+  ATA_IDENTIFY_DATA                     *IdentifyData;\r
 \r
-  EFI_UNICODE_STRING_TABLE          *ControllerNameTable;\r
-  CHAR16                            ModelName[MAX_MODEL_NAME_LEN + 1];\r
+  EFI_UNICODE_STRING_TABLE              *ControllerNameTable;\r
+  CHAR16                                ModelName[MAX_MODEL_NAME_LEN + 1];\r
 \r
+  LIST_ENTRY                            AtaTaskList;\r
 } ATA_DEVICE;\r
 \r
-#define ATA_DEVICE_FROM_BLOCK_IO(a)  CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)\r
-#define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)\r
+#define ATA_DEVICE_FROM_BLOCK_IO(a)         CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)\r
+#define ATA_DEVICE_FROM_BLOCK_IO2(a)        CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)\r
+#define ATA_DEVICE_FROM_DISK_INFO(a)        CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)\r
+#define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)\r
+#define ATA_AYNS_TASK_FROM_ENTRY(a)         CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)\r
 \r
 //\r
 // Global Variables\r
@@ -125,6 +155,52 @@ extern EFI_DRIVER_BINDING_PROTOCOL        gAtaBusDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL        gAtaBusComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL       gAtaBusComponentName2;\r
 \r
+/**\r
+  Allocates an aligned buffer for ATA device.\r
+\r
+  This function allocates an aligned buffer for the ATA device to perform\r
+  ATA pass through operations. The alignment requirement is from ATA pass\r
+  through interface.\r
+\r
+  @param  AtaDevice         The ATA child device involved for the operation.\r
+  @param  BufferSize        The request buffer size.\r
+\r
+  @return A pointer to the aligned buffer or NULL if the allocation fails.\r
+\r
+**/\r
+VOID *\r
+AllocateAlignedBuffer (\r
+  IN ATA_DEVICE               *AtaDevice,\r
+  IN UINTN                    BufferSize\r
+  );\r
+\r
+/**\r
+  Frees an aligned buffer for ATA device.\r
+\r
+  This function frees an aligned buffer for the ATA device to perform\r
+  ATA pass through operations.\r
+\r
+  @param  Buffer            The aligned buffer to be freed.\r
+  @param  BufferSize        The request buffer size.\r
+\r
+**/\r
+VOID\r
+FreeAlignedBuffer (\r
+  IN VOID                     *Buffer,\r
+  IN UINTN                    BufferSize\r
+  );\r
+\r
+/**\r
+  Free SubTask. \r
+\r
+  @param[in, out]  Task      Pointer to task to be freed.\r
\r
+**/\r
+VOID\r
+EFIAPI \r
+FreeAtaSubTask (\r
+  IN OUT ATA_BUS_ASYN_TASK  *Task\r
+  );\r
 \r
 /**\r
   Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().\r
@@ -162,7 +238,6 @@ DiscoverAtaDevice (
   IN OUT ATA_DEVICE                 *AtaDevice\r
   );\r
 \r
-\r
 /**\r
   Read or write a number of blocks from ATA device.\r
 \r
@@ -170,11 +245,12 @@ DiscoverAtaDevice (
   ATA device. It may separate the read/write request into several ATA pass through\r
   transactions.\r
 \r
-  @param  AtaDevice         The ATA child device involved for the operation.\r
-  @param  Buffer            The pointer to the current transaction buffer.\r
-  @param  StartLba          The starting logical block address to be accessed.\r
-  @param  NumberOfBlocks    The block number or sector count of the transfer.\r
-  @param  IsWrite           Indicates whether it is a write operation.\r
+  @param[in, out]  AtaDevice       The ATA child device involved for the operation.\r
+  @param[in, out]  Buffer          The pointer to the current transaction buffer.\r
+  @param[in]       StartLba        The starting logical block address to be accessed.\r
+  @param[in]       NumberOfBlocks  The block number or sector count of the transfer.\r
+  @param[in]       IsWrite         Indicates whether it is a write operation.\r
+  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
 \r
   @retval EFI_SUCCESS       The data transfer is complete successfully.\r
   @return others            Some error occurs when transferring data. \r
@@ -186,7 +262,49 @@ AccessAtaDevice(
   IN OUT UINT8                      *Buffer,\r
   IN EFI_LBA                        StartLba,\r
   IN UINTN                          NumberOfBlocks,\r
-  IN BOOLEAN                        IsWrite\r
+  IN BOOLEAN                        IsWrite,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN        *Token\r
+  );\r
+/**\r
+  Trust transfer data from/to ATA device.\r
+\r
+  This function performs one ATA pass through transaction to do a trust transfer from/to\r
+  ATA device. It chooses the appropriate ATA command and protocol to invoke PassThru\r
+  interface of ATA pass through.\r
+\r
+  @param  AtaDevice                    The ATA child device involved for the operation.\r
+  @param  Buffer                       The pointer to the current transaction buffer.\r
+  @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
+                                       the security protocol command to be sent.\r
+  @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
+                                       of the security protocol command to be sent.\r
+  @param  TransferLength               The block number or sector count of the transfer.\r
+  @param  IsTrustSend                  Indicates whether it is a trust send operation or not.\r
+  @param  Timeout                      The timeout, in 100ns units, to use for the execution\r
+                                       of the security protocol command. A Timeout value of 0\r
+                                       means that this function will wait indefinitely for the\r
+                                       security protocol command to execute. If Timeout is greater\r
+                                       than zero, then this function will return EFI_TIMEOUT\r
+                                       if the time required to execute the receive data command\r
+                                       is greater than Timeout.\r
+  @param  TransferLengthOut            A pointer to a buffer to store the size in bytes of the data\r
+                                       written to the buffer. Ignore it when IsTrustSend is TRUE.\r
+\r
+  @retval EFI_SUCCESS       The data transfer is complete successfully.\r
+  @return others            Some error occurs when transferring data. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TrustTransferAtaDevice (\r
+  IN OUT ATA_DEVICE                 *AtaDevice,\r
+  IN OUT VOID                       *Buffer,\r
+  IN UINT8                          SecurityProtocolId,\r
+  IN UINT16                         SecurityProtocolSpecificData,\r
+  IN UINTN                          TransferLength,\r
+  IN BOOLEAN                        IsTrustSend,\r
+  IN UINT64                         Timeout,\r
+  OUT UINTN                         *TransferLengthOut\r
   );\r
 \r
 //\r
@@ -420,7 +538,7 @@ AtaBusComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -544,6 +662,111 @@ AtaBlockIoFlushBlocks (
   IN  EFI_BLOCK_IO_PROTOCOL   *This\r
   );\r
 \r
+/**\r
+  Reset the Block Device throught Block I/O2 protocol.\r
+\r
+  @param[in]  This                 Indicates a pointer to the calling context.\r
+  @param[in]  ExtendedVerification Driver may perform diagnostics on reset.\r
+\r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaBlockIoResetEx (\r
+  IN  EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN  BOOLEAN                 ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Read BufferSize bytes from Lba into Buffer.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    Id of the media, changes every time the media is replaced.\r
+  @param[in]       Lba        The starting Logical Block Address to read from.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param[out]      Buffer     A pointer to the destination buffer for the data. The caller is\r
+                              responsible for either having implicit or explicit ownership of the buffer.\r
+\r
+  @retval EFI_SUCCESS           The read request was queued if Event is not NULL.\r
+                                The data was read correctly from the device if\r
+                                the Event is NULL.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
+                                the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
+  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
+                                intrinsic block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaBlockIoReadBlocksEx (\r
+  IN  EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN  UINT32                  MediaId,\r
+  IN  EFI_LBA                 Lba,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN  *Token,\r
+  IN  UINTN                   BufferSize,\r
+  OUT VOID                    *Buffer\r
+  );\r
+\r
+/**\r
+  Write BufferSize bytes from Lba into Buffer.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    The media ID that the write request is for.\r
+  @param[in]       Lba        The starting logical block address to be written. The\r
+                              caller is responsible for writing to only legitimate\r
+                              locations.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param[in]       Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The data was written correctly to the device.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaBlockIoWriteBlocksEx (\r
+  IN  EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN  UINT32                  MediaId,\r
+  IN  EFI_LBA                 Lba,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN  *Token,\r
+  IN  UINTN                   BufferSize,\r
+  IN  VOID                    *Buffer\r
+  );\r
+\r
+/**\r
+  Flush the Block Device.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+\r
+  @retval EFI_SUCCESS       All outstanding data was written to the device\r
+  @retval EFI_DEVICE_ERROR  The device reported an error while writing back the data\r
+  @retval EFI_NO_MEDIA      There is no media in the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaBlockIoFlushBlocksEx (\r
+  IN  EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN  *Token\r
+  );\r
 \r
 /**\r
   Provides inquiry information for the controller type.\r
@@ -643,4 +866,162 @@ AtaDiskInfoWhichIde (
   OUT UINT32                   *IdeDevice\r
   );\r
 \r
+/**\r
+  Send a security protocol command to a device that receives data and/or the result\r
+  of one or more commands sent by SendData.\r
+\r
+  The ReceiveData function sends a security protocol command to the given MediaId.\r
+  The security protocol command sent is defined by SecurityProtocolId and contains\r
+  the security protocol specific data SecurityProtocolSpecificData. The function\r
+  returns the data from the security protocol command in PayloadBuffer.\r
+\r
+  For devices supporting the SCSI command set, the security protocol command is sent\r
+  using the SECURITY PROTOCOL IN command defined in SPC-4.\r
+\r
+  For devices supporting the ATA command set, the security protocol command is sent\r
+  using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize\r
+  is non-zero.\r
+\r
+  If the PayloadBufferSize is zero, the security protocol command is sent using the\r
+  Trusted Non-Data command defined in ATA8-ACS.\r
+\r
+  If PayloadBufferSize is too small to store the available data from the security\r
+  protocol command, the function shall copy PayloadBufferSize bytes into the\r
+  PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.\r
+\r
+  If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,\r
+  the function shall return EFI_INVALID_PARAMETER.\r
+\r
+  If the given MediaId does not support security protocol commands, the function shall\r
+  return EFI_UNSUPPORTED. If there is no media in the device, the function returns\r
+  EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,\r
+  the function returns EFI_MEDIA_CHANGED.\r
+\r
+  If the security protocol fails to complete within the Timeout period, the function\r
+  shall return EFI_TIMEOUT.\r
+\r
+  If the security protocol command completes without an error, the function shall\r
+  return EFI_SUCCESS. If the security protocol command completes with an error, the\r
+  function shall return EFI_DEVICE_ERROR.\r
+\r
+  @param  This                              Indicates a pointer to the calling context.\r
+  @param  MediaId                           ID of the medium to receive data from.\r
+  @param  Timeout                                 The timeout, in 100ns units, to use for the execution\r
+                                       of the security protocol command. A Timeout value of 0\r
+                                       means that this function will wait indefinitely for the\r
+                                       security protocol command to execute. If Timeout is greater\r
+                                       than zero, then this function will return EFI_TIMEOUT\r
+                                                              if the time required to execute the receive data command\r
+                                                              is greater than Timeout.\r
+  @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
+                                       the security protocol command to be sent.\r
+  @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
+                                       of the security protocol command to be sent.\r
+  @param  PayloadBufferSize                     Size in bytes of the payload data buffer.\r
+  @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
+                                       protocol command specific payload data for the security\r
+                                       protocol command. The caller is responsible for having\r
+                                       either implicit or explicit ownership of the buffer.\r
+  @param  PayloadTransferSize          A pointer to a buffer to store the size in bytes of the\r
+                                       data written to the payload data buffer.\r
+\r
+  @retval EFI_SUCCESS                  The security protocol command completed successfully.\r
+  @retval EFI_WARN_BUFFER_TOO_SMALL    The PayloadBufferSize was too small to store the available\r
+                                       data from the device. The PayloadBuffer contains the truncated data.\r
+  @retval EFI_UNSUPPORTED              The given MediaId does not support security protocol commands.\r
+  @retval EFI_DEVICE_ERROR             The security protocol command completed with an error.\r
+  @retval EFI_NO_MEDIA                 There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED            The MediaId is not for the current media.\r
+  @retval EFI_INVALID_PARAMETER        The PayloadBuffer or PayloadTransferSize is NULL and\r
+                                       PayloadBufferSize is non-zero.\r
+  @retval EFI_TIMEOUT                  A timeout occurred while waiting for the security\r
+                                       protocol command to execute.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaStorageSecurityReceiveData (\r
+  IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL    *This,\r
+  IN UINT32                                   MediaId,\r
+  IN UINT64                                   Timeout,\r
+  IN UINT8                                    SecurityProtocolId,\r
+  IN UINT16                                   SecurityProtocolSpecificData,\r
+  IN UINTN                                    PayloadBufferSize,\r
+  OUT VOID                                    *PayloadBuffer,\r
+  OUT UINTN                                   *PayloadTransferSize\r
+  );\r
+\r
+/**\r
+  Send a security protocol command to a device.\r
+\r
+  The SendData function sends a security protocol command containing the payload\r
+  PayloadBuffer to the given MediaId. The security protocol command sent is\r
+  defined by SecurityProtocolId and contains the security protocol specific data\r
+  SecurityProtocolSpecificData. If the underlying protocol command requires a\r
+  specific padding for the command payload, the SendData function shall add padding\r
+  bytes to the command payload to satisfy the padding requirements.\r
+\r
+  For devices supporting the SCSI command set, the security protocol command is sent\r
+  using the SECURITY PROTOCOL OUT command defined in SPC-4.\r
+\r
+  For devices supporting the ATA command set, the security protocol command is sent\r
+  using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize\r
+  is non-zero. If the PayloadBufferSize is zero, the security protocol command is\r
+  sent using the Trusted Non-Data command defined in ATA8-ACS.\r
+\r
+  If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall\r
+  return EFI_INVALID_PARAMETER.\r
+\r
+  If the given MediaId does not support security protocol commands, the function\r
+  shall return EFI_UNSUPPORTED. If there is no media in the device, the function\r
+  returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the\r
+  device, the function returns EFI_MEDIA_CHANGED.\r
+\r
+  If the security protocol fails to complete within the Timeout period, the function\r
+  shall return EFI_TIMEOUT.\r
+\r
+  If the security protocol command completes without an error, the function shall return\r
+  EFI_SUCCESS. If the security protocol command completes with an error, the function\r
+  shall return EFI_DEVICE_ERROR.\r
+\r
+  @param  This                              Indicates a pointer to the calling context.\r
+  @param  MediaId                           ID of the medium to receive data from.\r
+  @param  Timeout                                 The timeout, in 100ns units, to use for the execution\r
+                                       of the security protocol command. A Timeout value of 0\r
+                                       means that this function will wait indefinitely for the\r
+                                       security protocol command to execute. If Timeout is greater\r
+                                       than zero, then this function will return EFI_TIMEOUT\r
+                                                              if the time required to execute the receive data command\r
+                                                              is greater than Timeout.\r
+  @param  SecurityProtocolId           The value of the "Security Protocol" parameter of\r
+                                       the security protocol command to be sent.\r
+  @param  SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter\r
+                                       of the security protocol command to be sent.\r
+  @param  PayloadBufferSize                     Size in bytes of the payload data buffer.\r
+  @param  PayloadBuffer                A pointer to a destination buffer to store the security\r
+                                       protocol command specific payload data for the security\r
+                                       protocol command.\r
+\r
+  @retval EFI_SUCCESS                  The security protocol command completed successfully.\r
+  @retval EFI_UNSUPPORTED              The given MediaId does not support security protocol commands.\r
+  @retval EFI_DEVICE_ERROR             The security protocol command completed with an error.\r
+  @retval EFI_NO_MEDIA                 There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED            The MediaId is not for the current media.\r
+  @retval EFI_INVALID_PARAMETER        The PayloadBuffer is NULL and PayloadBufferSize is non-zero.\r
+  @retval EFI_TIMEOUT                  A timeout occurred while waiting for the security\r
+                                       protocol command to execute.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaStorageSecuritySendData (\r
+  IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL    *This,\r
+  IN UINT32                                   MediaId,\r
+  IN UINT64                                   Timeout,\r
+  IN UINT8                                    SecurityProtocolId,\r
+  IN UINT16                                   SecurityProtocolSpecificData,\r
+  IN UINTN                                    PayloadBufferSize,\r
+  IN VOID                                     *PayloadBuffer\r
+  );\r
+\r
 #endif\r