summaryrefslogtreecommitdiff
path: root/DuetPkg/EfiLdr/TianoDecompress.h
diff options
context:
space:
mode:
Diffstat (limited to 'DuetPkg/EfiLdr/TianoDecompress.h')
-rw-r--r--DuetPkg/EfiLdr/TianoDecompress.h236
1 files changed, 48 insertions, 188 deletions
diff --git a/DuetPkg/EfiLdr/TianoDecompress.h b/DuetPkg/EfiLdr/TianoDecompress.h
index 54ae620996..dad51ed4a5 100644
--- a/DuetPkg/EfiLdr/TianoDecompress.h
+++ b/DuetPkg/EfiLdr/TianoDecompress.h
@@ -23,208 +23,68 @@
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.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 NC (0xff + MAXMATCH + 2 - THRESHOLD)
-#define CBIT 9
-#define MAXPBIT 5
-#define TBIT 5
-#define MAXNP ((1U << MAXPBIT) - 1)
-#define NT (CODE_BIT + 3)
-#if NT > MAXNP
-#define NPT NT
-#else
-#define NPT MAXNP
-#endif
-
-typedef struct {
- UINT8 *mSrcBase; // Starting address of compressed data
- UINT8 *mDstBase; // Starting address of decompressed data
- UINT32 mOutBuf;
- UINT32 mInBuf;
-
- UINT16 mBitCount;
- UINT32 mBitBuf;
- UINT32 mSubBitBuf;
- UINT16 mBlockSize;
- UINT32 mCompSize;
- UINT32 mOrigSize;
-
- UINT16 mBadTableFlag;
-
- UINT16 mLeft[2 * NC - 1];
- UINT16 mRight[2 * NC - 1];
- UINT8 mCLen[NC];
- UINT8 mPTLen[NPT];
- UINT16 mCTable[4096];
- UINT16 mPTTable[256];
-
- //
- // 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
- //
- UINT8 mPBit;
-} 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.
-
-**/
-VOID
-FillBuf (
- IN SCRATCH_DATA *Sd,
- IN UINT16 NumOfBits
- );
-
-/**
- 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.
-
-**/
-UINT32
-GetBits (
- IN SCRATCH_DATA *Sd,
- IN UINT16 NumOfBits
- );
-
-/**
- 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
-
- @retval 0 OK.
- @retval BAD_TABLE The table is corrupted.
-
-**/
-UINT16
-MakeTable (
- IN SCRATCH_DATA *Sd,
- IN UINT16 NumOfChar,
- IN UINT8 *BitLen,
- IN UINT16 TableBits,
- OUT UINT16 *Table
- );
-
-/**
- Decodes a position value.
-
- Get a position value according to Position Huffman Table.
-
- @param Sd the global scratch data
-
- @return The position value decoded.
+EFI_STATUS
+EFIAPI
+TianoGetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
-**/
-UINT32
-DecodeP (
- IN SCRATCH_DATA *Sd
- );
+Routine Description:
-/**
- Reads code lengths for the Extra Set or the Position Set.
+ The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().
- Read in the Extra Set or Pointion Set Length Arrary, then
- generate the Huffman code mapping for them.
+Arguments:
- @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.
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
- @retval 0 OK.
- @retval BAD_TABLE Table is corrupted.
+Returns:
-**/
-UINT16
-ReadPTLen (
- IN SCRATCH_DATA *Sd,
- IN UINT16 nn,
- IN UINT16 nbit,
- IN UINT16 Special
- );
-
-/**
- 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
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
-**/
-VOID
-ReadCLen (
- SCRATCH_DATA *Sd
- );
+--*/
+;
-/**
- Decode a character/length value.
-
- 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.
+EFI_STATUS
+EFIAPI
+TianoDecompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
- @param Sd The global scratch data.
+Routine Description:
- @return The value decoded.
+ The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
-**/
-UINT16
-DecodeC (
- SCRATCH_DATA *Sd
- );
+Arguments:
-/**
- Decode the source data and put the resulting data into the destination buffer.
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
- Decode the source data and put the resulting data into the destination buffer.
-
- @param Sd The global scratch data
+Returns:
-**/
-VOID
-Decode (
- SCRATCH_DATA *Sd
- );
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
-RETURN_STATUS
-EFIAPI
-UefiTianoDecompress (
- IN CONST VOID *Source,
- IN OUT VOID *Destination,
- IN OUT VOID *Scratch,
- IN UINT32 Version
- );
+--*/
+;
#endif