]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
MdeModulePkg/AtaAtapiPassThru: Revert patch to disable Bus Master
[mirror_edk2.git] / MdeModulePkg / Bus / Ata / AtaAtapiPassThru / AtaAtapiPassThru.h
index 69e6dc0ebf6f144651b4502972bfe9f6bec0639c..8d6eac706c0b7a4294d19b1a80e806ef0f07732e 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
   Header file for ATA/ATAPI PASS THRU driver.\r
-  \r
-  Copyright (c) 2010, 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
-  http://opensource.org/licenses/bsd-license.php                                            \r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  Copyright (c) 2010 - 2016, 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
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 #ifndef __ATA_ATAPI_PASS_THRU_H__\r
@@ -47,6 +47,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
 \r
 #define ATA_ATAPI_PASS_THRU_SIGNATURE  SIGNATURE_32 ('a', 'a', 'p', 't')\r
 #define ATA_ATAPI_DEVICE_SIGNATURE     SIGNATURE_32 ('a', 'd', 'e', 'v')\r
+#define ATA_NONBLOCKING_TASK_SIGNATURE  SIGNATURE_32 ('a', 't', 's', 'k')\r
+\r
+typedef struct _ATA_NONBLOCK_TASK ATA_NONBLOCK_TASK;\r
 \r
 typedef enum {\r
   EfiAtaIdeMode,\r
@@ -92,28 +95,60 @@ typedef struct {
 \r
   EFI_IDE_REGISTERS                 IdeRegisters[EfiIdeMaxChannel];\r
   EFI_AHCI_REGISTERS                AhciRegisters;\r
-  \r
+\r
   //\r
   // The attached device list\r
   //\r
   LIST_ENTRY                        DeviceList;\r
+  UINT64                            EnabledPciAttributes;\r
   UINT64                            OriginalPciAttributes;\r
-\r\r
+\r
   //\r
-  // For AtaPassThru protocol, using the following bytes to record the previous call in \r
+  // For AtaPassThru protocol, using the following bytes to record the previous call in\r
   // GetNextPort()/GetNextDevice().\r
   //\r
   UINT16                            PreviousPort;\r
   UINT16                            PreviousPortMultiplier;\r
   //\r
-  // For ExtScsiPassThru protocol, using the following bytes to record the previous call in \r
+  // For ExtScsiPassThru protocol, using the following bytes to record the previous call in\r
   // GetNextTarget()/GetNextTargetLun().\r
   //\r
   UINT16                            PreviousTargetId;\r
   UINT64                            PreviousLun;\r
 \r
+  //\r
+  // For Non-blocking.\r
+  //\r
+  EFI_EVENT                         TimerEvent;\r
+  LIST_ENTRY                        NonBlockingTaskList;\r
+\r
+  //\r
+  // For disabling the device (especially Bus Master DMA) at\r
+  // ExitBootServices().\r
+  //\r
+  EFI_EVENT                         ExitBootEvent;\r
 } ATA_ATAPI_PASS_THRU_INSTANCE;\r
 \r
+//\r
+// Task for Non-blocking mode.\r
+//\r
+struct _ATA_NONBLOCK_TASK {\r
+  UINT32                            Signature;\r
+  LIST_ENTRY                        Link;\r
+\r
+  UINT16                            Port;\r
+  UINT16                            PortMultiplier;\r
+  EFI_ATA_PASS_THRU_COMMAND_PACKET  *Packet;\r
+  BOOLEAN                           IsStart;\r
+  EFI_EVENT                         Event;\r
+  UINT64                            RetryTimes;\r
+  BOOLEAN                           InfiniteWait;\r
+  VOID                              *Map;            // Pointer to map.\r
+  VOID                              *TableMap;       // Pointer to PRD table map.\r
+  EFI_ATA_DMA_PRD                   *MapBaseAddress; //  Pointer to range Base address for Map.\r
+  UINTN                             PageCount;       //  The page numbers used by PCIO freebuffer.\r
+};\r
+\r
 //\r
 // Timeout value which uses 100ns as a unit.\r
 // It means 3 second span.\r
@@ -142,6 +177,14 @@ typedef struct {
       Link, \\r
       ATA_ATAPI_DEVICE_SIGNATURE \\r
       );\r
+\r
+#define ATA_NON_BLOCK_TASK_FROM_ENTRY(a) \\r
+  CR (a, \\r
+      ATA_NONBLOCK_TASK, \\r
+      Link, \\r
+      ATA_NONBLOCKING_TASK_SIGNATURE \\r
+      );\r
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the driver.\r
 \r
@@ -240,7 +283,7 @@ AtaAtapiPassThruComponentNameGetDriverName (
                                 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
@@ -268,33 +311,33 @@ AtaAtapiPassThruComponentNameGetControllerName (
   );\r
 \r
 /**\r
-  Tests to see if this driver supports a given controller. If a child device is provided, \r
+  Tests to see if this driver supports a given controller. If a child device is provided,\r
   it further tests to see if this driver supports creating a handle for the specified child device.\r
 \r
-  This function checks to see if the driver specified by This supports the device specified by \r
-  ControllerHandle. Drivers will typically use the device path attached to \r
-  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
-  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
-  may be called many times during platform initialization. In order to reduce boot times, the tests \r
-  performed by this function must be very small, and take as little time as possible to execute. This \r
-  function must not change the state of any hardware devices, and this function must be aware that the \r
-  device specified by ControllerHandle may already be managed by the same driver or a \r
-  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
-  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
-  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
-  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
+  This function checks to see if the driver specified by This supports the device specified by\r
+  ControllerHandle. Drivers will typically use the device path attached to\r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to\r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function\r
+  may be called many times during platform initialization. In order to reduce boot times, the tests\r
+  performed by this function must be very small, and take as little time as possible to execute. This\r
+  function must not change the state of any hardware devices, and this function must be aware that the\r
+  device specified by ControllerHandle may already be managed by the same driver or a\r
+  different driver. This function must match its calls to AllocatePages() with FreePages(),\r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().\r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is\r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required\r
   to guarantee the state of ControllerHandle is not modified by this function.\r
 \r
   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
-                                   must support a protocol interface that supplies \r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle\r
+                                   must support a protocol interface that supplies\r
                                    an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For bus drivers, if this parameter is not NULL, then \r
-                                   the bus driver must determine if the bus controller specified \r
-                                   by ControllerHandle and the child controller specified \r
-                                   by RemainingDevicePath are both supported by this \r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For bus drivers, if this parameter is not NULL, then\r
+                                   the bus driver must determine if the bus controller specified\r
+                                   by ControllerHandle and the child controller specified\r
+                                   by RemainingDevicePath are both supported by this\r
                                    bus driver.\r
 \r
   @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
@@ -321,28 +364,28 @@ AtaAtapiPassThruSupported (
   Starts a device controller or a bus controller.\r
 \r
   The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this \r
-  common boot service. It is legal to call Start() from other locations, \r
+  As a result, much of the error checking on the parameters to Start() has been moved into this\r
+  common boot service. It is legal to call Start() from other locations,\r
   but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
   1. ControllerHandle must be a valid EFI_HANDLE.\r
   2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
      EFI_DEVICE_PATH_PROTOCOL.\r
   3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r
 \r
   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
-                                   must support a protocol interface that supplies \r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle\r
+                                   must support a protocol interface that supplies\r
                                    an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
-                                   for all the children of Controller are created by this driver.  \r
-                                   If this parameter is not NULL and the first Device Path Node is \r
-                                   not the End of Device Path Node, then only the handle for the \r
-                                   child device specified by the first Device Path Node of \r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This\r
+                                   parameter is ignored by device drivers, and is optional for bus\r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles\r
+                                   for all the children of Controller are created by this driver.\r
+                                   If this parameter is not NULL and the first Device Path Node is\r
+                                   not the End of Device Path Node, then only the handle for the\r
+                                   child device specified by the first Device Path Node of\r
                                    RemainingDevicePath is created by this driver.\r
-                                   If the first Device Path Node of RemainingDevicePath is \r
+                                   If the first Device Path Node of RemainingDevicePath is\r
                                    the End of Device Path Node, no child handle is created by this\r
                                    driver.\r
 \r
@@ -362,10 +405,10 @@ AtaAtapiPassThruStart (
 \r
 /**\r
   Stops a device controller or a bus controller.\r
-  \r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
-  As a result, much of the error checking on the parameters to Stop() has been moved \r
-  into this common boot service. It is legal to call Stop() from other locations, \r
+\r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r
+  As a result, much of the error checking on the parameters to Stop() has been moved\r
+  into this common boot service. It is legal to call Stop() from other locations,\r
   but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
   1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
      same driver's Start() function.\r
@@ -373,13 +416,13 @@ AtaAtapiPassThruStart (
      EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
      Start() function, and the Start() function must have called OpenProtocol() on\r
      ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-  \r
+\r
   @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
-                                support a bus specific I/O protocol for the driver \r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must\r
+                                support a bus specific I/O protocol for the driver\r
                                 to use to stop the device.\r
   @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL\r
                                 if NumberOfChildren is 0.\r
 \r
   @retval EFI_SUCCESS           The device was stopped.\r
@@ -397,13 +440,13 @@ AtaAtapiPassThruStop (
 \r
 /**\r
   Traverse the attached ATA devices list to find out the device to access.\r
-  \r
+\r
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
-  @param[in]  Port                The port number of the ATA device to send the command. \r
+  @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
-  \r
+\r
   @retval     The pointer to the data structure of the device info to access.\r
 \r
 **/\r
@@ -419,11 +462,11 @@ SearchDeviceInfoList (
 /**\r
   Allocate device info data structure to contain device info.\r
   And insert the data structure to the tail of device list for tracing.\r
-    \r
+\r
   @param[in]  Instance            A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
-  @param[in]  Port                The port number of the ATA device to send the command. \r
+  @param[in]  Port                The port number of the ATA device to send the command.\r
   @param[in]  PortMultiplierPort  The port multiplier port number of the ATA device to send the command.\r
-                                  If there is no port multiplier, then specify 0.\r
+                                  If there is no port multiplier, then specify 0xFFFF.\r
   @param[in]  DeviceType          The device type of the ATA device.\r
   @param[in]  IdentifyData        The data buffer to store the output of the IDENTIFY cmd.\r
 \r
@@ -443,7 +486,7 @@ CreateNewDeviceInfo (
 \r
 /**\r
   Destroy all attached ATA devices info.\r
-  \r
+\r
   @param[in]  Instance          A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
 \r
 **/\r
@@ -453,11 +496,26 @@ DestroyDeviceInfoList (
   IN  ATA_ATAPI_PASS_THRU_INSTANCE  *Instance\r
   );\r
 \r
+/**\r
+  Destroy all pending non blocking tasks.\r
+\r
+  @param[in]  Instance    A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
+  @param[in]  IsSigEvent  Indicate whether signal the task event when remove the\r
+                          task.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DestroyAsynTaskList (\r
+  IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r
+  IN BOOLEAN                       IsSigEvent\r
+  );\r
+\r
 /**\r
   Enumerate all attached ATA devices at IDE mode or AHCI mode separately.\r
-  \r
-  The function is designed to enumerate all attached ATA devices. \r
-  \r
+\r
+  The function is designed to enumerate all attached ATA devices.\r
+\r
   @param[in]  Instance          A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
 \r
   @retval EFI_SUCCESS           Successfully enumerate attached ATA devices.\r
@@ -470,15 +528,30 @@ EnumerateAttachedDevice (
   IN  ATA_ATAPI_PASS_THRU_INSTANCE      *Instance\r
   );\r
 \r
+/**\r
+  Call back funtion when the timer event is signaled.\r
+\r
+  @param[in]  Event     The Event this notify function registered to.\r
+  @param[in]  Context   Pointer to the context data registered to the\r
+                        Event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsyncNonBlockingTransferRoutine (\r
+  EFI_EVENT  Event,\r
+  VOID*      Context\r
+  );\r
+\r
 /**\r
   Sends an ATA command to an ATA device that is attached to the ATA controller. This function\r
   supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,\r
   and the non-blocking I/O functionality is optional.\r
 \r
-  @param[in]      This               A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. \r
-  @param[in]      Port               The port number of the ATA device to send the command. \r
+  @param[in]      This               A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
+  @param[in]      Port               The port number of the ATA device to send the command.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device to send the command.\r
-                                     If there is no port multiplier, then specify 0.\r
+                                     If there is no port multiplier, then specify 0xFFFF.\r
   @param[in, out] Packet             A pointer to the ATA command to send to the ATA device specified by Port\r
                                      and PortMultiplierPort.\r
   @param[in]      Event              If non-blocking I/O is not supported then Event is ignored, and blocking\r
@@ -486,11 +559,11 @@ EnumerateAttachedDevice (
                                      Event is not NULL and non blocking I/O is supported, then non-blocking\r
                                      I/O is performed, and Event will be signaled when the ATA command completes.\r
 \r
-  @retval EFI_SUCCESS                The ATA command was sent by the host. For bi-directional commands, \r
+  @retval EFI_SUCCESS                The ATA command was sent by the host. For bi-directional commands,\r
                                      InTransferLength bytes were transferred from InDataBuffer. For write and\r
                                      bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.\r
   @retval EFI_BAD_BUFFER_SIZE        The ATA command was not executed. The number of bytes that could be transferred\r
-                                     is returned in InTransferLength. For write and bi-directional commands, \r
+                                     is returned in InTransferLength. For write and bi-directional commands,\r
                                      OutTransferLength bytes were transferred by OutDataBuffer.\r
   @retval EFI_NOT_READY              The ATA command could not be sent because there are too many ATA commands\r
                                      already queued. The caller may retry again later.\r
@@ -500,6 +573,7 @@ EnumerateAttachedDevice (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruPassThru (\r
   IN     EFI_ATA_PASS_THRU_PROTOCOL       *This,\r
   IN     UINT16                           Port,\r
@@ -527,7 +601,7 @@ AtaPassThruPassThru (
   If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is\r
   returned.\r
 \r
-  @param[in]      This          A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance. \r
+  @param[in]      This          A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in, out] Port          On input, a pointer to the port number on the ATA controller.\r
                                 On output, a pointer to the next port number on the ATA\r
                                 controller. An input value of 0xFFFF retrieves the first port\r
@@ -540,42 +614,43 @@ AtaPassThruPassThru (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruGetNextPort (\r
   IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN OUT UINT16                 *Port\r
   );\r
 \r
 /**\r
-  Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA \r
-  controller. These can either be the list of port multiplier ports where ATA devices are actually \r
-  present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this \r
-  function must probe the port number and port multiplier port number returned to see if an ATA \r
+  Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA\r
+  controller. These can either be the list of port multiplier ports where ATA devices are actually\r
+  present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this\r
+  function must probe the port number and port multiplier port number returned to see if an ATA\r
   device is actually present.\r
 \r
-  The GetNextDevice() function retrieves the port multiplier port number of an ATA device \r
+  The GetNextDevice() function retrieves the port multiplier port number of an ATA device\r
   present on a port of an ATA controller.\r
-  \r
-  If PortMultiplierPort points to a port multiplier port number value that was returned on a \r
+\r
+  If PortMultiplierPort points to a port multiplier port number value that was returned on a\r
   previous call to GetNextDevice(), then the port multiplier port number of the next ATA device\r
   on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is\r
   returned.\r
-  \r
-  If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first \r
-  ATA device on port of the ATA controller is returned in PortMultiplierPort and \r
+\r
+  If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first\r
+  ATA device on port of the ATA controller is returned in PortMultiplierPort and\r
   EFI_SUCCESS is returned.\r
-  \r
+\r
   If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort\r
   was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER\r
   is returned.\r
-  \r
-  If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of \r
+\r
+  If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of\r
   the ATA controller, then EFI_NOT_FOUND is returned.\r
 \r
   @param[in]      This               A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in]      Port               The port number present on the ATA controller.\r
   @param[in, out] PortMultiplierPort On input, a pointer to the port multiplier port number of an\r
-                                     ATA device present on the ATA controller. \r
-                                     If on input a PortMultiplierPort of 0xFFFF is specified, \r
+                                     ATA device present on the ATA controller.\r
+                                     If on input a PortMultiplierPort of 0xFFFF is specified,\r
                                      then the port multiplier port number of the first ATA device\r
                                      is returned. On output, a pointer to the port multiplier port\r
                                      number of the next ATA device present on an ATA controller.\r
@@ -588,6 +663,7 @@ AtaPassThruGetNextPort (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruGetNextDevice (\r
   IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN UINT16                     Port,\r
@@ -612,7 +688,7 @@ AtaPassThruGetNextDevice (
                                      device path node is to be allocated and built.\r
   @param[in]      PortMultiplierPort The port multiplier port number of the ATA device for which a\r
                                      device path node is to be allocated and built. If there is no\r
-                                     port multiplier, then specify 0.\r
+                                     port multiplier, then specify 0xFFFF.\r
   @param[in, out] DevicePath         A pointer to a single device path node that describes the ATA\r
                                      device specified by Port and PortMultiplierPort. This function\r
                                      is responsible for allocating the buffer DevicePath with the\r
@@ -627,6 +703,7 @@ AtaPassThruGetNextDevice (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruBuildDevicePath (\r
   IN     EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN     UINT16                     Port,\r
@@ -639,7 +716,7 @@ AtaPassThruBuildDevicePath (
 \r
   The GetDevice() function determines the port and port multiplier port number associated with\r
   the ATA device described by DevicePath. If DevicePath is a device path node type that the\r
-  ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents \r
+  ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents\r
   DevicePath into a port number and port multiplier port number.\r
 \r
   If this translation is successful, then that port number and port multiplier port number are returned\r
@@ -647,11 +724,11 @@ AtaPassThruBuildDevicePath (
 \r
   If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.\r
 \r
-  If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then \r
+  If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then\r
   EFI_UNSUPPORTED is returned.\r
 \r
-  If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not \r
-  a valid translation from DevicePath to a port number and port multiplier port number, then \r
+  If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not\r
+  a valid translation from DevicePath to a port number and port multiplier port number, then\r
   EFI_NOT_FOUND is returned.\r
 \r
   @param[in]  This                A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
@@ -669,8 +746,10 @@ AtaPassThruBuildDevicePath (
   @retval EFI_UNSUPPORTED         This driver does not support the device path node type in DevicePath.\r
   @retval EFI_NOT_FOUND           A valid translation from DevicePath to a port number and port multiplier\r
                                   port number does not exist.\r
+\r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruGetDevice (\r
   IN  EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN  EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
@@ -703,6 +782,7 @@ AtaPassThruGetDevice (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruResetPort (\r
   IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN UINT16                     Port\r
@@ -715,7 +795,7 @@ AtaPassThruResetPort (
   If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is\r
   returned.\r
 \r
-  If Port or PortMultiplierPort are not in a valid range for this ATA controller, then \r
+  If Port or PortMultiplierPort are not in a valid range for this ATA controller, then\r
   EFI_INVALID_PARAMETER is returned.\r
 \r
   If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR\r
@@ -729,7 +809,7 @@ AtaPassThruResetPort (
   @param[in] This                A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.\r
   @param[in] Port                Port represents the port number of the ATA device to be reset.\r
   @param[in] PortMultiplierPort  The port multiplier port number of the ATA device to reset.\r
-                                 If there is no port multiplier, then specify 0.\r
+                                 If there is no port multiplier, then specify 0xFFFF.\r
   @retval EFI_SUCCESS            The ATA device specified by Port and PortMultiplierPort was reset.\r
   @retval EFI_UNSUPPORTED        The ATA controller does not support a device reset operation.\r
   @retval EFI_INVALID_PARAMETER  Port or PortMultiplierPort are invalid.\r
@@ -740,6 +820,7 @@ AtaPassThruResetPort (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 AtaPassThruResetDevice (\r
   IN EFI_ATA_PASS_THRU_PROTOCOL *This,\r
   IN UINT16                     Port,\r
@@ -747,9 +828,9 @@ AtaPassThruResetDevice (
   );\r
 \r
 /**\r
-  Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function   \r
+  Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r
   supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r
-  nonblocking I/O functionality is optional.                                                             \r
+  nonblocking I/O functionality is optional.\r
 \r
   @param  This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param  Target  The Target is an array of size TARGET_MAX_BYTES and it represents\r
@@ -798,11 +879,11 @@ ExtScsiPassThruPassThru (
   );\r
 \r
 /**\r
-  Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These       \r
+  Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These\r
   can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r
-  Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the       \r
-  Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI    \r
-  channel.                                                                                               \r
+  Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the\r
+  Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI\r
+  channel.\r
 \r
   @param  This   A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param  Target On input, a pointer to the Target ID (an array of size\r
@@ -911,7 +992,7 @@ EFIAPI
 ExtScsiPassThruResetChannel (\r
   IN  EFI_EXT_SCSI_PASS_THRU_PROTOCOL   *This\r
   );\r
-  \r
+\r
 /**\r
   Resets a SCSI logical unit that is connected to a SCSI channel.\r
 \r
@@ -937,13 +1018,13 @@ ExtScsiPassThruResetTargetLun (
   IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL    *This,\r
   IN UINT8                              *Target,\r
   IN UINT64                             Lun\r
-  );     \r
+  );\r
 \r
 /**\r
-  Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either     \r
+  Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either\r
   be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r
-  for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to     \r
-  see if a SCSI device is actually present at that location on the SCSI channel.                         \r
+  for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to\r
+  see if a SCSI device is actually present at that location on the SCSI channel.\r
 \r
   @param  This   A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param  Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r
@@ -970,9 +1051,9 @@ ExtScsiPassThruGetNextTarget (
 \r
 /**\r
   Initialize ATA host controller at IDE mode.\r
-  \r
-  The function is designed to initialize ATA host controller. \r
-  \r
+\r
+  The function is designed to initialize ATA host controller.\r
+\r
   @param[in]  Instance          A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
 \r
 **/\r
@@ -984,9 +1065,9 @@ IdeModeInitialization (
 \r
 /**\r
   Initialize ATA host controller at AHCI mode.\r
-  \r
-  The function is designed to initialize ATA host controller. \r
-  \r
+\r
+  The function is designed to initialize ATA host controller.\r
+\r
   @param[in]  Instance          A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.\r
 \r
 **/\r
@@ -996,5 +1077,231 @@ AhciModeInitialization (
   IN  ATA_ATAPI_PASS_THRU_INSTANCE    *Instance\r
   );\r
 \r
+/**\r
+  Start a non data transfer on specific port.\r
+\r
+  @param[in]       PciIo               The PCI IO protocol instance.\r
+  @param[in]       AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param[in]       Port                The number of port.\r
+  @param[in]       PortMultiplier      The timeout value of stop.\r
+  @param[in]       AtapiCommand        The atapi command will be used for the\r
+                                       transfer.\r
+  @param[in]       AtapiCommandLength  The length of the atapi command.\r
+  @param[in]       AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
+  @param[in, out]  AtaStatusBlock      The EFI_ATA_STATUS_BLOCK data.\r
+  @param[in]       Timeout             The timeout value of non data transfer, uses 100ns as a unit.\r
+  @param[in]       Task                Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                       used by non-blocking mode.\r
+\r
+  @retval EFI_DEVICE_ERROR    The non data transfer abort with error occurs.\r
+  @retval EFI_TIMEOUT         The operation is time out.\r
+  @retval EFI_UNSUPPORTED     The device is not ready for transfer.\r
+  @retval EFI_SUCCESS         The non data transfer executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AhciNonDataTransfer (\r
+  IN     EFI_PCI_IO_PROTOCOL           *PciIo,\r
+  IN     EFI_AHCI_REGISTERS            *AhciRegisters,\r
+  IN     UINT8                         Port,\r
+  IN     UINT8                         PortMultiplier,\r
+  IN     EFI_AHCI_ATAPI_COMMAND        *AtapiCommand OPTIONAL,\r
+  IN     UINT8                         AtapiCommandLength,\r
+  IN     EFI_ATA_COMMAND_BLOCK         *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK          *AtaStatusBlock,\r
+  IN     UINT64                        Timeout,\r
+  IN     ATA_NONBLOCK_TASK             *Task\r
+  );\r
+\r
+/**\r
+  Start a DMA data transfer on specific port\r
+\r
+  @param[in]       Instance            The ATA_ATAPI_PASS_THRU_INSTANCE protocol instance.\r
+  @param[in]       AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param[in]       Port                The number of port.\r
+  @param[in]       PortMultiplier      The timeout value of stop.\r
+  @param[in]       AtapiCommand        The atapi command will be used for the\r
+                                       transfer.\r
+  @param[in]       AtapiCommandLength  The length of the atapi command.\r
+  @param[in]       Read                The transfer direction.\r
+  @param[in]       AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
+  @param[in, out]  AtaStatusBlock      The EFI_ATA_STATUS_BLOCK data.\r
+  @param[in, out]  MemoryAddr          The pointer to the data buffer.\r
+  @param[in]       DataCount           The data count to be transferred.\r
+  @param[in]       Timeout             The timeout value of non data transfer, uses 100ns as a unit.\r
+  @param[in]       Task                Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                       used by non-blocking mode.\r
+\r
+  @retval EFI_DEVICE_ERROR    The DMA data transfer abort with error occurs.\r
+  @retval EFI_TIMEOUT         The operation is time out.\r
+  @retval EFI_UNSUPPORTED     The device is not ready for transfer.\r
+  @retval EFI_SUCCESS         The DMA data transfer executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AhciDmaTransfer (\r
+  IN     ATA_ATAPI_PASS_THRU_INSTANCE *Instance,\r
+  IN     EFI_AHCI_REGISTERS           *AhciRegisters,\r
+  IN     UINT8                        Port,\r
+  IN     UINT8                        PortMultiplier,\r
+  IN     EFI_AHCI_ATAPI_COMMAND       *AtapiCommand OPTIONAL,\r
+  IN     UINT8                        AtapiCommandLength,\r
+  IN     BOOLEAN                      Read,\r
+  IN     EFI_ATA_COMMAND_BLOCK        *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK         *AtaStatusBlock,\r
+  IN OUT VOID                         *MemoryAddr,\r
+  IN     UINT32                       DataCount,\r
+  IN     UINT64                       Timeout,\r
+  IN     ATA_NONBLOCK_TASK            *Task\r
+  );\r
+\r
+/**\r
+  Start a PIO data transfer on specific port.\r
+\r
+  @param[in]       PciIo               The PCI IO protocol instance.\r
+  @param[in]       AhciRegisters       The pointer to the EFI_AHCI_REGISTERS.\r
+  @param[in]       Port                The number of port.\r
+  @param[in]       PortMultiplier      The timeout value of stop.\r
+  @param[in]       AtapiCommand        The atapi command will be used for the\r
+                                       transfer.\r
+  @param[in]       AtapiCommandLength  The length of the atapi command.\r
+  @param[in]       Read                The transfer direction.\r
+  @param[in]       AtaCommandBlock     The EFI_ATA_COMMAND_BLOCK data.\r
+  @param[in, out]  AtaStatusBlock      The EFI_ATA_STATUS_BLOCK data.\r
+  @param[in, out]  MemoryAddr          The pointer to the data buffer.\r
+  @param[in]       DataCount           The data count to be transferred.\r
+  @param[in]       Timeout             The timeout value of non data transfer, uses 100ns as a unit.\r
+  @param[in]       Task                Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                       used by non-blocking mode.\r
+\r
+  @retval EFI_DEVICE_ERROR    The PIO data transfer abort with error occurs.\r
+  @retval EFI_TIMEOUT         The operation is time out.\r
+  @retval EFI_UNSUPPORTED     The device is not ready for transfer.\r
+  @retval EFI_SUCCESS         The PIO data transfer executes successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AhciPioTransfer (\r
+  IN     EFI_PCI_IO_PROTOCOL        *PciIo,\r
+  IN     EFI_AHCI_REGISTERS         *AhciRegisters,\r
+  IN     UINT8                      Port,\r
+  IN     UINT8                      PortMultiplier,\r
+  IN     EFI_AHCI_ATAPI_COMMAND     *AtapiCommand OPTIONAL,\r
+  IN     UINT8                      AtapiCommandLength,\r
+  IN     BOOLEAN                    Read,\r
+  IN     EFI_ATA_COMMAND_BLOCK      *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK       *AtaStatusBlock,\r
+  IN OUT VOID                       *MemoryAddr,\r
+  IN     UINT32                     DataCount,\r
+  IN     UINT64                     Timeout,\r
+  IN     ATA_NONBLOCK_TASK          *Task\r
+  );\r
+\r
+/**\r
+  Send ATA command into device with NON_DATA protocol\r
+\r
+  @param[in]      PciIo            A pointer to ATA_ATAPI_PASS_THRU_INSTANCE\r
+                                   data structure.\r
+  @param[in]      IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.\r
+  @param[in]      AtaCommandBlock  A pointer to EFI_ATA_COMMAND_BLOCK data\r
+                                   structure.\r
+  @param[in, out] AtaStatusBlock   A pointer to EFI_ATA_STATUS_BLOCK data structure.\r
+  @param[in]      Timeout          The time to complete the command, uses 100ns as a unit.\r
+  @param[in]      Task             Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                   used by non-blocking mode.\r
+\r
+  @retval  EFI_SUCCESS Reading succeed\r
+  @retval  EFI_ABORTED Command failed\r
+  @retval  EFI_DEVICE_ERROR Device status error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaNonDataCommandIn (\r
+  IN     EFI_PCI_IO_PROTOCOL       *PciIo,\r
+  IN     EFI_IDE_REGISTERS         *IdeRegisters,\r
+  IN     EFI_ATA_COMMAND_BLOCK     *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK      *AtaStatusBlock,\r
+  IN     UINT64                    Timeout,\r
+  IN     ATA_NONBLOCK_TASK         *Task\r
+  );\r
+\r
+/**\r
+  Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt).\r
+\r
+  @param[in]      Instance         A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data\r
+                                   structure.\r
+  @param[in]      IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.\r
+  @param[in]      Read             Flag used to determine the data transfer\r
+                                   direction. Read equals 1, means data transferred\r
+                                   from device to host;Read equals 0, means data\r
+                                   transferred from host to device.\r
+  @param[in]      DataBuffer       A pointer to the source buffer for the data.\r
+  @param[in]      DataLength       The length of  the data.\r
+  @param[in]      AtaCommandBlock  A pointer to EFI_ATA_COMMAND_BLOCK data structure.\r
+  @param[in, out] AtaStatusBlock   A pointer to EFI_ATA_STATUS_BLOCK data structure.\r
+  @param[in]      Timeout          The time to complete the command, uses 100ns as a unit.\r
+  @param[in]      Task             Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                   used by non-blocking mode.\r
+\r
+  @retval EFI_SUCCESS          the operation is successful.\r
+  @retval EFI_OUT_OF_RESOURCES Build PRD table failed\r
+  @retval EFI_UNSUPPORTED      Unknown channel or operations command\r
+  @retval EFI_DEVICE_ERROR     Ata command execute failed\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaUdmaInOut (\r
+  IN     ATA_ATAPI_PASS_THRU_INSTANCE  *Instance,\r
+  IN     EFI_IDE_REGISTERS             *IdeRegisters,\r
+  IN     BOOLEAN                       Read,\r
+  IN     VOID                          *DataBuffer,\r
+  IN     UINT64                        DataLength,\r
+  IN     EFI_ATA_COMMAND_BLOCK         *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK          *AtaStatusBlock,\r
+  IN     UINT64                        Timeout,\r
+  IN     ATA_NONBLOCK_TASK             *Task\r
+  );\r
+\r
+/**\r
+  This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
+\r
+  @param[in]      PciIo            A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data\r
+                                   structure.\r
+  @param[in]      IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.\r
+  @param[in, out] Buffer           A pointer to the source buffer for the data.\r
+  @param[in]      ByteCount        The length of  the data.\r
+  @param[in] Read                  Flag used to determine the data transfer direction.\r
+                                   Read equals 1, means data transferred from device\r
+                                   to host;Read equals 0, means data transferred\r
+                                   from host to device.\r
+  @param[in]      AtaCommandBlock  A pointer to EFI_ATA_COMMAND_BLOCK data structure.\r
+  @param[in, out] AtaStatusBlock   A pointer to EFI_ATA_STATUS_BLOCK data structure.\r
+  @param[in]      Timeout          The time to complete the command, uses 100ns as a unit.\r
+  @param[in]      Task             Optional. Pointer to the ATA_NONBLOCK_TASK\r
+                                   used by non-blocking mode.\r
+\r
+  @retval EFI_SUCCESS      send out the ATA command and device send required data successfully.\r
+  @retval EFI_DEVICE_ERROR command sent failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtaPioDataInOut (\r
+  IN     EFI_PCI_IO_PROTOCOL       *PciIo,\r
+  IN     EFI_IDE_REGISTERS         *IdeRegisters,\r
+  IN OUT VOID                      *Buffer,\r
+  IN     UINT64                    ByteCount,\r
+  IN     BOOLEAN                   Read,\r
+  IN     EFI_ATA_COMMAND_BLOCK     *AtaCommandBlock,\r
+  IN OUT EFI_ATA_STATUS_BLOCK      *AtaStatusBlock,\r
+  IN     UINT64                    Timeout,\r
+  IN     ATA_NONBLOCK_TASK         *Task\r
+  );\r
+\r
 #endif\r
 \r