X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseUefiDecompressLib%2FBaseUefiDecompressLib.c;h=e3b2846c0986892526b7916786311064bf73e505;hb=a750b4ae24ce072f7c5ced1b89c18f9cc23debc8;hp=54cba81a14cf65f0699300b30508e32c8729c8f4;hpb=acbcf0425f4fa835d3455df86c6e505b5095cd51;p=mirror_edk2.git diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c index 54cba81a14..e3b2846c09 100644 --- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c +++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -1,12 +1,12 @@ /** @file UEFI Decompress Library implementation refer to UEFI specification. - Copyright (c) 2006 - 2008, Intel Corporation
- Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
- All rights reserved. This program and the accompanying materials + Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+ Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php + http://opensource.org/licenses/bsd-license.php. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. @@ -27,7 +27,7 @@ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. - @param Sd The global scratch data + @param Sd The global scratch data. @param NumOfBits The number of bits to shift and read. **/ @@ -68,7 +68,7 @@ FillBuf ( } // - // Caculate additional bit count read to update mBitCount + // Calculate additional bit count read to update mBitCount // Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); @@ -117,11 +117,12 @@ GetBits ( Creates Huffman Code mapping table for Extra Set, Char&Len Set and Position Set according to code length array. + If TableBits > 16, then ASSERT (). - @param Sd The global scratch data - @param NumOfChar Number of symbols in the symbol set - @param BitLen Code length array - @param TableBits The width of the mapping table + @param Sd The global scratch data. + @param NumOfChar The number of symbols in the symbol set. + @param BitLen Code length array. + @param TableBits The width of the mapping table. @param Table The table to be created. @retval 0 OK. @@ -152,6 +153,11 @@ MakeTable ( UINT16 WordOfStart; UINT16 WordOfCount; + // + // The maximum mapping table width supported by this internal + // working function is 16. + // + ASSERT (TableBits <= 16); for (Index = 0; Index <= 16; Index++) { Count[Index] = 0; @@ -256,7 +262,7 @@ MakeTable ( Get a position value according to Position Huffman Table. - @param Sd the global scratch data + @param Sd The global scratch data. @return The position value decoded. @@ -302,12 +308,12 @@ DecodeP ( /** Reads code lengths for the Extra Set or the Position Set. - Read in the Extra Set or Pointion Set Length Arrary, then + Read in the Extra Set or Position Set Length Array, then generate the Huffman code mapping for them. @param Sd The global scratch data. - @param nn Number of symbols. - @param nbit Number of bits needed to represent nn. + @param nn The number of symbols. + @param nbit The number of bits needed to represent nn. @param Special The special symbol that needs to be taken care of. @retval 0 OK. @@ -327,6 +333,7 @@ ReadPTLen ( UINT16 Index; UINT32 Mask; + ASSERT (nn <= NPT); // // Read Extra Set Code Length Array size // @@ -395,7 +402,7 @@ ReadPTLen ( Read in and decode the Char&Len Set Code Length Array, then generate the Huffman Code mapping table for the Char&Len Set. - @param Sd the global scratch data + @param Sd The global scratch data. **/ VOID @@ -501,7 +508,7 @@ DecodeC ( Sd->mBlockSize = (UINT16) GetBits (Sd, 16); // - // Read in the Extra Set Code Length Arrary, + // Read in the Extra Set Code Length Array, // Generate the Huffman code mapping table for Extra Set. // Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3); @@ -510,13 +517,13 @@ DecodeC ( } // - // Read in and decode the Char&Len Set Code Length Arrary, + // Read in and decode the Char&Len Set Code Length Array, // Generate the Huffman code mapping table for Char&Len Set. // ReadCLen (Sd); // - // Read in the Position Set Code Length Arrary, + // Read in the Position Set Code Length Array, // Generate the Huffman code mapping table for the Position Set. // Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1)); @@ -555,7 +562,7 @@ DecodeC ( /** Decode the source data and put the resulting data into the destination buffer. - @param Sd The global scratch data + @param Sd The global scratch data. **/ VOID @@ -653,13 +660,13 @@ Done: @param SourceSize The size, in bytes, of the source buffer. @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer that will be generated when the compressed buffer specified - by Source and SourceSize is decompressed.. + by Source and SourceSize is decompressed. @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that is required to decompress the compressed buffer specified by Source and SourceSize. @retval RETURN_SUCCESS The size of the uncompressed data was returned - in DestinationSize and the size of the scratch + in DestinationSize, and the size of the scratch buffer was returned in ScratchSize. @retval RETURN_INVALID_PARAMETER The size of the uncompressed data or the size of @@ -715,7 +722,7 @@ UefiDecompressGetInfo ( If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). @param Source The source buffer containing the compressed data. - @param Destination The destination buffer to store the decompressed data + @param Destination The destination buffer to store the decompressed data. @param Scratch A temporary scratch buffer that is used to perform the decompression. This is an optional parameter that may be NULL if the required scratch buffer size is 0. @@ -770,7 +777,7 @@ UefiDecompress ( Sd->mSrcBase = (UINT8 *)Src; Sd->mDstBase = Dst; // - // CompSize and OrigSize are caculated in bytes + // CompSize and OrigSize are calculated in bytes // Sd->mCompSize = CompSize; Sd->mOrigSize = OrigSize;