BaseUefiTianoCustomDecompressLibInternals.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Internal data structure and interfaces defintions for UEFI and Tiano Decompress Libary.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiPei.h>
#include <Guid/TianoDecompress.h>
#include <Library/UefiDecompressLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/ExtractGuidedSectionLib.h>
//
// Decompression algorithm begins here
//
#define BITBUFSIZ 32
#define MAXMATCH 256
#define THRESHOLD 3
#define CODE_BIT 16
#define BAD_TABLE - 1
//
// C: Char&Len Set; P: Position Set; T: exTra Set
//
#define CBIT 9
#define MAXPBIT 5
#define TBIT 5
#else
#endif
typedef struct {
///
/// The length of the field 'Position Set Code Length Array Size' in Block Header.
/// For UEFI 2.0 de/compression algorithm, mPBit = 4
/// For Tiano de/compression algorithm, mPBit = 5
///
} SCRATCH_DATA;
/**
Read NumOfBit of bits from source into mBitBuf.
Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
@param Sd The global scratch data
@param NumOfBits The number of bits to shift and read.
**/
FillBuf (
);
/**
Get NumOfBits of bits out from mBitBuf.
Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
NumOfBits of bits from source. Returns NumOfBits of bits that are
popped out.
@param Sd The global scratch data.
@param NumOfBits The number of bits to pop and read.
@return The bits that are popped out.
**/
GetBits (
);
/**
Creates Huffman Code mapping table according to code length array.
Creates Huffman Code mapping table for Extra Set, Char&Len Set
and Position Set according to code length array.
@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 Table The table to be created.
@retval 0 OK.
@retval BAD_TABLE The table is corrupted.
**/
);
/**
Decodes a position value.
Get a position value according to Position Huffman Table.
@param Sd the global scratch data
@return The position value decoded.
**/
DecodeP (
);
/**
Reads code lengths for the Extra Set or the Position Set.
Read in the Extra Set or Pointion Set Length Arrary, 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 Special The special symbol that needs to be taken care of.
@retval 0 OK.
@retval BAD_TABLE Table is corrupted.
**/
);
/**
Reads code lengths for Char&Len Set.
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
**/
ReadCLen (
);
/**
Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
Huffman code mapping table for Extra Set, Code&Len Set and
Position Set.
@param Sd The global scratch data.
@return The value decoded.
**/
DecodeC (
);
/**
Decode the source data and put the resulting data into the destination buffer.
@param Sd The global scratch data
**/
Decode (
);
#endif