TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseUefiDecompressLibInternals.h File Reference
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiDecompressLib.h>

Go to the source code of this file.

Data Structures

struct  SCRATCH_DATA
 

Macros

#define BITBUFSIZ   32
 
#define MAXMATCH   256
 
#define THRESHOLD   3
 
#define CODE_BIT   16
 
#define BAD_TABLE   - 1
 
#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)
 
#define NPT   MAXNP
 

Functions

VOID FillBuf (IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
 
UINT32 GetBits (IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
 
UINT16 MakeTable (IN SCRATCH_DATA *Sd, IN UINT16 NumOfChar, IN UINT8 *BitLen, IN UINT16 TableBits, OUT UINT16 *Table)
 
UINT32 DecodeP (IN SCRATCH_DATA *Sd)
 
UINT16 ReadPTLen (IN SCRATCH_DATA *Sd, IN UINT16 nn, IN UINT16 nbit, IN UINT16 Special)
 
VOID ReadCLen (SCRATCH_DATA *Sd)
 
UINT16 DecodeC (SCRATCH_DATA *Sd)
 
VOID Decode (SCRATCH_DATA *Sd)
 
RETURN_STATUS UefiTianoDecompress (IN CONST VOID *Source, IN OUT VOID *Destination, IN OUT VOID *Scratch, IN UINT32 Version)
 

Detailed Description

Internal data structure defintions for Base UEFI Decompress Library.

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file BaseUefiDecompressLibInternals.h.

Macro Definition Documentation

◆ BAD_TABLE

#define BAD_TABLE   - 1

Definition at line 24 of file BaseUefiDecompressLibInternals.h.

◆ BITBUFSIZ

#define BITBUFSIZ   32

Definition at line 20 of file BaseUefiDecompressLibInternals.h.

◆ CBIT

#define CBIT   9

Definition at line 30 of file BaseUefiDecompressLibInternals.h.

◆ CODE_BIT

#define CODE_BIT   16

Definition at line 23 of file BaseUefiDecompressLibInternals.h.

◆ MAXMATCH

#define MAXMATCH   256

Definition at line 21 of file BaseUefiDecompressLibInternals.h.

◆ MAXNP

#define MAXNP   ((1U << MAXPBIT) - 1)

Definition at line 33 of file BaseUefiDecompressLibInternals.h.

◆ MAXPBIT

#define MAXPBIT   5

Definition at line 31 of file BaseUefiDecompressLibInternals.h.

◆ NC

#define NC   (0xff + MAXMATCH + 2 - THRESHOLD)

Definition at line 29 of file BaseUefiDecompressLibInternals.h.

◆ NPT

#define NPT   MAXNP

Definition at line 38 of file BaseUefiDecompressLibInternals.h.

◆ NT

#define NT   (CODE_BIT + 3)

Definition at line 34 of file BaseUefiDecompressLibInternals.h.

◆ TBIT

#define TBIT   5

Definition at line 32 of file BaseUefiDecompressLibInternals.h.

◆ THRESHOLD

#define THRESHOLD   3

Definition at line 22 of file BaseUefiDecompressLibInternals.h.

Function Documentation

◆ Decode()

VOID Decode ( SCRATCH_DATA Sd)

Decode the source data and put the resulting data into the destination buffer.

Parameters
SdThe global scratch data.

Definition at line 555 of file BaseUefiDecompressLib.c.

◆ DecodeC()

UINT16 DecodeC ( 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.

Parameters
SdThe global scratch data.
Returns
The value decoded.

Definition at line 481 of file BaseUefiDecompressLib.c.

◆ DecodeP()

UINT32 DecodeP ( IN SCRATCH_DATA Sd)

Decodes a position value.

Get a position value according to Position Huffman Table.

Parameters
SdThe global scratch data.
Returns
The position value decoded.

Definition at line 262 of file BaseUefiDecompressLib.c.

◆ FillBuf()

VOID FillBuf ( IN SCRATCH_DATA Sd,
IN UINT16  NumOfBits 
)

Read NumOfBit of bits from source into mBitBuf.

Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.

Parameters
SdThe global scratch data.
NumOfBitsThe number of bits to shift and read.

Definition at line 22 of file BaseUefiDecompressLib.c.

◆ GetBits()

UINT32 GetBits ( 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.

Parameters
SdThe global scratch data.
NumOfBitsThe number of bits to pop and read.
Returns
The bits that are popped out.

Definition at line 80 of file BaseUefiDecompressLib.c.

◆ MakeTable()

UINT16 MakeTable ( IN SCRATCH_DATA Sd,
IN UINT16  NumOfChar,
IN UINT8 *  BitLen,
IN UINT16  TableBits,
OUT UINT16 *  Table 
)

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. If TableBits > 16, then ASSERT ().

Parameters
SdThe global scratch data.
NumOfCharThe number of symbols in the symbol set.
BitLenCode length array.
TableBitsThe width of the mapping table.
TableThe table to be created.
Return values
0OK.
BAD_TABLEThe table is corrupted.

Definition at line 118 of file BaseUefiDecompressLib.c.

◆ ReadCLen()

VOID ReadCLen ( SCRATCH_DATA Sd)

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.

Parameters
SdThe global scratch data.

Definition at line 399 of file BaseUefiDecompressLib.c.

◆ ReadPTLen()

UINT16 ReadPTLen ( IN SCRATCH_DATA Sd,
IN UINT16  nn,
IN UINT16  nbit,
IN UINT16  Special 
)

Reads code lengths for the Extra Set or the Position Set.

Read in the Extra Set or Position Set Length Array, then generate the Huffman code mapping for them.

Parameters
SdThe global scratch data.
nnThe number of symbols.
nbitThe number of bits needed to represent nn.
SpecialThe special symbol that needs to be taken care of.
Return values
0OK.
BAD_TABLETable is corrupted.

Definition at line 315 of file BaseUefiDecompressLib.c.

◆ UefiTianoDecompress()

RETURN_STATUS UefiTianoDecompress ( IN CONST VOID *  Source,
IN OUT VOID *  Destination,
IN OUT VOID *  Scratch,
IN UINT32  Version 
)

Decompresses a compressed source buffer.

Extracts decompressed data to its original form. This function is designed so that the decompression algorithm can be implemented without using any memory services. As a result, this function is not allowed to call any memory allocation services in its implementation. It is the caller's responsibility to allocate and free the Destination and Scratch buffers. If the compressed source data specified by Source is successfully decompressed into Destination, then RETURN_SUCCESS is returned. If the compressed source data specified by Source is not in a valid compressed data format, then RETURN_INVALID_PARAMETER is returned.

If Source is NULL, then ASSERT(). If Destination is NULL, then ASSERT(). If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().

Parameters
SourceThe source buffer containing the compressed data.
DestinationThe destination buffer to store the decompressed data.
ScratchA 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.
Version1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm.
Return values
RETURN_SUCCESSDecompression completed successfully, and the uncompressed buffer is returned in Destination.
RETURN_INVALID_PARAMETERThe source buffer specified by Source is corrupted (not in a valid compressed format).

Decompresses a compressed source buffer.

Extracts decompressed data to its original form. This function is designed so that the decompression algorithm can be implemented without using any memory services. As a result, this function is not allowed to call any memory allocation services in its implementation. It is the caller's responsibility to allocate and free the Destination and Scratch buffers. If the compressed source data specified by Source is successfully decompressed into Destination, then RETURN_SUCCESS is returned. If the compressed source data specified by Source is not in a valid compressed data format, then RETURN_INVALID_PARAMETER is returned.

If Source is NULL, then ASSERT(). If Destination is NULL, then ASSERT(). If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT(). If the Version is not 1 or 2, then ASSERT().

Parameters
SourceThe source buffer containing the compressed data.
DestinationThe destination buffer to store the decompressed data.
ScratchA 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.
Version1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm.
Return values
RETURN_SUCCESSDecompression completed successfully, and the uncompressed buffer is returned in Destination.
RETURN_INVALID_PARAMETERThe source buffer specified by Source is corrupted (not in a valid compressed format).

Definition at line 738 of file BaseUefiDecompressLib.c.