]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / Atapi.c
index c641dc5714bcc5d678aa0d4ed9bb4e9fdfd39988..1900a76800f887d3948406516a7b7f08a98d28c2 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
-   This file contains all helper functions on the ATAPI command \r
-  \r
-  Copyright (c) 2006 - 2017, 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
+   This file contains all helper functions on the ATAPI command\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) 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
+  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
 \r
@@ -16,7 +16,7 @@
 \r
 /**\r
   This function is used to get the current status of the media residing\r
-  in the LS-120 drive or ZIP drive. The media status is returned in the \r
+  in the LS-120 drive or ZIP drive. The media status is returned in the\r
   Error Status.\r
 \r
   @param IdeDev   pointer pointing to IDE_BLK_IO_DEV data structure, used\r
@@ -28,8 +28,8 @@
   @retval EFI_NO_MEDIA        There is no media in the drive.\r
   @retval EFI_WRITE_PROTECTED The media is writing protected.\r
 \r
-  @note  This function must be called after the LS120EnableMediaStatus() \r
-         with second parameter set to TRUE \r
+  @note  This function must be called after the LS120EnableMediaStatus()\r
+         with second parameter set to TRUE\r
          (means enable media status notification) is called.\r
 **/\r
 EFI_STATUS\r
@@ -189,8 +189,8 @@ AtapiReadPendingData (
     while ((TempWordBuffer & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {\r
       IDEReadPortWMultiple (\r
         IdeDev->PciIo,\r
-        IdeDev->IoPort->Data, \r
-        1, \r
+        IdeDev->IoPort->Data,\r
+        1,\r
         &TempWordBuffer\r
         );\r
       TempWordBuffer = IDEReadPortB (IdeDev->PciIo,IdeDev->IoPort->Alt.AltStatus);\r
@@ -200,7 +200,7 @@ AtapiReadPendingData (
 }\r
 \r
 /**\r
-  This function is called by either AtapiPacketCommandIn() or AtapiPacketCommandOut(). \r
+  This function is called by either AtapiPacketCommandIn() or AtapiPacketCommandOut().\r
   It is used to transfer data between host and device. The data direction is specified\r
   by the fourth parameter.\r
 \r
@@ -246,9 +246,9 @@ PioReadWriteData (
   }\r
   //\r
   // for performance, we assert the ByteCount is an even number\r
-  // which is actually a resonable assumption  \r
+  // which is actually a resonable assumption\r
   ASSERT((ByteCount%2) == 0);\r
-  \r
+\r
   PtrBuffer         = Buffer;\r
   RequiredWordCount = ByteCount / 2;\r
   //\r
@@ -257,7 +257,7 @@ PioReadWriteData (
   ActualWordCount = 0;\r
 \r
   while (ActualWordCount < RequiredWordCount) {\r
-    \r
+\r
     //\r
     // before each data transfer stream, the host should poll DRQ bit ready,\r
     // to see whether indicates device is ready to transfer data.\r
@@ -266,7 +266,7 @@ PioReadWriteData (
     if (EFI_ERROR (Status)) {\r
       return CheckErrorStatus (IdeDev);\r
     }\r
-    \r
+\r
     //\r
     // read Status Register will clear interrupt\r
     //\r
@@ -301,7 +301,7 @@ PioReadWriteData (
     PtrBuffer += WordCount;\r
     ActualWordCount += WordCount;\r
   }\r
-  \r
+\r
   if (Read) {\r
     //\r
     // In the case where the drive wants to send more data than we need to read,\r
@@ -326,17 +326,17 @@ PioReadWriteData (
 }\r
 \r
 /**\r
-  This function is used to send out ATAPI commands conforms to the Packet Command \r
+  This function is used to send out ATAPI commands conforms to the Packet Command\r
   with PIO Data In Protocol.\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
   @param Packet    pointer pointing to ATAPI_PACKET_COMMAND data structure\r
-                   which contains the contents of the command.     \r
+                   which contains the contents of the command.\r
   @param Buffer    buffer contained data transferred from device to host.\r
   @param ByteCount data size in byte unit of the buffer.\r
-  @param TimeOut   this parameter is used to specify the timeout value for the \r
-                   PioReadWriteData() function. \r
+  @param TimeOut   this parameter is used to specify the timeout value for the\r
+                   PioReadWriteData() function.\r
 \r
   @retval EFI_SUCCESS       send out the ATAPI packet command successfully\r
                             and device sends data successfully.\r
@@ -437,10 +437,10 @@ AtapiPacketCommandIn (
                      which contains the contents of the command.\r
   @param Buffer      buffer contained data transferred from host to device.\r
   @param ByteCount   data size in byte unit of the buffer.\r
-  @param TimeOut     this parameter is used to specify the timeout value \r
-                     for the PioReadWriteData() function. \r
+  @param TimeOut     this parameter is used to specify the timeout value\r
+                     for the PioReadWriteData() function.\r
   @retval EFI_SUCCESS      send out the ATAPI packet command successfully\r
-                           and device received data successfully.  \r
+                           and device received data successfully.\r
   @retval EFI_DEVICE_ERROR the device failed to send data.\r
 \r
 **/\r
@@ -465,7 +465,7 @@ AtapiPacketCommandOut (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Select device via Device/Head Register.\r
   //\r
@@ -587,26 +587,26 @@ AtapiInquiry (
   to fill in the Media data structure of the Block I/O Protocol interface.\r
 \r
   There are 5 steps to reach such objective:\r
-  1. Sends out the ATAPI Identify Command to the specified device. \r
+  1. Sends out the ATAPI Identify Command to the specified device.\r
   Only ATAPI device responses to this command. If the command succeeds,\r
-  it returns the Identify data structure which filled with information \r
-  about the device. Since the ATAPI device contains removable media, \r
+  it returns the Identify data structure which filled with information\r
+  about the device. Since the ATAPI device contains removable media,\r
   the only meaningful information is the device module name.\r
   2. Sends out ATAPI Inquiry Packet Command to the specified device.\r
   This command will return inquiry data of the device, which contains\r
   the device type information.\r
   3. Allocate sense data space for future use. We don't detect the media\r
-  presence here to improvement boot performance, especially when CD \r
+  presence here to improvement boot performance, especially when CD\r
   media is present. The media detection will be performed just before\r
   each BLK_IO read/write\r
-  \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
 \r
   @retval EFI_SUCCESS       Identify ATAPI device successfully.\r
   @retval EFI_DEVICE_ERROR  ATAPI Identify Device Command failed or device type\r
                             is not supported by this IDE driver.\r
-  @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed \r
+  @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed\r
 \r
   @note   Parameter "IdeDev" will be updated in this function.\r
 **/\r
@@ -719,7 +719,7 @@ ATAPIIdentify (
   // WORM\r
   //\r
   case 0x04:\r
-  \r
+\r
   //\r
   // Optical\r
   //\r
@@ -758,13 +758,13 @@ ATAPIIdentify (
 }\r
 /**\r
   Sends out ATAPI Request Sense Packet Command to the specified device. This command\r
-  will return all the current Sense data in the device.  This function will pack \r
+  will return all the current Sense data in the device.  This function will pack\r
   all the Sense data in one single buffer.\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
   @param SenseCounts  allocated in this function, and freed by the calling function.\r
-                      This buffer is used to accommodate all the sense data returned \r
+                      This buffer is used to accommodate all the sense data returned\r
                       by the device.\r
 \r
   @retval EFI_SUCCESS      Request Sense command completes successfully.\r
@@ -850,7 +850,7 @@ AtapiRequestSense (
 }\r
 /**\r
   This function is used to parse sense data. Only the first sense data is honoured\r
-  \r
+\r
   @param IdeDev     Indicates the calling context.\r
   @param SenseCount Count of sense data.\r
   @param Result    The parsed result.\r
@@ -936,12 +936,12 @@ ParseSenseData (
 EFI_STATUS\r
 AtapiTestUnitReady (\r
   IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT SENSE_RESULT    *SResult  \r
+  OUT SENSE_RESULT    *SResult\r
   )\r
 {\r
   ATAPI_PACKET_COMMAND  Packet;\r
   EFI_STATUS            Status;\r
-  UINTN                                SenseCount;\r
+  UINTN         SenseCount;\r
 \r
   //\r
   // fill command packet\r
@@ -974,7 +974,7 @@ AtapiTestUnitReady (
 \r
   Current device status will impact device's response to the Read Capacity\r
   Command. For example, if the device once reset, the Read Capacity\r
-  Command will fail. The Sense data record the current device status, so \r
+  Command will fail. The Sense data record the current device status, so\r
   if the Read Capacity Command failed, the Sense data must be requested\r
   and be analyzed to determine if the Read Capacity Command should retry.\r
 \r
@@ -988,12 +988,12 @@ AtapiTestUnitReady (
 \r
   @note Parameter "IdeDev" will be updated in this function.\r
 \r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 AtapiReadCapacity (\r
   IN  IDE_BLK_IO_DEV  *IdeDev,\r
-  OUT SENSE_RESULT       *SResult  \r
+  OUT SENSE_RESULT    *SResult\r
   )\r
 {\r
   //\r
@@ -1002,7 +1002,7 @@ AtapiReadCapacity (
   EFI_STATUS                Status;\r
   EFI_STATUS                SenseStatus;\r
   ATAPI_PACKET_COMMAND      Packet;\r
-  UINTN                                        SenseCount;\r
+  UINTN           SenseCount;\r
 \r
   //\r
   // used for capacity data returned from ATAPI device\r
@@ -1048,9 +1048,9 @@ AtapiReadCapacity (
   SenseStatus = AtapiRequestSense (IdeDev, &SenseCount);\r
 \r
   if (!EFI_ERROR (SenseStatus)) {\r
-       ParseSenseData (IdeDev, SenseCount, SResult);                    \r
-                                                                                                                        \r
-       if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {\r
+  ParseSenseData (IdeDev, SenseCount, SResult);\r
+\r
+  if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {\r
       if (IdeDev->Type == IdeCdRom) {\r
 \r
         IdeDev->BlkIo.Media->LastBlock = ((UINT32) Data.LastLba3 << 24) |\r
@@ -1058,7 +1058,7 @@ AtapiReadCapacity (
           (Data.LastLba1 << 8) |\r
           Data.LastLba0;\r
 \r
-             IdeDev->BlkIo.Media->MediaPresent = TRUE;\r
+        IdeDev->BlkIo.Media->MediaPresent = TRUE;\r
 \r
         IdeDev->BlkIo.Media->ReadOnly = TRUE;\r
 \r
@@ -1077,7 +1077,7 @@ AtapiReadCapacity (
         } else {\r
 \r
           IdeDev->BlkIo.Media->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |\r
-            (FormatData.LastLba2 << 16) | \r
+            (FormatData.LastLba2 << 16) |\r
             (FormatData.LastLba1 << 8)  |\r
             FormatData.LastLba0;\r
           if (IdeDev->BlkIo.Media->LastBlock != 0) {\r
@@ -1110,7 +1110,7 @@ AtapiReadCapacity (
 }\r
 /**\r
   This function is used to test the current media write-protected or not residing\r
-  in the LS-120 drive or ZIP drive. \r
+  in the LS-120 drive or ZIP drive.\r
   @param IdeDev          pointer pointing to IDE_BLK_IO_DEV data structure, used\r
                          to record all the information of the IDE device.\r
   @param WriteProtected  if True, current media is write protected.\r
@@ -1159,8 +1159,8 @@ IsLS120orZipWriteProtected (
 }\r
 \r
 /**\r
-  Used before read/write blocks from/to ATAPI device media. Since ATAPI device \r
-  media is removable, it is necessary to detect whether media is present and \r
+  Used before read/write blocks from/to ATAPI device media. Since ATAPI device\r
+  media is removable, it is necessary to detect whether media is present and\r
   get current present media's information, and if media has been changed, Block\r
   I/O Protocol need to be reinstalled.\r
 \r
@@ -1409,17 +1409,17 @@ AtapiDetectMedia (
   This function is called by the AtapiBlkIoReadBlocks() to perform\r
   read from media in block unit.\r
 \r
-  The main command used to access media here is READ(10) Command. \r
-  READ(10) Command requests that the ATAPI device media transfer \r
-  specified data to the host. Data is transferred in block(sector) \r
+  The main command used to access media here is READ(10) Command.\r
+  READ(10) Command requests that the ATAPI device media transfer\r
+  specified data to the host. Data is transferred in block(sector)\r
   unit. The maximum number of blocks that can be transferred once is\r
-  65536. This is the main difference between READ(10) and READ(12) \r
+  65536. This is the main difference between READ(10) and READ(12)\r
   Command. The maximum number of blocks in READ(12) is 2 power 32.\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
-  @param Buffer           A pointer to the destination buffer for the data. \r
-  @param Lba              The starting logical block address to read from on the \r
+  @param Buffer           A pointer to the destination buffer for the data.\r
+  @param Lba              The starting logical block address to read from on the\r
                           device media.\r
   @param NumberOfBlocks   The number of transfer data blocks.\r
 \r
@@ -1527,19 +1527,19 @@ AtapiReadSectors (
 /**\r
   This function is called by the AtapiBlkIoWriteBlocks() to perform\r
   write onto media in block unit.\r
-  The main command used to access media here is Write(10) Command. \r
-  Write(10) Command requests that the ATAPI device media transfer \r
-  specified data to the host. Data is transferred in block (sector) \r
+  The main command used to access media here is Write(10) Command.\r
+  Write(10) Command requests that the ATAPI device media transfer\r
+  specified data to the host. Data is transferred in block (sector)\r
   unit. The maximum number of blocks that can be transferred once is\r
-  65536. \r
+  65536.\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
-  @param Buffer          A pointer to the source buffer for the data. \r
-  @param Lba             The starting logical block address to write onto \r
+  @param Buffer          A pointer to the source buffer for the data.\r
+  @param Lba             The starting logical block address to write onto\r
                          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 AtapiPacketCommandOut() function.\r
 \r
 **/\r
@@ -1594,7 +1594,7 @@ AtapiWriteSectors (
     } else {\r
       SectorCount = (UINT16) BlocksRemaining;\r
     }\r
-  \r
+\r
     //\r
     // Command code is WRITE_10.\r
     //\r
@@ -1645,7 +1645,7 @@ AtapiWriteSectors (
   condition (such as BSY bit is always set ), I think the Soft Reset\r
   command should be sent without waiting for the BSY clear and DRDY\r
   set.\r
-  This function is called by IdeBlkIoReset(), \r
+  This function is called by IdeBlkIoReset(),\r
   a interface function of Block I/O protocol.\r
 \r
   @param IdeDev    pointer pointing to IDE_BLK_IO_DEV data structure, used\r
@@ -1683,7 +1683,7 @@ AtapiSoftReset (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   //\r
   // stall 5 seconds to make the device status stable\r
   //\r
@@ -1702,9 +1702,9 @@ AtapiSoftReset (
   @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 destination 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 read into.\r
-  \r
+\r
   @retval EFI_SUCCESS           Read Blocks successfully.\r
   @retval EFI_DEVICE_ERROR      Read Blocks failed.\r
   @retval EFI_NO_MEDIA          There is no media in the device.\r
@@ -1804,11 +1804,11 @@ AtapiBlkIoReadBlocks (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   //\r
   // Read blocks succeeded\r
   //\r
-  \r
+\r
   //\r
   // save the first block to the cache for performance\r
   //\r
@@ -1840,8 +1840,8 @@ AtapiBlkIoReadBlocks (
   @retval EFI_NO_MEDIA           There is no media in the device.\r
   @retval EFI_MEDIA_CHANGE       The MediaId is not for the current media.\r
   @retval EFI_BAD_BUFFER_SIZE    The BufferSize parameter is not a multiple of the\r
-                                 intrinsic block size of the device.  \r
-  @retval EFI_INVALID_PARAMETER  The write request contains LBAs that are not valid, \r
+                                 intrinsic block size of the device.\r
+  @retval EFI_INVALID_PARAMETER  The write request contains LBAs that are not valid,\r
                                  or the data buffer is not valid.\r
 \r
   @retval EFI_WRITE_PROTECTED    The write protected is enabled or the media does not support write\r
@@ -1889,7 +1889,7 @@ AtapiBlkIoWriteBlocks (
     }\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Get the intrinsic block size\r
   //\r