]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
index cb009e7771bb815fa6ee3d157f26098319ccf476..ab7987acf0a4f35eb30794f1475aaf0dd1105731 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
-  UEFI and Tiano Custom Decompress Library \r
+  UEFI and Tiano Custom Decompress Library\r
   It will do Tiano or UEFI decompress with different verison parameter.\r
-  \r
-Copyright (c) 2006 - 2015, 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
+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
@@ -17,9 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 /**\r
   Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
-  \r
+\r
   @param Sd         The global scratch data\r
-  @param NumOfBits  The number of bits to shift and read.  \r
+  @param NumOfBits  The number of bits to shift and read.\r
 **/\r
 VOID\r
 FillBuf (\r
@@ -62,7 +62,7 @@ FillBuf (
   // Calculate additional bit count read to update mBitCount\r
   //\r
   Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
-  \r
+\r
   //\r
   // Copy NumOfBits of bits from mSubBitBuf into mBitBuf\r
   //\r
@@ -72,8 +72,8 @@ FillBuf (
 /**\r
   Get NumOfBits of bits out from mBitBuf\r
 \r
-  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
-  NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+  Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent\r
+  NumOfBits of bits from source. Returns NumOfBits of bits that are\r
   popped out.\r
 \r
   @param  Sd        The global scratch data.\r
@@ -92,7 +92,7 @@ GetBits (
 \r
   //\r
   // Pop NumOfBits of Bits from Left\r
-  //  \r
+  //\r
   OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
 \r
   //\r
@@ -106,7 +106,7 @@ GetBits (
 /**\r
   Creates Huffman Code mapping table according to code length array.\r
 \r
-  Creates Huffman Code mapping table for Extra Set, Char&Len Set \r
+  Creates Huffman Code mapping table for Extra Set, Char&Len Set\r
   and Position Set according to code length array.\r
   If TableBits > 16, then ASSERT ().\r
 \r
@@ -157,7 +157,7 @@ MakeTable (
   for (Index = 0; Index < NumOfChar; Index++) {\r
     Count[BitLen[Index]]++;\r
   }\r
-  \r
+\r
   Start[0] = 0;\r
   Start[1] = 0;\r
 \r
@@ -173,7 +173,7 @@ MakeTable (
   }\r
 \r
   JuBits = (UINT16) (16 - TableBits);\r
-  \r
+\r
   Weight[0] = 0;\r
   for (Index = 1; Index <= TableBits; Index++) {\r
     Start[Index] >>= JuBits;\r
@@ -182,7 +182,7 @@ MakeTable (
 \r
   while (Index <= 16) {\r
     Weight[Index] = (UINT16) (1U << (16 - Index));\r
-    Index++;    \r
+    Index++;\r
   }\r
 \r
   Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
@@ -223,7 +223,7 @@ MakeTable (
           Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;\r
           *Pointer = Avail++;\r
         }\r
-        \r
+\r
         if (*Pointer < (2 * NC - 1)) {\r
           if ((Index3 & Mask) != 0) {\r
             Pointer = &Sd->mRight[*Pointer];\r
@@ -250,11 +250,11 @@ MakeTable (
 \r
 /**\r
   Decodes a position value.\r
-  \r
+\r
   Get a position value according to Position Huffman Table.\r
 \r
   @param Sd      the global scratch data\r
-  \r
+\r
   @return The position value decoded.\r
 **/\r
 UINT32\r
@@ -325,7 +325,7 @@ ReadPTLen (
 \r
   ASSERT (nn <= NPT);\r
   //\r
-  // Read Extra Set Code Length Array size \r
+  // Read Extra Set Code Length Array size\r
   //\r
   Number = (UINT16) GetBits (Sd, nbit);\r
 \r
@@ -352,7 +352,7 @@ ReadPTLen (
 \r
     //\r
     // If a code length is less than 7, then it is encoded as a 3-bit\r
-    // value. Or it is encoded as a series of "1"s followed by a \r
+    // value. Or it is encoded as a series of "1"s followed by a\r
     // terminating "0". The number of "1"s = Code length - 4.\r
     //\r
     if (CharC == 7) {\r
@@ -362,15 +362,15 @@ ReadPTLen (
         CharC += 1;\r
       }\r
     }\r
-    \r
+\r
     FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
 \r
     Sd->mPTLen[Index++] = (UINT8) CharC;\r
\r
+\r
     //\r
-    // For Code&Len Set, \r
+    // For Code&Len Set,\r
     // After the third length of the code length concatenation,\r
-    // a 2-bit value is used to indicated the number of consecutive \r
+    // a 2-bit value is used to indicated the number of consecutive\r
     // zero lengths after the third length.\r
     //\r
     if (Index == Special) {\r
@@ -384,13 +384,13 @@ ReadPTLen (
   while (Index < nn && Index < NPT) {\r
     Sd->mPTLen[Index++] = 0;\r
   }\r
-  \r
+\r
   return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
 }\r
 \r
 /**\r
   Reads code lengths for Char&Len Set.\r
-  \r
+\r
   Read in and decode the Char&Len Set Code Length Array, then\r
   generate the Huffman Code mapping table for the Char&Len Set.\r
 \r
@@ -477,7 +477,7 @@ ReadCLen (
 \r
 /**\r
   Decode a character/length value.\r
-  \r
+\r
   Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates\r
   Huffman code mapping table for Extra Set, Code&Len Set and\r
   Position Set.\r
@@ -499,7 +499,7 @@ DecodeC (
     //\r
     // Starting a new block\r
     // Read BlockSize from block header\r
-    // \r
+    //\r
     Sd->mBlockSize    = (UINT16) GetBits (Sd, 16);\r
 \r
     //\r
@@ -556,7 +556,7 @@ DecodeC (
 \r
 /**\r
   Decode the source data and put the resulting data into the destination buffer.\r
-  \r
+\r
   @param  Sd The global scratch data\r
 **/\r
 VOID\r
@@ -575,7 +575,7 @@ Decode (
   for (;;) {\r
     //\r
     // Get one code from mBitBuf\r
-    // \r
+    //\r
     CharC = DecodeC (Sd);\r
     if (Sd->mBadTableFlag != 0) {\r
       goto Done;\r
@@ -599,7 +599,7 @@ Decode (
       // Process a Pointer\r
       //\r
       CharC       = (UINT16) (CharC - (BIT8 - THRESHOLD));\r
\r
+\r
       //\r
       // Get string length\r
       //\r
@@ -630,18 +630,18 @@ Done:
 }\r
 \r
 /**\r
-  Given a compressed source buffer, this function retrieves the size of \r
-  the uncompressed buffer and the size of the scratch buffer required \r
+  Given a compressed source buffer, this function retrieves the size of\r
+  the uncompressed buffer and the size of the scratch buffer required\r
   to decompress the compressed source buffer.\r
 \r
-  Retrieves the size of the uncompressed buffer and the temporary scratch buffer \r
+  Retrieves the size of the uncompressed buffer and the temporary scratch buffer\r
   required to decompress the buffer specified by Source and SourceSize.\r
   If the size of the uncompressed buffer or the size of the scratch buffer cannot\r
-  be determined from the compressed data specified by Source and SourceData, \r
+  be determined from the compressed data specified by Source and SourceData,\r
   then RETURN_INVALID_PARAMETER is returned.  Otherwise, the size of the uncompressed\r
   buffer is returned in DestinationSize, the size of the scratch buffer is returned\r
   in ScratchSize, and RETURN_SUCCESS is returned.\r
-  This function does not have scratch buffer available to perform a thorough \r
+  This function does not have scratch buffer available to perform a thorough\r
   checking of the validity of the source data.  It just retrieves the "Original Size"\r
   field from the beginning bytes of the source data and output it as DestinationSize.\r
   And ScratchSize is specific to the decompression implementation.\r
@@ -656,16 +656,16 @@ Done:
                           that will be generated when the compressed buffer specified\r
                           by Source and SourceSize is decompressed..\r
   @param  ScratchSize     A pointer to the size, in bytes, of the scratch buffer that\r
-                          is required to decompress the compressed buffer specified \r
+                          is required to decompress the compressed buffer specified\r
                           by Source and SourceSize.\r
 \r
-  @retval  RETURN_SUCCESS The size of the uncompressed data was returned \r
-                          in DestinationSize and the size of the scratch \r
+  @retval  RETURN_SUCCESS The size of the uncompressed data was returned\r
+                          in DestinationSize and the size of the scratch\r
                           buffer was returned in ScratchSize.\r
-  @retval  RETURN_INVALID_PARAMETER \r
-                          The size of the uncompressed data or the size of \r
-                          the scratch buffer cannot be determined from \r
-                          the compressed data specified by Source \r
+  @retval  RETURN_INVALID_PARAMETER\r
+                          The size of the uncompressed data or the size of\r
+                          the scratch buffer cannot be determined from\r
+                          the compressed data specified by Source\r
                           and SourceSize.\r
 **/\r
 RETURN_STATUS\r
@@ -704,10 +704,10 @@ UefiDecompressGetInfo (
   Extracts decompressed data to its original form.\r
   This function is designed so that the decompression algorithm can be implemented\r
   without using any memory services.  As a result, this function is not allowed to\r
-  call any memory allocation services in its implementation.  It is the caller's \r
+  call any memory allocation services in its implementation.  It is the caller's\r
   responsibility to allocate and free the Destination and Scratch buffers.\r
-  If the compressed source data specified by Source is successfully decompressed \r
-  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data \r
+  If the compressed source data specified by Source is successfully decompressed\r
+  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data\r
   specified by Source is not in a valid compressed data format,\r
   then RETURN_INVALID_PARAMETER is returned.\r
 \r
@@ -718,14 +718,14 @@ UefiDecompressGetInfo (
   @param  Source      The source buffer containing the compressed data.\r
   @param  Destination The destination buffer to store the decompressed data\r
   @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
-                      This is an optional parameter that may be NULL if the \r
+                      This is an optional parameter that may be NULL if the\r
                       required scratch buffer size is 0.\r
   @param  Version     1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm.\r
 \r
-  @retval  RETURN_SUCCESS Decompression completed successfully, and \r
+  @retval  RETURN_SUCCESS Decompression completed successfully, and\r
                           the uncompressed buffer is returned in Destination.\r
-  @retval  RETURN_INVALID_PARAMETER \r
-                          The source buffer specified by Source is corrupted \r
+  @retval  RETURN_INVALID_PARAMETER\r
+                          The source buffer specified by Source is corrupted\r
                           (not in a valid compressed format).\r
 **/\r
 RETURN_STATUS\r
@@ -815,10 +815,10 @@ UefiTianoDecompress (
   Extracts decompressed data to its original form.\r
   This function is designed so that the decompression algorithm can be implemented\r
   without using any memory services.  As a result, this function is not allowed to\r
-  call any memory allocation services in its implementation.  It is the caller's \r
+  call any memory allocation services in its implementation.  It is the caller's\r
   responsibility to allocate and free the Destination and Scratch buffers.\r
-  If the compressed source data specified by Source is successfully decompressed \r
-  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data \r
+  If the compressed source data specified by Source is successfully decompressed\r
+  into Destination, then RETURN_SUCCESS is returned.  If the compressed source data\r
   specified by Source is not in a valid compressed data format,\r
   then RETURN_INVALID_PARAMETER is returned.\r
 \r
@@ -829,13 +829,13 @@ UefiTianoDecompress (
   @param  Source      The source buffer containing the compressed data.\r
   @param  Destination The destination buffer to store the decompressed data\r
   @param  Scratch     A temporary scratch buffer that is used to perform the decompression.\r
-                      This is an optional parameter that may be NULL if the \r
+                      This is an optional parameter that may be NULL if the\r
                       required scratch buffer size is 0.\r
 \r
-  @retval  RETURN_SUCCESS Decompression completed successfully, and \r
+  @retval  RETURN_SUCCESS Decompression completed successfully, and\r
                           the uncompressed buffer is returned in Destination.\r
-  @retval  RETURN_INVALID_PARAMETER \r
-                          The source buffer specified by Source is corrupted \r
+  @retval  RETURN_INVALID_PARAMETER\r
+                          The source buffer specified by Source is corrupted\r
                           (not in a valid compressed format).\r
 **/\r
 RETURN_STATUS\r
@@ -853,16 +853,16 @@ UefiDecompress (
   Examines a GUIDed section and returns the size of the decoded buffer and the\r
   size of an optional scratch buffer required to actually decode the data in a GUIDed section.\r
 \r
-  Examines a GUIDed section specified by InputSection.  \r
+  Examines a GUIDed section specified by InputSection.\r
   If GUID for InputSection does not match the GUID that this handler supports,\r
-  then RETURN_UNSUPPORTED is returned.  \r
+  then RETURN_UNSUPPORTED is returned.\r
   If the required information can not be retrieved from InputSection,\r
   then RETURN_INVALID_PARAMETER is returned.\r
   If the GUID of InputSection does match the GUID that this handler supports,\r
   then the size required to hold the decoded buffer is returned in OututBufferSize,\r
   the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
   from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
-  \r
+\r
   If InputSection is NULL, then ASSERT().\r
   If OutputBufferSize is NULL, then ASSERT().\r
   If ScratchBufferSize is NULL, then ASSERT().\r
@@ -905,7 +905,7 @@ TianoDecompressGetInfo (
       return RETURN_INVALID_PARAMETER;\r
     }\r
     //\r
-    // Get guid attribute of guid section. \r
+    // Get guid attribute of guid section.\r
     //\r
     *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
 \r
@@ -925,7 +925,7 @@ TianoDecompressGetInfo (
       return RETURN_INVALID_PARAMETER;\r
     }\r
     //\r
-    // Get guid attribute of guid section. \r
+    // Get guid attribute of guid section.\r
     //\r
     *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
 \r
@@ -943,16 +943,16 @@ TianoDecompressGetInfo (
 \r
 /**\r
   Decompress a Tiano compressed GUIDed section into a caller allocated output buffer.\r
-  \r
-  Decodes the GUIDed section specified by InputSection.  \r
-  If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.  \r
+\r
+  Decodes the GUIDed section specified by InputSection.\r
+  If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.\r
   If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
   If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
   is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
   decode operation is returned in AuthenticationStatus.  If the decoded buffer is identical to the\r
   data in InputSection, then OutputBuffer is set to point at the data in InputSection.  Otherwise,\r
   the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
-  \r
+\r
   If InputSection is NULL, then ASSERT().\r
   If OutputBuffer is NULL, then ASSERT().\r
   If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
@@ -960,10 +960,10 @@ TianoDecompressGetInfo (
 \r
 \r
   @param[in]  InputSection  A pointer to a GUIDed section of an FFS formatted file.\r
-  @param[out] OutputBuffer  A pointer to a buffer that contains the result of a decode operation. \r
+  @param[out] OutputBuffer  A pointer to a buffer that contains the result of a decode operation.\r
   @param[in] ScratchBuffer  A caller allocated buffer that may be required by this function\r
-                            as a scratch buffer to perform the decode operation. \r
-  @param[out] AuthenticationStatus \r
+                            as a scratch buffer to perform the decode operation.\r
+  @param[out] AuthenticationStatus\r
                             A pointer to the authentication status of the decoded output buffer.\r
                             See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
                             section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r