]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/AtapiPassThruDxe/AtapiPassThru.c
Fixed potential issues to release resources when error occurs.
[mirror_edk2.git] / OptionRomPkg / AtapiPassThruDxe / AtapiPassThru.c
index 482933dc1b94cf1fb23d90ab75ab5ca659def370..ac12be4ee048aed5d5406620043e568f782d2a3c 100644 (file)
@@ -73,7 +73,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_SCSI_PASS_THRU_PROTOCOL gScsiPassThruProtocolT
 };\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_EXT_SCSI_PASS_THRU_MODE gExtScsiPassThruMode = {\r
 };\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED EFI_EXT_SCSI_PASS_THRU_MODE gExtScsiPassThruMode = {\r
-  4,      \r
+  4,\r
   EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,\r
   0\r
 };\r
   EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL,\r
   0\r
 };\r
@@ -106,20 +106,20 @@ AtapiScsiPassThruDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 /*++\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
   Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
   that has gEfiPciIoProtocolGuid installed and is IDE Controller it will be supported.\r
 Routine Description:\r
   Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
   that has gEfiPciIoProtocolGuid installed and is IDE Controller it will be supported.\r
-    \r
+\r
 Arguments:\r
 \r
   This                - Protocol instance pointer.\r
   Controller          - Handle of device to test\r
   RemainingDevicePath - Not used\r
 Arguments:\r
 \r
   This                - Protocol instance pointer.\r
   Controller          - Handle of device to test\r
   RemainingDevicePath - Not used\r
-    \r
+\r
 Returns:\r
     EFI_STATUS\r
 Returns:\r
     EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
@@ -186,26 +186,27 @@ AtapiScsiPassThruDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 /*++\r
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
   Create handles for IDE channels specified by RemainingDevicePath.\r
   Install SCSI Pass Thru Protocol onto each created handle.\r
 Routine Description:\r
   Create handles for IDE channels specified by RemainingDevicePath.\r
   Install SCSI Pass Thru Protocol onto each created handle.\r
-  \r
+\r
 Arguments:\r
 \r
   This                - Protocol instance pointer.\r
   Controller          - Handle of device to test\r
   RemainingDevicePath - Not used\r
 Arguments:\r
 \r
   This                - Protocol instance pointer.\r
   Controller          - Handle of device to test\r
   RemainingDevicePath - Not used\r
-    \r
+\r
 Returns:\r
     EFI_STATUS\r
 Returns:\r
     EFI_STATUS\r
-    \r
+\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   UINT64              Supports;\r
   UINT64              OriginalPciAttributes;\r
 --*/\r
 {\r
   EFI_STATUS          Status;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   UINT64              Supports;\r
   UINT64              OriginalPciAttributes;\r
+  BOOLEAN             PciAttributesSaved;\r
 \r
   PciIo = NULL;\r
   Status = gBS->OpenProtocol (\r
 \r
   PciIo = NULL;\r
   Status = gBS->OpenProtocol (\r
@@ -220,6 +221,7 @@ Returns:
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  PciAttributesSaved = FALSE;\r
   //\r
   // Save original PCI attributes\r
   //\r
   //\r
   // Save original PCI attributes\r
   //\r
@@ -231,8 +233,9 @@ Returns:
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto Done;\r
   }\r
   }\r
+  PciAttributesSaved = TRUE;\r
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
@@ -262,15 +265,17 @@ Returns:
 \r
 Done:\r
   if (EFI_ERROR (Status)) {\r
 \r
 Done:\r
   if (EFI_ERROR (Status)) {\r
-    //\r
-    // Restore original PCI attributes\r
-    //\r
-    PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSet,\r
-                    OriginalPciAttributes,\r
-                    NULL\r
-                    );\r
+    if (PciAttributesSaved == TRUE) {\r
+      //\r
+      // Restore original PCI attributes\r
+      //\r
+      PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationSet,\r
+                      OriginalPciAttributes,\r
+                      NULL\r
+                      );\r
+    }\r
 \r
     gBS->CloseProtocol (\r
            Controller,\r
 \r
     gBS->CloseProtocol (\r
            Controller,\r
@@ -292,7 +297,7 @@ AtapiScsiPassThruDriverBindingStop (
   IN  EFI_HANDLE                      *ChildHandleBuffer\r
   )\r
 /*++\r
   IN  EFI_HANDLE                      *ChildHandleBuffer\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
 \r
   Stop this driver on ControllerHandle. Support stoping any child handles\r
 Routine Description:\r
 \r
   Stop this driver on ControllerHandle. Support stoping any child handles\r
@@ -304,11 +309,11 @@ Arguments:
   Controller        - Handle of device to stop driver on\r
   NumberOfChildren  - Number of Children in the ChildHandleBuffer\r
   ChildHandleBuffer - List of handles for the children we need to stop.\r
   Controller        - Handle of device to stop driver on\r
   NumberOfChildren  - Number of Children in the ChildHandleBuffer\r
   ChildHandleBuffer - List of handles for the children we need to stop.\r
-  \r
+\r
 Returns:\r
 \r
     EFI_STATUS\r
 Returns:\r
 \r
     EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
   EFI_STATUS                      Status;\r
 --*/\r
 {\r
   EFI_STATUS                      Status;\r
@@ -400,15 +405,15 @@ RegisterAtapiScsiPassThru (
   IN  UINT64                      OriginalPciAttributes\r
   )\r
 /*++\r
   IN  UINT64                      OriginalPciAttributes\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
   Attaches SCSI Pass Thru Protocol for specified IDE channel.\r
 Routine Description:\r
   Attaches SCSI Pass Thru Protocol for specified IDE channel.\r
-    \r
+\r
 Arguments:\r
   This              - Protocol instance pointer.\r
 Arguments:\r
   This              - Protocol instance pointer.\r
-  Controller        - Parent device handle to the IDE channel.    \r
-  PciIo             - PCI I/O protocol attached on the "Controller".                        \r
-  \r
+  Controller        - Parent device handle to the IDE channel.\r
+  PciIo             - PCI I/O protocol attached on the "Controller".\r
+\r
 Returns:\r
   Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.\r
 \r
 Returns:\r
   Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.\r
 \r
@@ -472,25 +477,25 @@ Routine Description:
 Arguments:\r
 \r
   This:     The EFI_SCSI_PASS_THRU_PROTOCOL instance.\r
 Arguments:\r
 \r
   This:     The EFI_SCSI_PASS_THRU_PROTOCOL instance.\r
-  Target:   The Target ID of the ATAPI device to send the SCSI \r
+  Target:   The Target ID of the ATAPI device to send the SCSI\r
             Request Packet. To ATAPI devices attached on an IDE\r
             Channel, Target ID 0 indicates Master device;Target\r
             ID 1 indicates Slave device.\r
   Lun:      The LUN of the ATAPI device to send the SCSI Request\r
             Packet. To the ATAPI device, Lun is always 0.\r
             Request Packet. To ATAPI devices attached on an IDE\r
             Channel, Target ID 0 indicates Master device;Target\r
             ID 1 indicates Slave device.\r
   Lun:      The LUN of the ATAPI device to send the SCSI Request\r
             Packet. To the ATAPI device, Lun is always 0.\r
-  Packet:   The SCSI Request Packet to send to the ATAPI device \r
+  Packet:   The SCSI Request Packet to send to the ATAPI device\r
             specified by Target and Lun.\r
             specified by Target and Lun.\r
-  Event:    If non-blocking I/O is not supported then Event is ignored, \r
+  Event:    If non-blocking I/O is not supported then Event is ignored,\r
             and blocking I/O is performed.\r
             If Event is NULL, then blocking I/O is performed.\r
             and blocking I/O is performed.\r
             If Event is NULL, then blocking I/O is performed.\r
-            If Event is not NULL and non blocking I/O is supported, \r
-            then non-blocking I/O is performed, and Event will be signaled \r
-            when the SCSI Request Packet completes.      \r
+            If Event is not NULL and non blocking I/O is supported,\r
+            then non-blocking I/O is performed, and Event will be signaled\r
+            when the SCSI Request Packet completes.\r
 \r
 \r
-Returns:  \r
+Returns:\r
 \r
    EFI_STATUS\r
 \r
    EFI_STATUS\r
-   \r
+\r
 --*/\r
 {\r
   ATAPI_SCSI_PASS_THRU_DEV               *AtapiScsiPrivate;\r
 --*/\r
 {\r
   ATAPI_SCSI_PASS_THRU_DEV               *AtapiScsiPrivate;\r
@@ -504,7 +509,7 @@ Returns:
   if ((Target > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if ((Target > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // check the data fields in Packet parameter.\r
   //\r
   //\r
   // check the data fields in Packet parameter.\r
   //\r
@@ -556,25 +561,25 @@ AtapiScsiPassThruGetNextDevice (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Used to retrieve the list of legal Target IDs for SCSI devices \r
+  Used to retrieve the list of legal Target IDs for SCSI devices\r
   on a SCSI channel.\r
 \r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
   on a SCSI channel.\r
 \r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  Target                - On input, a pointer to the Target ID of a SCSI \r
-                          device present on the SCSI channel.  On output, \r
+  Target                - On input, a pointer to the Target ID of a SCSI\r
+                          device present on the SCSI channel.  On output,\r
                           a pointer to the Target ID of the next SCSI device\r
                           a pointer to the Target ID of the next SCSI device\r
-                          present on a SCSI channel.  An input value of \r
-                          0xFFFFFFFF retrieves the Target ID of the first \r
+                          present on a SCSI channel.  An input value of\r
+                          0xFFFFFFFF retrieves the Target ID of the first\r
                           SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
                           SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
-                          to the LUN of the next SCSI device present on \r
+                          to the LUN of the next SCSI device present on\r
                           a SCSI channel.\r
 Returns:\r
 \r
                           a SCSI channel.\r
 Returns:\r
 \r
-  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device \r
+  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
@@ -635,7 +640,7 @@ AtapiScsiPassThruBuildDevicePath (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Used to allocate and build a device path node for a SCSI device \r
+  Used to allocate and build a device path node for a SCSI device\r
   on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
 \r
 Arguments:\r
   on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
 \r
 Arguments:\r
@@ -643,23 +648,23 @@ Arguments:
   This                  - Protocol instance pointer.\r
   Target                - The Target ID of the SCSI device for which\r
                           a device path node is to be allocated and built.\r
   This                  - Protocol instance pointer.\r
   Target                - The Target ID of the SCSI device for which\r
                           a device path node is to be allocated and built.\r
-  Lun                   - The LUN of the SCSI device for which a device \r
+  Lun                   - The LUN of the SCSI device for which a device\r
                           path node is to be allocated and built.\r
                           path node is to be allocated and built.\r
-  DevicePath            - A pointer to a single device path node that \r
-                          describes the SCSI device specified by \r
-                          Target and Lun. This function is responsible \r
+  DevicePath            - A pointer to a single device path node that\r
+                          describes the SCSI device specified by\r
+                          Target and Lun. This function is responsible\r
                           for allocating the buffer DevicePath with the boot\r
                           for allocating the buffer DevicePath with the boot\r
-                          service AllocatePool().  It is the caller's \r
+                          service AllocatePool().  It is the caller's\r
                           responsibility to free DevicePath when the caller\r
                           responsibility to free DevicePath when the caller\r
-                          is finished with DevicePath.    \r
+                          is finished with DevicePath.\r
   Returns:\r
   EFI_SUCCESS           - The device path node that describes the SCSI device\r
   Returns:\r
   EFI_SUCCESS           - The device path node that describes the SCSI device\r
-                          specified by Target and Lun was allocated and \r
+                          specified by Target and Lun was allocated and\r
                           returned in DevicePath.\r
   EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does\r
                           not exist on the SCSI channel.\r
   EFI_INVALID_PARAMETER - DevicePath is NULL.\r
                           returned in DevicePath.\r
   EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does\r
                           not exist on the SCSI channel.\r
   EFI_INVALID_PARAMETER - DevicePath is NULL.\r
-  EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate \r
+  EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate\r
                           DevicePath.\r
 --*/\r
 {\r
                           DevicePath.\r
 --*/\r
 {\r
@@ -716,21 +721,21 @@ Routine Description:
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  DevicePath            - A pointer to the device path node that \r
+  DevicePath            - A pointer to the device path node that\r
                           describes a SCSI device on the SCSI channel.\r
                           describes a SCSI device on the SCSI channel.\r
-  Target                - A pointer to the Target ID of a SCSI device \r
-                          on the SCSI channel. \r
-  Lun                   - A pointer to the LUN of a SCSI device on \r
-                          the SCSI channel.    \r
+  Target                - A pointer to the Target ID of a SCSI device\r
+                          on the SCSI channel.\r
+  Lun                   - A pointer to the LUN of a SCSI device on\r
+                          the SCSI channel.\r
 Returns:\r
 \r
 Returns:\r
 \r
-  EFI_SUCCESS           - DevicePath was successfully translated to a \r
-                          Target ID and LUN, and they were returned \r
+  EFI_SUCCESS           - DevicePath was successfully translated to a\r
+                          Target ID and LUN, and they were returned\r
                           in Target and Lun.\r
   EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
                           in Target and Lun.\r
   EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
-  EFI_UNSUPPORTED       - This driver does not support the device path \r
+  EFI_UNSUPPORTED       - This driver does not support the device path\r
                           node type in DevicePath.\r
                           node type in DevicePath.\r
-  EFI_NOT_FOUND         - A valid translation from DevicePath to a \r
+  EFI_NOT_FOUND         - A valid translation from DevicePath to a\r
                           Target ID and LUN does not exist.\r
 --*/\r
 {\r
                           Target ID and LUN does not exist.\r
 --*/\r
 {\r
@@ -773,7 +778,7 @@ AtapiScsiPassThruResetChannel (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Resets a SCSI channel.This operation resets all the \r
+  Resets a SCSI channel.This operation resets all the\r
   SCSI devices connected to the SCSI channel.\r
 \r
 Arguments:\r
   SCSI devices connected to the SCSI channel.\r
 \r
 Arguments:\r
@@ -783,11 +788,11 @@ Arguments:
 Returns:\r
 \r
   EFI_SUCCESS           - The SCSI channel was reset.\r
 Returns:\r
 \r
   EFI_SUCCESS           - The SCSI channel was reset.\r
-  EFI_UNSUPPORTED       - The SCSI channel does not support \r
+  EFI_UNSUPPORTED       - The SCSI channel does not support\r
                           a channel reset operation.\r
                           a channel reset operation.\r
-  EFI_DEVICE_ERROR      - A device error occurred while \r
+  EFI_DEVICE_ERROR      - A device error occurred while\r
                           attempting to reset the SCSI channel.\r
                           attempting to reset the SCSI channel.\r
-  EFI_TIMEOUT           - A timeout occurred while attempting \r
+  EFI_TIMEOUT           - A timeout occurred while attempting\r
                           to reset the SCSI channel.\r
 --*/\r
 {\r
                           to reset the SCSI channel.\r
 --*/\r
 {\r
@@ -868,20 +873,20 @@ Routine Description:
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  Target                - The Target ID of the SCSI device to reset. \r
+  Target                - The Target ID of the SCSI device to reset.\r
   Lun                   - The LUN of the SCSI device to reset.\r
   Lun                   - The LUN of the SCSI device to reset.\r
-    \r
+\r
 Returns:\r
 \r
 Returns:\r
 \r
-  EFI_SUCCESS           - The SCSI device specified by Target and \r
+  EFI_SUCCESS           - The SCSI device specified by Target and\r
                           Lun was reset.\r
   EFI_UNSUPPORTED       - The SCSI channel does not support a target\r
                           reset operation.\r
   EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
                           Lun was reset.\r
   EFI_UNSUPPORTED       - The SCSI channel does not support a target\r
                           reset operation.\r
   EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
-  EFI_DEVICE_ERROR      - A device error occurred while attempting \r
-                          to reset the SCSI device specified by Target \r
+  EFI_DEVICE_ERROR      - A device error occurred while attempting\r
+                          to reset the SCSI device specified by Target\r
                           and Lun.\r
                           and Lun.\r
-  EFI_TIMEOUT           - A timeout occurred while attempting to reset \r
+  EFI_TIMEOUT           - A timeout occurred while attempting to reset\r
                           the SCSI device specified by Target and Lun.\r
 --*/\r
 {\r
                           the SCSI device specified by Target and Lun.\r
 --*/\r
 {\r
@@ -958,45 +963,45 @@ Routine Description:
 Arguments:\r
 \r
   This:     The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
 Arguments:\r
 \r
   This:     The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
-  Target:   The Target ID of the ATAPI device to send the SCSI \r
+  Target:   The Target ID of the ATAPI device to send the SCSI\r
             Request Packet. To ATAPI devices attached on an IDE\r
             Channel, Target ID 0 indicates Master device;Target\r
             ID 1 indicates Slave device.\r
   Lun:      The LUN of the ATAPI device to send the SCSI Request\r
             Packet. To the ATAPI device, Lun is always 0.\r
             Request Packet. To ATAPI devices attached on an IDE\r
             Channel, Target ID 0 indicates Master device;Target\r
             ID 1 indicates Slave device.\r
   Lun:      The LUN of the ATAPI device to send the SCSI Request\r
             Packet. To the ATAPI device, Lun is always 0.\r
-  Packet:   The SCSI Request Packet to send to the ATAPI device \r
+  Packet:   The SCSI Request Packet to send to the ATAPI device\r
             specified by Target and Lun.\r
             specified by Target and Lun.\r
-  Event:    If non-blocking I/O is not supported then Event is ignored, \r
+  Event:    If non-blocking I/O is not supported then Event is ignored,\r
             and blocking I/O is performed.\r
             If Event is NULL, then blocking I/O is performed.\r
             and blocking I/O is performed.\r
             If Event is NULL, then blocking I/O is performed.\r
-            If Event is not NULL and non blocking I/O is supported, \r
-            then non-blocking I/O is performed, and Event will be signaled \r
-            when the SCSI Request Packet completes.      \r
+            If Event is not NULL and non blocking I/O is supported,\r
+            then non-blocking I/O is performed, and Event will be signaled\r
+            when the SCSI Request Packet completes.\r
 \r
 \r
-Returns:  \r
+Returns:\r
 \r
    EFI_STATUS\r
 \r
    EFI_STATUS\r
-   \r
+\r
 --*/\r
 {\r
   EFI_STATUS                          Status;\r
   ATAPI_SCSI_PASS_THRU_DEV            *AtapiScsiPrivate;\r
   UINT8                                TargetId;\r
 --*/\r
 {\r
   EFI_STATUS                          Status;\r
   ATAPI_SCSI_PASS_THRU_DEV            *AtapiScsiPrivate;\r
   UINT8                                TargetId;\r
-  \r
+\r
   AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
 \r
   //\r
   // For ATAPI device, UINT8 is enough to represent the SCSI ID on channel.\r
   //\r
   TargetId = Target[0];\r
   AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
 \r
   //\r
   // For ATAPI device, UINT8 is enough to represent the SCSI ID on channel.\r
   //\r
   TargetId = Target[0];\r
-  \r
+\r
   //\r
   // Target is not allowed beyond MAX_TARGET_ID\r
   //\r
   if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
   // Target is not allowed beyond MAX_TARGET_ID\r
   //\r
   if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // check the data fields in Packet parameter.\r
   //\r
   //\r
   // check the data fields in Packet parameter.\r
   //\r
@@ -1013,7 +1018,7 @@ Returns:
     Packet->InTransferLength = Packet->OutTransferLength = 0;\r
     return EFI_SUCCESS;\r
   }\r
     Packet->InTransferLength = Packet->OutTransferLength = 0;\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // According to Target ID, reset the Atapi I/O Register mapping\r
   // (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
   //\r
   // According to Target ID, reset the Atapi I/O Register mapping\r
   // (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
@@ -1026,7 +1031,7 @@ Returns:
     TargetId = (UINT8) (TargetId % 2);\r
     AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
   }\r
     TargetId = (UINT8) (TargetId % 2);\r
     AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
   }\r
-  \r
+\r
   //\r
   // the ATAPI SCSI interface does not support non-blocking I/O\r
   // ignore the Event parameter\r
   //\r
   // the ATAPI SCSI interface does not support non-blocking I/O\r
   // ignore the Event parameter\r
@@ -1048,25 +1053,25 @@ AtapiExtScsiPassThruGetNextTargetLun (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Used to retrieve the list of legal Target IDs for SCSI devices \r
+  Used to retrieve the list of legal Target IDs for SCSI devices\r
   on a SCSI channel.\r
 \r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
   on a SCSI channel.\r
 \r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  Target                - On input, a pointer to the Target ID of a SCSI \r
-                          device present on the SCSI channel.  On output, \r
+  Target                - On input, a pointer to the Target ID of a SCSI\r
+                          device present on the SCSI channel.  On output,\r
                           a pointer to the Target ID of the next SCSI device\r
                           a pointer to the Target ID of the next SCSI device\r
-                          present on a SCSI channel.  An input value of \r
-                          0xFFFFFFFF retrieves the Target ID of the first \r
+                          present on a SCSI channel.  An input value of\r
+                          0xFFFFFFFF retrieves the Target ID of the first\r
                           SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
                           SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
-                          to the LUN of the next SCSI device present on \r
+                          to the LUN of the next SCSI device present on\r
                           a SCSI channel.\r
 Returns:\r
 \r
                           a SCSI channel.\r
 Returns:\r
 \r
-  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device \r
+  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
@@ -1076,7 +1081,7 @@ Returns:
   UINT8                          ByteIndex;\r
   UINT8                          TargetId;\r
   UINT8                          ScsiId[TARGET_MAX_BYTES];\r
   UINT8                          ByteIndex;\r
   UINT8                          TargetId;\r
   UINT8                          ScsiId[TARGET_MAX_BYTES];\r
-  ATAPI_SCSI_PASS_THRU_DEV       *AtapiScsiPrivate; \r
+  ATAPI_SCSI_PASS_THRU_DEV       *AtapiScsiPrivate;\r
 \r
   //\r
   // Retrieve Device Private Data Structure.\r
 \r
   //\r
   // Retrieve Device Private Data Structure.\r
@@ -1102,9 +1107,9 @@ Returns:
       if ((*Target)[ByteIndex] != 0) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
       if ((*Target)[ByteIndex] != 0) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
-    } \r
+    }\r
   }\r
   }\r
-  \r
+\r
   if ((CompareMem(*Target, ScsiId, TARGET_MAX_BYTES) != 0) &&\r
       ((TargetId != AtapiScsiPrivate->LatestTargetId) ||\r
       (*Lun != AtapiScsiPrivate->LatestLun))) {\r
   if ((CompareMem(*Target, ScsiId, TARGET_MAX_BYTES) != 0) &&\r
       ((TargetId != AtapiScsiPrivate->LatestTargetId) ||\r
       (*Lun != AtapiScsiPrivate->LatestLun))) {\r
@@ -1145,7 +1150,7 @@ AtapiExtScsiPassThruBuildDevicePath (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Used to allocate and build a device path node for a SCSI device \r
+  Used to allocate and build a device path node for a SCSI device\r
   on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
 \r
 Arguments:\r
   on a SCSI channel. Would not build device path for a SCSI Host Controller.\r
 \r
 Arguments:\r
@@ -1153,39 +1158,39 @@ Arguments:
   This                  - Protocol instance pointer.\r
   Target                - The Target ID of the SCSI device for which\r
                           a device path node is to be allocated and built.\r
   This                  - Protocol instance pointer.\r
   Target                - The Target ID of the SCSI device for which\r
                           a device path node is to be allocated and built.\r
-  Lun                   - The LUN of the SCSI device for which a device \r
+  Lun                   - The LUN of the SCSI device for which a device\r
                           path node is to be allocated and built.\r
                           path node is to be allocated and built.\r
-  DevicePath            - A pointer to a single device path node that \r
-                          describes the SCSI device specified by \r
-                          Target and Lun. This function is responsible \r
+  DevicePath            - A pointer to a single device path node that\r
+                          describes the SCSI device specified by\r
+                          Target and Lun. This function is responsible\r
                           for allocating the buffer DevicePath with the boot\r
                           for allocating the buffer DevicePath with the boot\r
-                          service AllocatePool().  It is the caller's \r
+                          service AllocatePool().  It is the caller's\r
                           responsibility to free DevicePath when the caller\r
                           responsibility to free DevicePath when the caller\r
-                          is finished with DevicePath.    \r
+                          is finished with DevicePath.\r
   Returns:\r
   EFI_SUCCESS           - The device path node that describes the SCSI device\r
   Returns:\r
   EFI_SUCCESS           - The device path node that describes the SCSI device\r
-                          specified by Target and Lun was allocated and \r
+                          specified by Target and Lun was allocated and\r
                           returned in DevicePath.\r
   EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does\r
                           not exist on the SCSI channel.\r
   EFI_INVALID_PARAMETER - DevicePath is NULL.\r
                           returned in DevicePath.\r
   EFI_NOT_FOUND         - The SCSI devices specified by Target and Lun does\r
                           not exist on the SCSI channel.\r
   EFI_INVALID_PARAMETER - DevicePath is NULL.\r
-  EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate \r
+  EFI_OUT_OF_RESOURCES  - There are not enough resources to allocate\r
                           DevicePath.\r
 --*/\r
 {\r
   EFI_DEV_PATH                   *Node;\r
   UINT8                          TargetId;\r
 \r
                           DevicePath.\r
 --*/\r
 {\r
   EFI_DEV_PATH                   *Node;\r
   UINT8                          TargetId;\r
 \r
-  TargetId = Target[0];  \r
+  TargetId = Target[0];\r
 \r
   //\r
   // Validate parameters passed in.\r
   //\r
 \r
   //\r
   // Validate parameters passed in.\r
   //\r
-  \r
+\r
   if (DevicePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (DevicePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // can not build device path for the SCSI Host Controller.\r
   //\r
   //\r
   // can not build device path for the SCSI Host Controller.\r
   //\r
@@ -1228,21 +1233,21 @@ Routine Description:
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  DevicePath            - A pointer to the device path node that \r
+  DevicePath            - A pointer to the device path node that\r
                           describes a SCSI device on the SCSI channel.\r
                           describes a SCSI device on the SCSI channel.\r
-  Target                - A pointer to the Target ID of a SCSI device \r
-                          on the SCSI channel. \r
-  Lun                   - A pointer to the LUN of a SCSI device on \r
-                          the SCSI channel.    \r
+  Target                - A pointer to the Target ID of a SCSI device\r
+                          on the SCSI channel.\r
+  Lun                   - A pointer to the LUN of a SCSI device on\r
+                          the SCSI channel.\r
 Returns:\r
 \r
 Returns:\r
 \r
-  EFI_SUCCESS           - DevicePath was successfully translated to a \r
-                          Target ID and LUN, and they were returned \r
+  EFI_SUCCESS           - DevicePath was successfully translated to a\r
+                          Target ID and LUN, and they were returned\r
                           in Target and Lun.\r
   EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
                           in Target and Lun.\r
   EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.\r
-  EFI_UNSUPPORTED       - This driver does not support the device path \r
+  EFI_UNSUPPORTED       - This driver does not support the device path\r
                           node type in DevicePath.\r
                           node type in DevicePath.\r
-  EFI_NOT_FOUND         - A valid translation from DevicePath to a \r
+  EFI_NOT_FOUND         - A valid translation from DevicePath to a\r
                           Target ID and LUN does not exist.\r
 --*/\r
 {\r
                           Target ID and LUN does not exist.\r
 --*/\r
 {\r
@@ -1254,7 +1259,7 @@ Returns:
   if (DevicePath == NULL || Target == NULL || Lun == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (DevicePath == NULL || Target == NULL || Lun == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // Check whether the DevicePath belongs to SCSI_DEVICE_PATH\r
   //\r
   //\r
   // Check whether the DevicePath belongs to SCSI_DEVICE_PATH\r
   //\r
@@ -1287,7 +1292,7 @@ AtapiExtScsiPassThruResetChannel (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Resets a SCSI channel.This operation resets all the \r
+  Resets a SCSI channel.This operation resets all the\r
   SCSI devices connected to the SCSI channel.\r
 \r
 Arguments:\r
   SCSI devices connected to the SCSI channel.\r
 \r
 Arguments:\r
@@ -1297,11 +1302,11 @@ Arguments:
 Returns:\r
 \r
   EFI_SUCCESS           - The SCSI channel was reset.\r
 Returns:\r
 \r
   EFI_SUCCESS           - The SCSI channel was reset.\r
-  EFI_UNSUPPORTED       - The SCSI channel does not support \r
+  EFI_UNSUPPORTED       - The SCSI channel does not support\r
                           a channel reset operation.\r
                           a channel reset operation.\r
-  EFI_DEVICE_ERROR      - A device error occurred while \r
+  EFI_DEVICE_ERROR      - A device error occurred while\r
                           attempting to reset the SCSI channel.\r
                           attempting to reset the SCSI channel.\r
-  EFI_TIMEOUT           - A timeout occurred while attempting \r
+  EFI_TIMEOUT           - A timeout occurred while attempting\r
                           to reset the SCSI channel.\r
 --*/\r
 {\r
                           to reset the SCSI channel.\r
 --*/\r
 {\r
@@ -1348,7 +1353,7 @@ Returns:
     // 0xfb:1111,1011\r
     //\r
     DeviceControlValue &= 0xfb;\r
     // 0xfb:1111,1011\r
     //\r
     DeviceControlValue &= 0xfb;\r
-    \r
+\r
     WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, DeviceControlValue);\r
 \r
     //\r
     WritePortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Alt.DeviceControl, DeviceControlValue);\r
 \r
     //\r
@@ -1362,7 +1367,7 @@ Returns:
   if (ResetFlag) {\r
     return EFI_SUCCESS;\r
   }\r
   if (ResetFlag) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   return EFI_TIMEOUT;\r
 }\r
 \r
   return EFI_TIMEOUT;\r
 }\r
 \r
@@ -1382,20 +1387,20 @@ Routine Description:
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
 Arguments:\r
 \r
   This                  - Protocol instance pointer.\r
-  Target                - The Target ID of the SCSI device to reset. \r
+  Target                - The Target ID of the SCSI device to reset.\r
   Lun                   - The LUN of the SCSI device to reset.\r
   Lun                   - The LUN of the SCSI device to reset.\r
-    \r
+\r
 Returns:\r
 \r
 Returns:\r
 \r
-  EFI_SUCCESS           - The SCSI device specified by Target and \r
+  EFI_SUCCESS           - The SCSI device specified by Target and\r
                           Lun was reset.\r
   EFI_UNSUPPORTED       - The SCSI channel does not support a target\r
                           reset operation.\r
   EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
                           Lun was reset.\r
   EFI_UNSUPPORTED       - The SCSI channel does not support a target\r
                           reset operation.\r
   EFI_INVALID_PARAMETER - Target or Lun are invalid.\r
-  EFI_DEVICE_ERROR      - A device error occurred while attempting \r
-                          to reset the SCSI device specified by Target \r
+  EFI_DEVICE_ERROR      - A device error occurred while attempting\r
+                          to reset the SCSI device specified by Target\r
                           and Lun.\r
                           and Lun.\r
-  EFI_TIMEOUT           - A timeout occurred while attempting to reset \r
+  EFI_TIMEOUT           - A timeout occurred while attempting to reset\r
                           the SCSI device specified by Target and Lun.\r
 --*/\r
 {\r
                           the SCSI device specified by Target and Lun.\r
 --*/\r
 {\r
@@ -1403,10 +1408,10 @@ Returns:
   UINT8                         DeviceSelect;\r
   UINT8                         TargetId;\r
   ATAPI_SCSI_PASS_THRU_DEV      *AtapiScsiPrivate;\r
   UINT8                         DeviceSelect;\r
   UINT8                         TargetId;\r
   ATAPI_SCSI_PASS_THRU_DEV      *AtapiScsiPrivate;\r
-  \r
+\r
   AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
   TargetId = Target[0];\r
   AtapiScsiPrivate = ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS (This);\r
   TargetId = Target[0];\r
-  \r
+\r
   if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if ((TargetId > MAX_TARGET_ID) || (Lun != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1416,7 +1421,7 @@ Returns:
   if (TargetId == This->Mode->AdapterId) {\r
     return EFI_SUCCESS;\r
   }\r
   if (TargetId == This->Mode->AdapterId) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // According to Target ID, reset the Atapi I/O Register mapping\r
   // (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
   //\r
   // According to Target ID, reset the Atapi I/O Register mapping\r
   // (Target Id in [0,1] area, using AtapiIoPortRegisters[0],\r
@@ -1427,7 +1432,7 @@ Returns:
   } else {\r
     AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
   }\r
   } else {\r
     AtapiScsiPrivate->IoPort = &AtapiScsiPrivate->AtapiIoPortRegisters[1];\r
   }\r
-  \r
+\r
   //\r
   // for ATAPI device, no need to wait DRDY ready after device selecting.\r
   //\r
   //\r
   // for ATAPI device, no need to wait DRDY ready after device selecting.\r
   //\r
@@ -1447,7 +1452,7 @@ Returns:
   if (EFI_ERROR (StatusWaitForBSYClear (AtapiScsiPrivate, 31000000))) {\r
     return EFI_TIMEOUT;\r
   }\r
   if (EFI_ERROR (StatusWaitForBSYClear (AtapiScsiPrivate, 31000000))) {\r
     return EFI_TIMEOUT;\r
   }\r
-  \r
+\r
   //\r
   // stall 5 seconds to make the device status stable\r
   //\r
   //\r
   // stall 5 seconds to make the device status stable\r
   //\r
@@ -1466,24 +1471,24 @@ AtapiExtScsiPassThruGetNextTarget (
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
-  Used to retrieve the list of legal Target IDs for SCSI devices \r
+  Used to retrieve the list of legal Target IDs for SCSI devices\r
   on a SCSI channel.\r
 \r
 Arguments:\r
   This                  - Protocol instance pointer.\r
   on a SCSI channel.\r
 \r
 Arguments:\r
   This                  - Protocol instance pointer.\r
-  Target                - On input, a pointer to the Target ID of a SCSI \r
-                          device present on the SCSI channel.  On output, \r
+  Target                - On input, a pointer to the Target ID of a SCSI\r
+                          device present on the SCSI channel.  On output,\r
                           a pointer to the Target ID of the next SCSI device\r
                           a pointer to the Target ID of the next SCSI device\r
-                           present on a SCSI channel.  An input value of \r
-                           0xFFFFFFFF retrieves the Target ID of the first \r
+                           present on a SCSI channel.  An input value of\r
+                           0xFFFFFFFF retrieves the Target ID of the first\r
                            SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
                            SCSI device present on a SCSI channel.\r
   Lun                   - On input, a pointer to the LUN of a SCSI device\r
                           present on the SCSI channel. On output, a pointer\r
-                          to the LUN of the next SCSI device present on \r
+                          to the LUN of the next SCSI device present on\r
                           a SCSI channel.\r
                           a SCSI channel.\r
-    \r
+\r
 Returns:\r
 Returns:\r
-  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device \r
+  EFI_SUCCESS           - The Target ID and Lun of the next SCSI device\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
                           on the SCSI channel was returned in Target and Lun.\r
   EFI_NOT_FOUND         - There are no more SCSI devices on this SCSI channel.\r
   EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not\r
@@ -1492,7 +1497,7 @@ Returns:
 {\r
   UINT8                         TargetId;\r
   UINT8                         ScsiId[TARGET_MAX_BYTES];\r
 {\r
   UINT8                         TargetId;\r
   UINT8                         ScsiId[TARGET_MAX_BYTES];\r
-  ATAPI_SCSI_PASS_THRU_DEV      *AtapiScsiPrivate;  \r
+  ATAPI_SCSI_PASS_THRU_DEV      *AtapiScsiPrivate;\r
   UINT8                         ByteIndex;\r
 \r
   //\r
   UINT8                         ByteIndex;\r
 \r
   //\r
@@ -1725,16 +1730,16 @@ IsCommandValid (
   EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   *Packet\r
   )\r
 /*++\r
   EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   *Packet\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
 \r
 Routine Description:\r
 \r
-  Checks the requested SCSI command: \r
+  Checks the requested SCSI command:\r
   Is it supported by this driver?\r
   Is the Data transfer direction reasonable?\r
 \r
 Arguments:\r
 \r
   Is it supported by this driver?\r
   Is the Data transfer direction reasonable?\r
 \r
 Arguments:\r
 \r
-  Packet         -  The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   \r
+  Packet         -  The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
 \r
 Returns:\r
 \r
 \r
 Returns:\r
 \r
@@ -1791,19 +1796,19 @@ SubmitBlockingIoCommand (
 Routine Description:\r
 \r
   Performs blocking I/O request.\r
 Routine Description:\r
 \r
   Performs blocking I/O request.\r
-    \r
+\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
-  Target:             The Target ID of the ATAPI device to send the SCSI \r
+  Target:             The Target ID of the ATAPI device to send the SCSI\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
-  Packet:             The SCSI Request Packet to send to the ATAPI device \r
+  Packet:             The SCSI Request Packet to send to the ATAPI device\r
                       specified by Target.\r
                       specified by Target.\r
-  \r
-  Returns:            EFI_STATUS  \r
-  \r
+\r
+  Returns:            EFI_STATUS\r
+\r
 --*/\r
 {\r
   UINT8       PacketCommand[12];\r
 --*/\r
 {\r
   UINT8       PacketCommand[12];\r
@@ -1891,7 +1896,7 @@ Arguments:
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
   EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  Packet;\r
 --*/\r
 {\r
   EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  Packet;\r
@@ -1931,9 +1936,9 @@ Routine Description:
 Arguments:\r
 \r
   Packet       - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
 Arguments:\r
 \r
   Packet       - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
-  \r
+\r
 Returns:\r
 Returns:\r
-  \r
+\r
   EFI_STATUS\r
 \r
 --*/\r
   EFI_STATUS\r
 \r
 --*/\r
@@ -1949,7 +1954,7 @@ Returns:
   if (Packet->Cdb == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (Packet->Cdb == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // Checks whether the request command is supported.\r
   //\r
   //\r
   // Checks whether the request command is supported.\r
   //\r
@@ -1966,16 +1971,16 @@ IsExtCommandValid (
   EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   *Packet\r
   )\r
 /*++\r
   EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   *Packet\r
   )\r
 /*++\r
-  \r
+\r
 Routine Description:\r
 \r
 Routine Description:\r
 \r
-  Checks the requested SCSI command: \r
+  Checks the requested SCSI command:\r
   Is it supported by this driver?\r
   Is the Data transfer direction reasonable?\r
 \r
 Arguments:\r
 \r
   Is it supported by this driver?\r
   Is the Data transfer direction reasonable?\r
 \r
 Arguments:\r
 \r
-  Packet         -  The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET   \r
+  Packet         -  The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET\r
 \r
 Returns:\r
 \r
 \r
 Returns:\r
 \r
@@ -2032,19 +2037,19 @@ SubmitExtBlockingIoCommand (
 Routine Description:\r
 \r
   Performs blocking I/O request.\r
 Routine Description:\r
 \r
   Performs blocking I/O request.\r
-    \r
+\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
-  Target:             The Target ID of the ATAPI device to send the SCSI \r
+  Target:             The Target ID of the ATAPI device to send the SCSI\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
-  Packet:             The SCSI Request Packet to send to the ATAPI device \r
+  Packet:             The SCSI Request Packet to send to the ATAPI device\r
                       specified by Target.\r
                       specified by Target.\r
-  \r
-  Returns:            EFI_STATUS  \r
-  \r
+\r
+  Returns:            EFI_STATUS\r
+\r
 --*/\r
 {\r
   UINT8       PacketCommand[12];\r
 --*/\r
 {\r
   UINT8       PacketCommand[12];\r
@@ -2087,12 +2092,12 @@ Arguments:
                             TimeoutInMicroSeconds\r
                             );\r
   }\r
                             TimeoutInMicroSeconds\r
                             );\r
   }\r
-  \r
+\r
   if (!EFI_ERROR (PacketCommandStatus) || (Packet->SenseData == NULL)) {\r
     Packet->SenseDataLength = 0;\r
     return PacketCommandStatus;\r
   }\r
   if (!EFI_ERROR (PacketCommandStatus) || (Packet->SenseData == NULL)) {\r
     Packet->SenseDataLength = 0;\r
     return PacketCommandStatus;\r
   }\r
-  \r
+\r
   //\r
   // Return SenseData if PacketCommandStatus matches\r
   // the following return codes.\r
   //\r
   // Return SenseData if PacketCommandStatus matches\r
   // the following return codes.\r
@@ -2137,11 +2142,11 @@ AtapiPacketCommand (
 Routine Description:\r
 \r
   Submits ATAPI command packet to the specified ATAPI device.\r
 Routine Description:\r
 \r
   Submits ATAPI command packet to the specified ATAPI device.\r
-    \r
+\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
 Arguments:\r
 \r
   AtapiScsiPrivate:   Private data structure for the specified channel.\r
-  Target:             The Target ID of the ATAPI device to send the SCSI \r
+  Target:             The Target ID of the ATAPI device to send the SCSI\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
                       Request Packet. To ATAPI devices attached on an IDE\r
                       Channel, Target ID 0 indicates Master device;Target\r
                       ID 1 indicates Slave device.\r
@@ -2149,22 +2154,22 @@ Arguments:
   Buffer:             Points to the transferred data.\r
   ByteCount:          When input,indicates the buffer size; when output,\r
                       indicates the actually transferred data size.\r
   Buffer:             Points to the transferred data.\r
   ByteCount:          When input,indicates the buffer size; when output,\r
                       indicates the actually transferred data size.\r
-  Direction:          Indicates the data transfer direction. \r
+  Direction:          Indicates the data transfer direction.\r
   TimeoutInMicroSeconds:\r
   TimeoutInMicroSeconds:\r
-                      The timeout, in micro second units, to use for the \r
+                      The timeout, in micro second units, to use for the\r
                       execution of this ATAPI command.\r
                       execution of this ATAPI command.\r
-                      A TimeoutInMicroSeconds value of 0 means that \r
-                      this function will wait indefinitely for the ATAPI \r
+                      A TimeoutInMicroSeconds value of 0 means that\r
+                      this function will wait indefinitely for the ATAPI\r
                       command to execute.\r
                       command to execute.\r
-                      If TimeoutInMicroSeconds is greater than zero, then \r
-                      this function will return EFI_TIMEOUT if the time \r
-                      required to execute the ATAPI command is greater \r
+                      If TimeoutInMicroSeconds is greater than zero, then\r
+                      this function will return EFI_TIMEOUT if the time\r
+                      required to execute the ATAPI command is greater\r
                       than TimeoutInMicroSeconds.\r
                       than TimeoutInMicroSeconds.\r
-  \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
 \r
@@ -2300,28 +2305,28 @@ Routine Description:
 \r
   Performs data transfer between ATAPI device and host after the\r
   ATAPI command packet is sent.\r
 \r
   Performs data transfer between ATAPI device and host after the\r
   ATAPI command packet is sent.\r
-    \r
+\r
 Arguments:\r
 \r
 Arguments:\r
 \r
-  AtapiScsiPrivate:   Private data structure for the specified channel.    \r
+  AtapiScsiPrivate:   Private data structure for the specified channel.\r
   Buffer:             Points to the transferred data.\r
   ByteCount:          When input,indicates the buffer size; when output,\r
                       indicates the actually transferred data size.\r
   Buffer:             Points to the transferred data.\r
   ByteCount:          When input,indicates the buffer size; when output,\r
                       indicates the actually transferred data size.\r
-  Direction:          Indicates the data transfer direction. \r
+  Direction:          Indicates the data transfer direction.\r
   TimeoutInMicroSeconds:\r
   TimeoutInMicroSeconds:\r
-                      The timeout, in micro second units, to use for the \r
+                      The timeout, in micro second units, to use for the\r
                       execution of this ATAPI command.\r
                       execution of this ATAPI command.\r
-                      A TimeoutInMicroSeconds value of 0 means that \r
-                      this function will wait indefinitely for the ATAPI \r
+                      A TimeoutInMicroSeconds value of 0 means that\r
+                      this function will wait indefinitely for the ATAPI\r
                       command to execute.\r
                       command to execute.\r
-                      If TimeoutInMicroSeconds is greater than zero, then \r
-                      this function will return EFI_TIMEOUT if the time \r
-                      required to execute the ATAPI command is greater \r
+                      If TimeoutInMicroSeconds is greater than zero, then\r
+                      this function will return EFI_TIMEOUT if the time\r
+                      required to execute the ATAPI command is greater\r
                       than TimeoutInMicroSeconds.\r
  Returns:\r
 \r
   EFI_STATUS\r
                       than TimeoutInMicroSeconds.\r
  Returns:\r
 \r
   EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
   UINT32      Index;\r
 --*/\r
 {\r
   UINT32      Index;\r
@@ -2428,7 +2433,7 @@ Arguments:
 \r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
 \r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
-  \r
+\r
 Returns:\r
 \r
   A byte read out\r
 Returns:\r
 \r
   A byte read out\r
@@ -2465,7 +2470,7 @@ Arguments:
 \r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
 \r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
-  \r
+\r
 Returns:\r
 \r
   A word read out\r
 Returns:\r
 \r
   A word read out\r
@@ -2503,7 +2508,7 @@ Arguments:
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
   Data       - The data to write\r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
   Data       - The data to write\r
-  \r
+\r
 Returns:\r
 \r
    NONE\r
 Returns:\r
 \r
    NONE\r
@@ -2538,11 +2543,11 @@ Arguments:
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
   Data       - The data to write\r
   PciIo      - The pointer of EFI_PCI_IO_PROTOCOL\r
   Port       - IO port\r
   Data       - The data to write\r
-  \r
+\r
 Returns:\r
 \r
    NONE\r
 Returns:\r
 \r
    NONE\r
-   \r
+\r
 --*/\r
 {\r
   PciIo->Io.Write (\r
 --*/\r
 {\r
   PciIo->Io.Write (\r
@@ -2566,18 +2571,18 @@ Routine Description:
 \r
   Check whether DRQ is clear in the Status Register. (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
 \r
   Check whether DRQ is clear in the Status Register. (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
-  \r
+\r
 --*/\r
 {\r
   UINT64  Delay;\r
 --*/\r
 {\r
   UINT64  Delay;\r
@@ -2648,16 +2653,16 @@ AltStatusDRQClear (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Check whether DRQ is clear in the Alternate Status Register. \r
-  (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should \r
-  wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  Check whether DRQ is clear in the Alternate Status Register.\r
+  (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should\r
+  wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -2732,14 +2737,14 @@ Routine Description:
 \r
   Check whether DRQ is ready in the Status Register. (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
 \r
   Check whether DRQ is ready in the Status Register. (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -2814,17 +2819,17 @@ AltStatusDRQReady (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Check whether DRQ is ready in the Alternate Status Register. \r
+  Check whether DRQ is ready in the Alternate Status Register.\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -2900,14 +2905,14 @@ Routine Description:
 \r
   Check whether BSY is clear in the Status Register.\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
 \r
   Check whether BSY is clear in the Status Register.\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -2966,14 +2971,14 @@ Routine Description:
 \r
   Check whether BSY is clear in the Alternate Status Register.\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
 \r
   Check whether BSY is clear in the Alternate Status Register.\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -3029,17 +3034,17 @@ StatusDRDYReady (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Check whether DRDY is ready in the Status Register. \r
+  Check whether DRDY is ready in the Status Register.\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -3109,17 +3114,17 @@ AltStatusDRDYReady (
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Check whether DRDY is ready in the Alternate Status Register. \r
+  Check whether DRDY is ready in the Alternate Status Register.\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
   (BSY must also be cleared)\r
   If TimeoutInMicroSeconds is zero, this routine should wait infinitely for\r
-  DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is \r
+  DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
   elapsed.\r
 \r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
   TimeoutInMicroSeconds       - The time to wait for\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -3184,16 +3189,16 @@ EFI_STATUS
 AtapiPassThruCheckErrorStatus (\r
   ATAPI_SCSI_PASS_THRU_DEV        *AtapiScsiPrivate\r
   )\r
 AtapiPassThruCheckErrorStatus (\r
   ATAPI_SCSI_PASS_THRU_DEV        *AtapiScsiPrivate\r
   )\r
-/*++  \r
+/*++\r
 \r
 Routine Description:\r
 \r
 \r
 Routine Description:\r
 \r
-  Check Error Register for Error Information. \r
-  \r
+  Check Error Register for Error Information.\r
+\r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
 Arguments:\r
 \r
   AtapiScsiPrivate            - The pointer of ATAPI_SCSI_PASS_THRU_DEV\r
-   \r
+\r
 Returns:\r
 \r
   EFI_STATUS\r
 Returns:\r
 \r
   EFI_STATUS\r
@@ -3291,17 +3296,17 @@ Returns:
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Installs Scsi Pass Thru and/or Ext Scsi Pass Thru \r
-  protocols based on feature flags. \r
+  Installs Scsi Pass Thru and/or Ext Scsi Pass Thru\r
+  protocols based on feature flags.\r
 \r
 \r
-  @param Controller         The controller handle to \r
+  @param Controller         The controller handle to\r
                             install these protocols on.\r
   @param AtapiScsiPrivate   A pointer to the protocol private\r
                             data structure.\r
 \r
                             install these protocols on.\r
   @param AtapiScsiPrivate   A pointer to the protocol private\r
                             data structure.\r
 \r
-  @retval EFI_SUCCESS       The installation succeeds. \r
-  @retval other             The installation fails. \r
-   \r
+  @retval EFI_SUCCESS       The installation succeeds.\r
+  @retval other             The installation fails.\r
+\r
 **/\r
 EFI_STATUS\r
 InstallScsiPassThruProtocols (\r
 **/\r
 EFI_STATUS\r
 InstallScsiPassThruProtocols (\r
@@ -3349,7 +3354,7 @@ InstallScsiPassThruProtocols (
       //\r
       // This driver must support either ScsiPassThru or\r
       // ExtScsiPassThru protocols\r
       //\r
       // This driver must support either ScsiPassThru or\r
       // ExtScsiPassThru protocols\r
-      // \r
+      //\r
       ASSERT (FALSE);\r
       Status = EFI_UNSUPPORTED;\r
     }\r
       ASSERT (FALSE);\r
       Status = EFI_UNSUPPORTED;\r
     }\r
@@ -3391,7 +3396,7 @@ InitializeAtapiPassThru(
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
-  // Install EFI Driver Supported EFI Version Protocol required for \r
+  // Install EFI Driver Supported EFI Version Protocol required for\r
   // EFI drivers that are on PCI and other plug in cards.\r
   //\r
   gAtapiScsiPassThruDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r
   // EFI drivers that are on PCI and other plug in cards.\r
   //\r
   gAtapiScsiPassThruDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion);\r