]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h
846abdb78e580d747fec78cfdf989ca4940a3961
2 Internal data structure and interfaces defintions for UEFI and Tiano Decompress Library.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__
10 #define __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__
14 #include <Guid/TianoDecompress.h>
15 #include <Library/BaseLib.h>
16 #include <Library/UefiDecompressLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/ExtractGuidedSectionLib.h>
22 // Decompression algorithm begins here
31 // C: Char&Len Set; P: Position Set; T: exTra Set
33 #define NC (0xff + MAXMATCH + 2 - THRESHOLD)
37 #define MAXNP ((1U << MAXPBIT) - 1)
38 #define NT (CODE_BIT + 3)
46 UINT8
*mSrcBase
; // Starting address of compressed data
47 UINT8
*mDstBase
; // Starting address of decompressed data
60 UINT16 mLeft
[2 * NC
- 1];
61 UINT16 mRight
[2 * NC
- 1];
68 /// The length of the field 'Position Set Code Length Array Size' in Block Header.
69 /// For UEFI 2.0 de/compression algorithm, mPBit = 4
70 /// For Tiano de/compression algorithm, mPBit = 5
76 Read NumOfBit of bits from source into mBitBuf.
78 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
80 @param Sd The global scratch data
81 @param NumOfBits The number of bits to shift and read.
91 Get NumOfBits of bits out from mBitBuf.
93 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
94 NumOfBits of bits from source. Returns NumOfBits of bits that are
97 @param Sd The global scratch data.
98 @param NumOfBits The number of bits to pop and read.
100 @return The bits that are popped out.
110 Creates Huffman Code mapping table according to code length array.
112 Creates Huffman Code mapping table for Extra Set, Char&Len Set
113 and Position Set according to code length array.
115 @param Sd The global scratch data
116 @param NumOfChar Number of symbols in the symbol set
117 @param BitLen Code length array
118 @param TableBits The width of the mapping table
119 @param Table The table to be created.
122 @retval BAD_TABLE The table is corrupted.
135 Decodes a position value.
137 Get a position value according to Position Huffman Table.
139 @param Sd the global scratch data
141 @return The position value decoded.
150 Reads code lengths for the Extra Set or the Position Set.
152 Read in the Extra Set or Position Set Length Array, then
153 generate the Huffman code mapping for them.
155 @param Sd The global scratch data.
156 @param nn Number of symbols.
157 @param nbit Number of bits needed to represent nn.
158 @param Special The special symbol that needs to be taken care of.
161 @retval BAD_TABLE Table is corrupted.
173 Reads code lengths for Char&Len Set.
175 Read in and decode the Char&Len Set Code Length Array, then
176 generate the Huffman Code mapping table for the Char&Len Set.
178 @param Sd the global scratch data
187 Decode a character/length value.
189 Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
190 Huffman code mapping table for Extra Set, Code&Len Set and
193 @param Sd The global scratch data.
195 @return The value decoded.
204 Decode the source data and put the resulting data into the destination buffer.
206 @param Sd The global scratch data