2 Internal include file for Tiano Decompress Libary.
\r
4 Copyright (c) 2006, Intel Corporation
\r
5 All rights reserved. This program and the accompanying materials
\r
6 are licensed and made available under the terms and conditions of the BSD License
\r
7 which accompanies this distribution. The full text of the license may be found at
\r
8 http://opensource.org/licenses/bsd-license.php
\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
13 Module Name: TianoDecompress.h
\r
17 #ifndef __TIANO_DECOMPRESS_H__
\r
18 #define __TIANO_DECOMPRESS_H__
\r
22 #include <Common/UefiBaseTypes.h>
\r
26 // Decompression algorithm begins here
\r
28 #define UTILITY_NAME "TianoCompress"
\r
29 #define UTILITY_MAJOR_VERSION 0
\r
30 #define UTILITY_MINOR_VERSION 1
\r
33 // Default output file name
\r
35 #define DEFAULT_OUTPUT_FILE "file.tmp"
\r
37 #define BITBUFSIZ 32
\r
38 #define MAXMATCH 256
\r
41 #define BAD_TABLE - 1
\r
46 // C: Char&Len Set; P: Position Set; T: exTra Set
\r
48 #define NC (0xff + MAXMATCH + 2 - THRESHOLD)
\r
52 #define MAXNP ((1U << MAXPBIT) - 1)
\r
53 #define NT (CODE_BIT + 3)
\r
61 UINT8 *mSrcBase; // Starting address of compressed data
\r
62 UINT8 *mDstBase; // Starting address of decompressed data
\r
73 UINT16 mBadTableFlag;
\r
75 UINT16 mLeft[2 * NC - 1];
\r
76 UINT16 mRight[2 * NC - 1];
\r
79 UINT16 mCTable[4096];
\r
80 UINT16 mPTTable[256];
\r
83 // The length of the field 'Position Set Code Length Array Size' in Block Header.
\r
84 // For EFI 1.1 de/compression algorithm, mPBit = 4
\r
85 // For Tiano de/compression algorithm, mPBit = 5
\r
91 // Function Prototypes
\r
96 IN char *InputFileName,
\r
97 OUT UINT8 *FileBuffer,
\r
98 OUT UINT32 *BufferLength
\r
244 OUT UINT8 *Pointer,
\r
284 IN UINT16 FreqParm[],
\r
285 OUT UINT8 LenParm[ ],
\r
286 OUT UINT16 CodeParm[]
\r
290 Read NumOfBit of bits from source into mBitBuf
\r
292 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
\r
294 @param Sd The global scratch data
\r
295 @param NumOfBits The number of bits to shift and read.
\r
300 IN SCRATCH_DATA *Sd,
\r
301 IN UINT16 NumOfBits
\r
305 Get NumOfBits of bits out from mBitBuf
\r
307 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
\r
308 NumOfBits of bits from source. Returns NumOfBits of bits that are
\r
311 @param Sd The global scratch data.
\r
312 @param NumOfBits The number of bits to pop and read.
\r
314 @return The bits that are popped out.
\r
319 IN SCRATCH_DATA *Sd,
\r
320 IN UINT16 NumOfBits
\r
324 Creates Huffman Code mapping table according to code length array.
\r
326 Creates Huffman Code mapping table for Extra Set, Char&Len Set
\r
327 and Position Set according to code length array.
\r
329 @param Sd The global scratch data
\r
330 @param NumOfChar Number of symbols in the symbol set
\r
331 @param BitLen Code length array
\r
332 @param TableBits The width of the mapping table
\r
333 @param Table The table
\r
336 @retval BAD_TABLE The table is corrupted.
\r
341 IN SCRATCH_DATA *Sd,
\r
342 IN UINT16 NumOfChar,
\r
344 IN UINT16 TableBits,
\r
349 Decodes a position value.
\r
351 Get a position value according to Position Huffman Table.
\r
353 @param Sd the global scratch data
\r
355 @return The position value decoded.
\r
360 IN SCRATCH_DATA *Sd
\r
364 Reads code lengths for the Extra Set or the Position Set.
\r
366 Read in the Extra Set or Pointion Set Length Arrary, then
\r
367 generate the Huffman code mapping for them.
\r
369 @param Sd The global scratch data.
\r
370 @param nn Number of symbols.
\r
371 @param nbit Number of bits needed to represent nn.
\r
372 @param Special The special symbol that needs to be taken care of.
\r
375 @retval BAD_TABLE Table is corrupted.
\r
380 IN SCRATCH_DATA *Sd,
\r
387 Reads code lengths for Char&Len Set.
\r
389 Read in and decode the Char&Len Set Code Length Array, then
\r
390 generate the Huffman Code mapping table for the Char&Len Set.
\r
392 @param Sd the global scratch data
\r
401 Decode a character/length value.
\r
403 Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
\r
404 Huffman code mapping table for Extra Set, Code&Len Set and
\r
407 @param Sd The global scratch data.
\r
409 @return The value decoded.
\r
418 Decode the source data and put the resulting data into the destination buffer.
\r
420 Decode the source data and put the resulting data into the destination buffer.
\r
422 @param Sd The global scratch data
\r
434 IN OUT VOID *Destination,
\r
435 IN OUT VOID *Scratch,
\r