]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
Add some function/header comments.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
index d3d99eac2c0f2549ee393e9517c738111e973be8..93b7c110bc3b23fe671a3b3b4ec9f88bd2920baa 100644 (file)
@@ -1,5 +1,8 @@
 /**@file\r
   UEFI and Custom Decompress Library \r
+  The function of UefiTianoDecompress() is interface for this module,\r
+  it will do tiano or uefi decompress with different verison parameter.\r
+  See EFI specification 1.1 Chapter 17 to get LZ77 compress/decompress.\r
   \r
 Copyright (c) 2006, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
@@ -15,25 +18,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/CustomDecompress.h>\r
 #include "BaseUefiTianoCustomDecompressLibInternals.h"\r
 \r
+/**\r
+  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
+  \r
+  @param Sd         The global scratch data\r
+  @param NumOfBits  The number of bits to shift and read.  \r
+**/\r
 VOID\r
 FillBuf (\r
   IN  SCRATCH_DATA  *Sd,\r
   IN  UINT16        NumOfBits\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfBits  - The number of bits to shift and read.\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
 {\r
   Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
 \r
@@ -64,29 +59,24 @@ Returns: (VOID)
   Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
 }\r
 \r
-UINT32\r
-GetBits (\r
-  IN  SCRATCH_DATA  *Sd,\r
-  IN  UINT16        NumOfBits\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\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
   popped out.\r
 \r
-Arguments:\r
+  @param  Sd        The global scratch data.\r
+  @param  NumOfBits The number of bits to pop and read.\r
 \r
-  Sd            - The global scratch data.\r
-  NumOfBits     - The number of bits to pop and read.\r
+  @return The bits that are popped out.\r
 \r
-Returns:\r
-\r
-  The bits that are popped out.\r
-\r
---*/\r
+**/\r
+UINT32\r
+GetBits (\r
+  IN  SCRATCH_DATA  *Sd,\r
+  IN  UINT16        NumOfBits\r
+  )\r
 {\r
   UINT32  OutBits;\r
 \r
@@ -97,6 +87,22 @@ Returns:
   return OutBits;\r
 }\r
 \r
+/**\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
+  and Position Set according to code length array.\r
+\r
+  @param  Sd        The global scratch data\r
+  @param  NumOfChar Number of symbols in the symbol set\r
+  @param  BitLen    Code length array\r
+  @param  TableBits The width of the mapping table\r
+  @param  Table     The table\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE The table is corrupted.\r
+\r
+**/\r
 UINT16\r
 MakeTable (\r
   IN  SCRATCH_DATA  *Sd,\r
@@ -105,26 +111,6 @@ MakeTable (
   IN  UINT16        TableBits,\r
   OUT UINT16        *Table\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Creates Huffman Code mapping table according to code length array.\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  NumOfChar - Number of symbols in the symbol set\r
-  BitLen    - Code length array\r
-  TableBits - The width of the mapping table\r
-  Table     - The table\r
-  \r
-Returns:\r
-  \r
-  0         - OK.\r
-  BAD_TABLE - The table is corrupted.\r
-\r
---*/\r
 {\r
   UINT16  Count[17];\r
   UINT16  Weight[17];\r
@@ -235,25 +221,17 @@ Returns:
   return 0;\r
 }\r
 \r
+/**\r
+  Decodes a position value.\r
+  \r
+  @param Sd      the global scratch data\r
+  \r
+  @return The position value decoded.\r
+**/\r
 UINT32\r
 DecodeP (\r
   IN  SCRATCH_DATA  *Sd\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decodes a position value.\r
-\r
-Arguments:\r
-\r
-  Sd      - the global scratch data\r
-\r
-Returns:\r
-\r
-  The position value decoded.\r
-\r
---*/\r
 {\r
   UINT16  Val;\r
   UINT32  Mask;\r
@@ -288,6 +266,21 @@ Returns:
   return Pos;\r
 }\r
 \r
+/**\r
+  Reads code lengths for the Extra Set or the Position Set.\r
+\r
+  Read in the Extra Set or Pointion Set Length Arrary, then\r
+  generate the Huffman code mapping for them.\r
+\r
+  @param  Sd      The global scratch data.\r
+  @param  nn      Number of symbols.\r
+  @param  nbit    Number of bits needed to represent nn.\r
+  @param  Special The special symbol that needs to be taken care of.\r
+\r
+  @retval  0 OK.\r
+  @retval  BAD_TABLE Table is corrupted.\r
+\r
+**/\r
 UINT16\r
 ReadPTLen (\r
   IN  SCRATCH_DATA  *Sd,\r
@@ -295,25 +288,6 @@ ReadPTLen (
   IN  UINT16        nbit,\r
   IN  UINT16        Special\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for the Extra Set or the Position Set\r
-\r
-Arguments:\r
-\r
-  Sd        - The global scratch data\r
-  nn        - Number of symbols\r
-  nbit      - Number of bits needed to represent nn\r
-  Special   - The special symbol that needs to be taken care of \r
-\r
-Returns:\r
-\r
-  0         - OK.\r
-  BAD_TABLE - Table is corrupted.\r
-\r
---*/\r
 {\r
   UINT16  Number;\r
   UINT16  CharC;\r
@@ -369,23 +343,19 @@ Returns:
   return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
 }\r
 \r
+/**\r
+  Reads code lengths for Char&Len Set.\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
+  @param  Sd the global scratch data\r
+\r
+**/\r
 VOID\r
 ReadCLen (\r
   SCRATCH_DATA  *Sd\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads code lengths for Char&Len Set.\r
-\r
-Arguments:\r
-\r
-  Sd    - the global scratch data\r
-\r
-Returns: (VOID)\r
-\r
---*/\r
 {\r
   UINT16  Number;\r
   UINT16  CharC;\r
@@ -462,25 +432,22 @@ Returns: (VOID)
   return ;\r
 }\r
 \r
-UINT16\r
-DecodeC (\r
-  SCRATCH_DATA  *Sd\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Decode a character/length value.\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
 \r
-Arguments:\r
-\r
-  Sd    - The global scratch data.\r
-\r
-Returns:\r
+  @param  Sd The global scratch data.\r
 \r
-  The value decoded.\r
+  @return The value decoded.\r
 \r
---*/\r
+**/\r
+UINT16\r
+DecodeC (\r
+  SCRATCH_DATA  *Sd\r
+  )\r
 {\r
   UINT16  Index2;\r
   UINT32  Mask;\r
@@ -527,23 +494,15 @@ Returns:
   return Index2;\r
 }\r
 \r
+/**\r
+  Decode the source data ad put the resulting data into the destination buffer.\r
+  \r
+  @param Sd            - The global scratch data\r
+**/\r
 VOID\r
 Decode (\r
   SCRATCH_DATA  *Sd\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Decode the source data and put the resulting data into the destination buffer.\r
-\r
-Arguments:\r
-\r
-  Sd            - The global scratch data\r
-\r
-Returns: (VOID)\r
-\r
- --*/\r
 {\r
   UINT16  BytesRemain;\r
   UINT32  DataIdx;\r
@@ -595,6 +554,17 @@ Done:
   return ;\r
 }\r
 \r
+/**\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
+  \r
+  @param Source           The source buffer containing the compressed data.\r
+  @param SourceSize       The size of source buffer\r
+  @param DestinationSize  The size of destination buffer.\r
+  @param ScratchSize      The size of scratch buffer.\r
+\r
+  @retval RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  @retval RETURN_INVALID_PARAMETER - The source data is corrupted\r
+**/\r
 RETURN_STATUS\r
 EFIAPI\r
 UefiDecompressGetInfo (\r
@@ -603,25 +573,6 @@ UefiDecompressGetInfo (
   OUT UINT32      *DestinationSize,\r
   OUT UINT32      *ScratchSize\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
-\r
-Arguments:\r
-\r
-  Source          - The source buffer containing the compressed data.\r
-  SourceSize      - The size of source buffer\r
-  DestinationSize - The size of destination buffer.\r
-  ScratchSize     - The size of scratch buffer.\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  RETURN_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
 {\r
   UINT32  CompressedSize;\r
 \r
@@ -644,6 +595,17 @@ Returns:
   return RETURN_SUCCESS;\r
 }\r
 \r
+/**\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
+\r
+  @param Source           The source buffer containing the compressed data.\r
+  @param Destination      The destination buffer to store the decompressed data\r
+  @param Scratch          The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  @param Version          1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm\r
+\r
+  @retval RETURN_SUCCESS            Decompression is successfull\r
+  @retval RETURN_INVALID_PARAMETER  The source data is corrupted\r
+**/\r
 RETURN_STATUS\r
 EFIAPI\r
 UefiTianoDecompress (\r
@@ -652,25 +614,6 @@ UefiTianoDecompress (
   IN OUT VOID    *Scratch,\r
   IN UINT32      Version\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  Source          - The source buffer containing the compressed data.\r
-  Destination     - The destination buffer to store the decompressed data\r
-  Scratch         - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-  Version         - 1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS           - Decompression is successfull\r
-  RETURN_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
 {\r
   volatile UINT32  Index;\r
   UINT32           CompSize;\r
@@ -743,6 +686,16 @@ Returns:
   return RETURN_SUCCESS;\r
 }\r
 \r
+/**\r
+  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
+  \r
+  @param Source          - The source buffer containing the compressed data.\r
+  @param Destination     - The destination buffer to store the decompressed data\r
+  @param Scratch         - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+\r
+  @retval RETURN_SUCCESS           - Decompression is successfull\r
+  @retval RETURN_INVALID_PARAMETER - The source data is corrupted  \r
+**/\r
 RETURN_STATUS\r
 EFIAPI\r
 UefiDecompress (\r
@@ -750,28 +703,22 @@ UefiDecompress (
   IN OUT VOID    *Destination,\r
   IN OUT VOID    *Scratch\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
-\r
-Arguments:\r
-\r
-  Source          - The source buffer containing the compressed data.\r
-  Destination     - The destination buffer to store the decompressed data\r
-  Scratch         - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS           - Decompression is successfull\r
-  RETURN_INVALID_PARAMETER - The source data is corrupted\r
-\r
---*/\r
 {\r
   return UefiTianoDecompress (Source, Destination, Scratch, 1);\r
 }\r
 \r
+/**\r
+  The internal implementation of Tiano decompress GetInfo.\r
+\r
+  @param InputSection          Buffer containing the input GUIDed section to be processed. \r
+  @param OutputBufferSize      The size of OutputBuffer.\r
+  @param ScratchBufferSize     The size of ScratchBuffer.\r
+  @param SectionAttribute      The attribute of the input guided section.\r
+\r
+  @retval RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
+  @retval RETURN_INVALID_PARAMETER - The source data is corrupted\r
+                             The GUID in InputSection does not match this instance guid.\r
+**/\r
 RETURN_STATUS\r
 EFIAPI\r
 TianoDecompressGetInfo (\r
@@ -780,25 +727,7 @@ TianoDecompressGetInfo (
   OUT UINT32      *ScratchBufferSize,\r
   OUT UINT16      *SectionAttribute\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The internal implementation of Tiano decompress GetInfo.\r
-\r
-Arguments:\r
-  InputSection          Buffer containing the input GUIDed section to be processed. \r
-  OutputBufferSize      The size of OutputBuffer.\r
-  ScratchBufferSize     The size of ScratchBuffer.\r
-  SectionAttribute      The attribute of the input guided section.\r
-\r
-Returns:\r
 \r
-  RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
-  RETURN_INVALID_PARAMETER - The source data is corrupted\r
-                             The GUID in InputSection does not match this instance guid.\r
-\r
---*/\r
 {\r
   ASSERT (SectionAttribute != NULL);\r
 \r
@@ -827,6 +756,22 @@ Returns:
          );\r
 }\r
 \r
+/**\r
+  The implementation of Tiano Decompress().\r
+\r
+  @param InputSection           Buffer containing the input GUIDed section to be processed. \r
+  @param OutputBuffer           OutputBuffer to point to the start of the section's contents.\r
+                                if guided data is not prcessed. Otherwise,\r
+                                OutputBuffer to contain the output data, which is allocated by the caller.\r
+  @param ScratchBuffer          A pointer to a caller-allocated buffer for function internal use. \r
+  @param AuthenticationStatus   A pointer to a caller-allocated UINT32 that indicates the\r
+                                authentication status of the output buffer. \r
+\r
+  @retval RETURN_SUCCESS            Decompression is successfull\r
+  @retval RETURN_INVALID_PARAMETER  The source data is corrupted, or\r
+                                    The GUID in InputSection does not match this instance guid.\r
+\r
+--*/\r
 RETURN_STATUS\r
 EFIAPI\r
 TianoDecompress (\r
@@ -835,28 +780,6 @@ TianoDecompress (
   IN        VOID    *ScratchBuffer,        OPTIONAL\r
   OUT       UINT32  *AuthenticationStatus\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The implementation of Tiano Decompress().\r
-\r
-Arguments:\r
-  InputSection           Buffer containing the input GUIDed section to be processed. \r
-  OutputBuffer           OutputBuffer to point to the start of the section's contents.\r
-                         if guided data is not prcessed. Otherwise,\r
-                         OutputBuffer to contain the output data, which is allocated by the caller.\r
-  ScratchBuffer          A pointer to a caller-allocated buffer for function internal use. \r
-  AuthenticationStatus   A pointer to a caller-allocated UINT32 that indicates the\r
-                         authentication status of the output buffer. 
-\r
-Returns:\r
-\r
-  RETURN_SUCCESS           - Decompression is successfull\r
-  RETURN_INVALID_PARAMETER - The source data is corrupted, or\r
-                             The GUID in InputSection does not match this instance guid.\r
-\r
---*/\r
 {\r
   ASSERT (OutputBuffer != NULL);\r
 \r
@@ -886,11 +809,11 @@ Returns:
          );\r
 }\r
 \r
-/**
+/**\r
   Register TianoDecompress handler.\r
-
+\r
   @retval  RETURN_SUCCESS            Register successfully.\r
-  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to store this handler.
+  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to store this handler.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r