]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / Ata.c
index c541eb8991a91e5cd7680567838859b81d6fb9d3..7819773f3864247aba8fc46bba9597611940a571 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  This file contains all helper functions on the ATA command \r
-  \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This file contains all helper functions on the ATA command\r
+\r
+  Copyright (c) 2006 - 2018, 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
@@ -31,9 +31,9 @@
   @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
                 all the information of the IDE device.\r
 \r
-  @retval EFI_SUCCESS       The disk specified by IdeDev is a Atapi6 supported one and \r
+  @retval EFI_SUCCESS       The disk specified by IdeDev is a Atapi6 supported one and\r
                             48-bit addressing must be used\r
-  @retval EFI_UNSUPPORTED   The disk dosn't not support Atapi6 or it supports but the \r
+  @retval EFI_UNSUPPORTED   The disk dosn't not support Atapi6 or it supports but the\r
                             capacity is below 120G, 48bit addressing is not needed\r
   @retval  EFI_DEVICE_ERROR      The identify data in IdeDev is incorrect\r
   @retval  EFI_INVALID_PARAMETER The identify data in IdeDev is NULL.\r
@@ -110,7 +110,7 @@ AtaAtapi6Identify (
 /**\r
   Enable SMART of the disk if supported\r
 \r
-  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record \r
+  @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
                 all the information of the IDE device.\r
 **/\r
 VOID\r
@@ -263,7 +263,7 @@ AtaSMARTSupport (
   information it needs to fill the IDE_BLK_IO_DEV data structure,\r
   including device type, media block size, media capacity, and etc.\r
 \r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure,used to record \r
+  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
                  all the information of the IDE device.\r
 \r
   @retval EFI_SUCCESS      Identify ATA device successfully.\r
@@ -280,7 +280,7 @@ ATAIdentify (
   EFI_IDENTIFY_DATA *AtaIdentifyPointer;\r
   UINT32            Capacity;\r
   UINT8             DeviceSelect;\r
-  UINTN                                Retry;\r
+  UINTN        Retry;\r
 \r
   //\r
   //  AtaIdentifyPointer is used for accommodating returned IDENTIFY data of\r
@@ -297,9 +297,9 @@ ATAIdentify (
   //\r
   DeviceSelect  = (UINT8) ((IdeDev->Device) << 4);\r
 \r
-  \r
+\r
   Retry = 3;\r
-  while (Retry > 0) {  \r
+  while (Retry > 0) {\r
     Status = AtaPioDataIn (\r
               IdeDev,\r
               (VOID *) AtaIdentifyPointer,\r
@@ -348,20 +348,20 @@ ATAIdentify (
           //\r
           return EFI_SUCCESS;\r
         } else if (Status == EFI_DEVICE_ERROR) {\r
-                 //\r
-                 // Some disk with big capacity (>200GB) is slow when being identified\r
-                 // and will return all zero for word83.\r
-                 // We try twice at first. If it fails, we do a SoftRest and try again.\r
-                 //\r
-                 Retry--;\r
-                 if (Retry == 1) {\r
-                   //\r
-                   // Do a SoftRest before the third attempt.\r
-                   //\r
-                   AtaSoftReset (IdeDev);\r
-                 }\r
-                 continue;\r
-           }\r
+      //\r
+      // Some disk with big capacity (>200GB) is slow when being identified\r
+      // and will return all zero for word83.\r
+      // We try twice at first. If it fails, we do a SoftRest and try again.\r
+      //\r
+      Retry--;\r
+      if (Retry == 1) {\r
+        //\r
+        // Do a SoftRest before the third attempt.\r
+        //\r
+        AtaSoftReset (IdeDev);\r
+      }\r
+      continue;\r
+      }\r
         //\r
         // This is a hard disk <= 120GB capacity, treat it as normal hard disk\r
         //\r
@@ -390,7 +390,7 @@ ATAIdentify (
       }\r
 \r
     }\r
-       break;\r
+    break;\r
   }\r
 \r
   gBS->FreePool (AtaIdentifyPointer);\r
@@ -404,12 +404,12 @@ ATAIdentify (
 \r
 /**\r
   This function is a helper function used to change the char order in a string. It\r
-  is designed specially for the PrintAtaModuleName() function. After the IDE device \r
-  is detected, the IDE driver gets the device module name by sending ATA command \r
+  is designed specially for the PrintAtaModuleName() function. After the IDE device\r
+  is detected, the IDE driver gets the device module name by sending ATA command\r
   called ATA Identify Command or ATAPI Identify Command to the specified IDE device.\r
   The module name returned is a string of ASCII characters: the first character is bit8--bit15\r
   of the first word, the second character is BIT0--bit7 of the first word and so on. Thus\r
-  the string can not be print directly before it is preprocessed by this func to change \r
+  the string can not be print directly before it is preprocessed by this func to change\r
   the order of characters in each word in the string.\r
 \r
   @param Destination Indicates the destination string.\r
@@ -455,7 +455,7 @@ PrintAtaModuleName (
 /**\r
   This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
 \r
-  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+  @param IdeDev       pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
                       all the information of the IDE device.\r
   @param Buffer       buffer contained data transferred from device to host.\r
   @param ByteCount    data size in byte unit of the buffer.\r
@@ -465,7 +465,7 @@ PrintAtaModuleName (
   @param SectorNumber value of the Sector Number Register\r
   @param CylinderLsb  value of the low byte of the Cylinder Register\r
   @param CylinderMsb  value of the high byte of the Cylinder Register\r
-  \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
@@ -752,7 +752,7 @@ AtaPioDataOut (
   some debug information and if there is ERR bit set in the Status\r
   Register, the Error Register's value is also be parsed and print out.\r
 \r
-  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to \r
+  @param IdeDev  pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
                  record all the information of the IDE device.\r
 \r
   @retval EFI_SUCCESS       No err information in the Status Register.\r
@@ -850,15 +850,15 @@ CheckErrorStatus (
 }\r
 \r
 /**\r
-  This function is called by the AtaBlkIoReadBlocks() to perform reading from \r
+  This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
   media in block unit.\r
 \r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
                         all the information of the IDE device.\r
   @param DataBuffer     A pointer to the destination buffer for the data.\r
   @param Lba            The starting logical block address to read from on the device media.\r
   @param NumberOfBlocks The number of transfer data blocks.\r
-  \r
+\r
   @return status is fully dependent on the return status of AtaPioDataIn() function.\r
 \r
 **/\r
@@ -959,7 +959,7 @@ AtaReadSectors (
 }\r
 \r
 /**\r
-  This function is called by the AtaBlkIoWriteBlocks() to perform writing onto \r
+  This function is called by the AtaBlkIoWriteBlocks() to perform writing onto\r
   media in block unit.\r
 \r
   @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
@@ -967,7 +967,7 @@ AtaReadSectors (
   @param BufferData     A pointer to the source buffer for the data.\r
   @param Lba            The starting logical block address to write onto the device media.\r
   @param NumberOfBlocks The number of transfer data blocks.\r
-  \r
+\r
   @return status is fully dependent on the return status of AtaPioDataIn() function.\r
 \r
 **/\r
@@ -1055,7 +1055,7 @@ AtaWriteSectors (
 }\r
 /**\r
   This function is used to implement the Soft Reset on the specified device. But,\r
-  the ATA Soft Reset mechanism is so strong a reset method that it will force \r
+  the ATA Soft Reset mechanism is so strong a reset method that it will force\r
   resetting on both devices connected to the same cable.\r
 \r
   It is called by IdeBlkIoReset(), a interface function of Block\r
@@ -1120,7 +1120,7 @@ AtaSoftReset (
   return EFI_SUCCESS;\r
 }\r
 /**\r
-  This function is used to send out ATA commands conforms to the PIO Data In \r
+  This function is used to send out ATA commands conforms to the PIO Data In\r
   Protocol, supporting ATA/ATAPI-6 standard\r
 \r
   Comparing with ATA-3 data in protocol, we have two differents here:\r
@@ -1595,27 +1595,27 @@ DoAtaUdma (
   // Read BMIS register and clear ERROR and INTR bit\r
   //\r
   IdeDev->PciIo->Io.Read (\r
-                                         IdeDev->PciIo,\r
-                                         EfiPciIoWidthUint8,\r
-                                         EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                         IoPortForBmis,\r
-                                         1,\r
-                                         &RegisterValue\r
-                                         );\r
-  \r
+            IdeDev->PciIo,\r
+            EfiPciIoWidthUint8,\r
+            EFI_PCI_IO_PASS_THROUGH_BAR,\r
+            IoPortForBmis,\r
+            1,\r
+            &RegisterValue\r
+            );\r
+\r
   RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);\r
-  \r
+\r
   IdeDev->PciIo->Io.Write (\r
-                                         IdeDev->PciIo,\r
-                                         EfiPciIoWidthUint8,\r
-                                         EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                                         IoPortForBmis,\r
-                                         1,\r
-                                         &RegisterValue\r
-                                         );\r
+            IdeDev->PciIo,\r
+            EfiPciIoWidthUint8,\r
+            EFI_PCI_IO_PASS_THROUGH_BAR,\r
+            IoPortForBmis,\r
+            1,\r
+            &RegisterValue\r
+            );\r
 \r
   Status = EFI_SUCCESS;\r
-  \r
+\r
   RemainBlockNum = NumberOfBlocks;\r
   while (RemainBlockNum > 0) {\r
 \r
@@ -1813,8 +1813,8 @@ DoAtaUdma (
                           );\r
       if (((RegisterValue & (BMIS_INTERRUPT | BMIS_ERROR)) != 0) || (Count == 0)) {\r
         if (((RegisterValue & BMIS_ERROR) != 0) || (Count == 0)) {\r
-                 Status = EFI_DEVICE_ERROR;\r
-                 break;\r
+      Status = EFI_DEVICE_ERROR;\r
+      break;\r
         }\r
         break;\r
       }\r
@@ -1847,7 +1847,7 @@ DoAtaUdma (
                         1,\r
                         &RegisterValue\r
                         );\r
-       //\r
+  //\r
     // Read Status Register of IDE device to clear interrupt\r
     //\r
     RegisterValue = IDEReadPortB(IdeDev->PciIo,IdeDev->IoPort->Reg.Status);\r
@@ -1878,9 +1878,9 @@ DoAtaUdma (
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
-       if (EFI_ERROR (Status)) {\r
-         break;\r
-       }\r
+  if (EFI_ERROR (Status)) {\r
+    break;\r
+  }\r
     DataBuffer = (UINT8 *) DataBuffer + NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;\r
     StartLba += NumberOfBlocks;\r
   }\r
@@ -1898,10 +1898,10 @@ DoAtaUdma (
 \r
 /**\r
   This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
-  media in block unit. The function has been enhanced to support >120GB access \r
+  media in block unit. The function has been enhanced to support >120GB access\r
   and transfer at most 65536 blocks per command\r
 \r
-  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+  @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
                         all the information of the IDE device.\r
   @param DataBuffer     A pointer to the destination buffer for the data.\r
   @param StartLba       The starting logical block address to read from on the device media.\r
@@ -1930,7 +1930,7 @@ AtaUdmaReadExt (
   @param StartLba       The starting logical block address to read from\r
                         on the device media.\r
   @param NumberOfBlocks The number of transfer data blocks.\r
-  \r
+\r
   @return status depends on the function DoAtaUdma() returns.\r
 **/\r
 EFI_STATUS\r
@@ -2313,7 +2313,7 @@ AtaUdmaWriteExt (
 \r
 /**\r
   This function is called by the AtaBlkIoWriteBlocks() to perform\r
-  writing to media in block unit. \r
+  writing to media in block unit.\r
 \r
   @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure, used\r
                         to record all the information of the IDE device.\r
@@ -2321,7 +2321,7 @@ AtaUdmaWriteExt (
   @param StartLba       The starting logical block address to write to\r
                         on the device media.\r
   @param NumberOfBlocks The number of transfer data blocks.\r
-  \r
+\r
   @return status depends on the function DoAtaUdma() returns.\r
 **/\r
 EFI_STATUS\r
@@ -2342,7 +2342,7 @@ AtaUdmaWrite (
   @param IdeDev         pointer pointing to IDE_BLK_IO_DEV data structure,used\r
                         to record all the information of the IDE device.\r
   @param DataBuffer     A pointer to the source buffer for the data.\r
-  @param StartLba       The starting logical block address to write onto the device \r
+  @param StartLba       The starting logical block address to write onto the device\r
                         media.\r
   @param NumberOfBlocks The number of transfer data blocks.\r
 \r
@@ -2423,7 +2423,7 @@ AtaWriteSectorsExt (
   @param BufferSize      The size of the Buffer in bytes. This must be a multiple\r
                          of the intrinsic block size of the device.\r
   @param Buffer          A pointer to the source buffer for the data.The caller\r
-                         is responsible for either having implicit or explicit \r
+                         is responsible for either having implicit or explicit\r
                          ownership of the memory that data is written from.\r
 \r
   @retval EFI_SUCCESS       Write Blocks successfully.\r