mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
Backport decompression updates from new_engine
This commit is contained in:
parent
b3f7beb236
commit
f507d71ead
@ -43,9 +43,9 @@ RShiftU64 (
|
||||
}
|
||||
|
||||
VOID
|
||||
SetEncodedSizeOfBuf (
|
||||
SetEncodedSizeOfBuf(
|
||||
UINT64 EncodedSize,
|
||||
UINT8 *EncodedData
|
||||
UINT8* EncodedData
|
||||
)
|
||||
{
|
||||
INT32 Index;
|
||||
@ -58,13 +58,13 @@ SetEncodedSizeOfBuf (
|
||||
}
|
||||
}
|
||||
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaCompress(
|
||||
LzmaCompress (
|
||||
CONST UINT8 *Source,
|
||||
UINTN SourceSize,
|
||||
UINT32 SourceSize,
|
||||
UINT8 *Destination,
|
||||
UINTN *DestinationSize
|
||||
UINT32 *DestinationSize
|
||||
)
|
||||
{
|
||||
SRes LzmaResult;
|
||||
@ -72,13 +72,14 @@ LzmaCompress(
|
||||
SizeT propsSize = LZMA_PROPS_SIZE;
|
||||
SizeT destLen = SourceSize + SourceSize / 3 + 128;
|
||||
|
||||
if (*DestinationSize < destLen)
|
||||
if (*DestinationSize < (UINT32)destLen)
|
||||
{
|
||||
*DestinationSize = (UINTN)destLen;
|
||||
return ERR_BUFFER_TOO_SMALL;
|
||||
*DestinationSize = (UINT32)destLen;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
LzmaEncProps_Init(&props);
|
||||
// TODO: need to detect this instead of hardcoding
|
||||
props.dictSize = LZMA_DICTIONARY_SIZE;
|
||||
props.level = 9;
|
||||
props.fb = 273;
|
||||
@ -87,7 +88,7 @@ LzmaCompress(
|
||||
(Byte*)((UINT8*)Destination + LZMA_HEADER_SIZE),
|
||||
&destLen,
|
||||
Source,
|
||||
SourceSize,
|
||||
(SizeT)SourceSize,
|
||||
&props,
|
||||
(UINT8*)Destination,
|
||||
&propsSize,
|
||||
@ -96,14 +97,14 @@ LzmaCompress(
|
||||
&SzAllocForLzma,
|
||||
&SzAllocForLzma);
|
||||
|
||||
*DestinationSize = destLen + LZMA_HEADER_SIZE;
|
||||
*DestinationSize = (UINT32)(destLen + LZMA_HEADER_SIZE);
|
||||
|
||||
SetEncodedSizeOfBuf(SourceSize, Destination);
|
||||
|
||||
if (LzmaResult == SZ_OK) {
|
||||
return ERR_SUCCESS;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __LZMACOMPRESS_H__
|
||||
#define __LZMACOMPRESS_H__
|
||||
#ifndef LZMACOMPRESS_H
|
||||
#define LZMACOMPRESS_H
|
||||
|
||||
#include "SDK/C/Types.h"
|
||||
#include "../basetypes.h"
|
||||
@ -24,16 +24,17 @@ extern "C" {
|
||||
#define LZMA_DICTIONARY_SIZE 0x800000
|
||||
#define _LZMA_SIZE_OPT
|
||||
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaCompress(
|
||||
LzmaCompress (
|
||||
const UINT8 *Source,
|
||||
UINTN SourceSize,
|
||||
UINT32 SourceSize,
|
||||
UINT8 *Destination,
|
||||
UINTN *DestinationSize
|
||||
UINT32 *DestinationSize
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // LZMACOMPRESS_H
|
||||
|
@ -19,10 +19,10 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
LShiftU64(
|
||||
LShiftU64 (
|
||||
UINT64 Operand,
|
||||
UINT32 Count
|
||||
)
|
||||
)
|
||||
{
|
||||
return Operand << Count;
|
||||
}
|
||||
@ -39,9 +39,9 @@ Get the size of the uncompressed buffer by parsing EncodeData header.
|
||||
@return The size of the uncompressed buffer.
|
||||
*/
|
||||
UINT64
|
||||
GetDecodedSizeOfBuf(
|
||||
GetDecodedSizeOfBuf (
|
||||
UINT8 *EncodedData
|
||||
)
|
||||
)
|
||||
{
|
||||
UINT64 DecodedSize;
|
||||
INT32 Index;
|
||||
@ -85,18 +85,27 @@ DestinationSize and the size of the scratch
|
||||
buffer was returned ScratchSize.
|
||||
|
||||
*/
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaGetInfo(
|
||||
LzmaGetInfo (
|
||||
CONST VOID *Source,
|
||||
UINTN SourceSize,
|
||||
UINTN *DestinationSize
|
||||
)
|
||||
UINT32 SourceSize,
|
||||
UINT32 *DestinationSize
|
||||
)
|
||||
{
|
||||
ASSERT(SourceSize >= LZMA_HEADER_SIZE); (void)SourceSize;
|
||||
UINT64 DecodedSize;
|
||||
ASSERT(SourceSize >= LZMA_HEADER_SIZE);
|
||||
(void)SourceSize;
|
||||
|
||||
*DestinationSize = (UINTN)GetDecodedSizeOfBuf((UINT8*)Source);
|
||||
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
|
||||
|
||||
if (DecodedSize <= UINT32_MAX) {
|
||||
*DestinationSize = (UINT32)DecodedSize;
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return ERR_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -118,13 +127,13 @@ the uncompressed buffer is returned Destination.
|
||||
The source buffer specified by Source is corrupted
|
||||
(not a valid compressed format).
|
||||
*/
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaDecompress(
|
||||
LzmaDecompress (
|
||||
CONST VOID *Source,
|
||||
UINTN SourceSize,
|
||||
UINT32 SourceSize,
|
||||
VOID *Destination
|
||||
)
|
||||
)
|
||||
{
|
||||
SRes LzmaResult;
|
||||
ELzmaStatus Status;
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __LZMADECOMPRESS_H__
|
||||
#define __LZMADECOMPRESS_H__
|
||||
#ifndef LZMADECOMPRESS_H
|
||||
#define LZMADECOMPRESS_H
|
||||
|
||||
#include "../basetypes.h"
|
||||
#include "SDK/C/LzmaDec.h"
|
||||
@ -23,13 +23,6 @@ extern "C" {
|
||||
|
||||
#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
LShiftU64(
|
||||
UINT64 Operand,
|
||||
UINT32 Count
|
||||
);
|
||||
|
||||
/*
|
||||
Given a Lzma compressed source buffer, this function retrieves the size of
|
||||
the uncompressed buffer and the size of the scratch buffer required
|
||||
@ -57,12 +50,12 @@ extern "C" {
|
||||
buffer was returned ScratchSize.
|
||||
|
||||
*/
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaGetInfo(
|
||||
const VOID *Source,
|
||||
UINTN SourceSize,
|
||||
UINTN *DestinationSize
|
||||
LzmaGetInfo (
|
||||
CONST VOID *Source,
|
||||
UINT32 SourceSize,
|
||||
UINT32 *DestinationSize
|
||||
);
|
||||
|
||||
/*
|
||||
@ -84,15 +77,16 @@ extern "C" {
|
||||
The source buffer specified by Source is corrupted
|
||||
(not a valid compressed format).
|
||||
*/
|
||||
INT32
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LzmaDecompress(
|
||||
const VOID *Source,
|
||||
UINTN SourceSize,
|
||||
LzmaDecompress (
|
||||
CONST VOID *Source,
|
||||
UINT32 SourceSize,
|
||||
VOID *Destination
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // LZMADECOMPRESS_H
|
||||
|
@ -52,9 +52,9 @@ UINT8 gPBIT = 4;
|
||||
#define NT (CODE_BIT + 3)
|
||||
#define TBIT 5
|
||||
#if NT > NP
|
||||
#define NPT NT
|
||||
#define NPT NT
|
||||
#else
|
||||
#define NPT NP
|
||||
#define NPT NP
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -65,160 +65,160 @@ STATIC
|
||||
VOID
|
||||
PutDword(
|
||||
IN UINT32 Data
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
AllocateMemory(VOID);
|
||||
AllocateMemory (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
FreeMemory(VOID);
|
||||
FreeMemory (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InitSlide(VOID);
|
||||
InitSlide (VOID);
|
||||
|
||||
STATIC
|
||||
NODE
|
||||
Child(
|
||||
Child (
|
||||
IN NODE q,
|
||||
IN UINT8 c
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeChild(
|
||||
MakeChild (
|
||||
IN NODE q,
|
||||
IN UINT8 c,
|
||||
IN NODE r
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
Split(
|
||||
Split (
|
||||
IN NODE Old
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InsertNode(VOID);
|
||||
InsertNode (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
DeleteNode(VOID);
|
||||
DeleteNode (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
GetNextMatch(VOID);
|
||||
GetNextMatch (VOID);
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
Encode(VOID);
|
||||
Encode (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
CountTFreq(VOID);
|
||||
CountTFreq (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
WritePTLen(
|
||||
WritePTLen (
|
||||
IN INT32 n,
|
||||
IN INT32 nbit,
|
||||
IN INT32 Special
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
WriteCLen(VOID);
|
||||
WriteCLen (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EncodeC(
|
||||
EncodeC (
|
||||
IN INT32 c
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EncodeP(
|
||||
EncodeP (
|
||||
IN UINT32 p
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
SendBlock(VOID);
|
||||
SendBlock (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
Output(
|
||||
Output (
|
||||
IN UINT32 c,
|
||||
IN UINT32 p
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
HufEncodeStart(VOID);
|
||||
HufEncodeStart (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
HufEncodeEnd(VOID);
|
||||
HufEncodeEnd (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeCrcTable(VOID);
|
||||
MakeCrcTable (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PutBits(
|
||||
PutBits (
|
||||
IN INT32 n,
|
||||
IN UINT32 x
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
INT32
|
||||
FreadCrc(
|
||||
FreadCrc (
|
||||
OUT UINT8 *p,
|
||||
IN INT32 n
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InitPutBits(VOID);
|
||||
InitPutBits (VOID);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
CountLen(
|
||||
CountLen (
|
||||
IN INT32 i
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeLen(
|
||||
MakeLen (
|
||||
IN INT32 Root
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
DownHeap(
|
||||
DownHeap (
|
||||
IN INT32 i
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeCode(
|
||||
MakeCode (
|
||||
IN INT32 n,
|
||||
IN UINT8 Len[],
|
||||
OUT UINT16 Code[]
|
||||
);
|
||||
);
|
||||
|
||||
STATIC
|
||||
INT32
|
||||
MakeTree(
|
||||
MakeTree (
|
||||
IN INT32 NParm,
|
||||
IN UINT16 FreqParm[],
|
||||
OUT UINT8 LenParm[],
|
||||
OUT UINT16 CodeParm[]
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
@ -234,8 +234,8 @@ STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;
|
||||
STATIC UINT32 mCompSize, mOrigSize;
|
||||
|
||||
STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1],
|
||||
mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCCode[NC],
|
||||
mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
|
||||
mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1],mCCode[NC],
|
||||
mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
|
||||
|
||||
STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;
|
||||
|
||||
@ -245,12 +245,12 @@ STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NU
|
||||
//
|
||||
|
||||
EFI_STATUS
|
||||
EfiCompress(
|
||||
EfiCompress (
|
||||
IN CONST VOID *SrcBuffer,
|
||||
IN UINT32 SrcSize,
|
||||
IN VOID *DstBuffer,
|
||||
IN OUT UINT32 *DstSize
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -297,7 +297,7 @@ Returns:
|
||||
PutDword(0L);
|
||||
PutDword(0L);
|
||||
|
||||
MakeCrcTable();
|
||||
MakeCrcTable ();
|
||||
|
||||
mOrigSize = mCompSize = 0;
|
||||
mCrc = INIT_CRC;
|
||||
@ -307,7 +307,7 @@ Returns:
|
||||
//
|
||||
|
||||
Status = Encode();
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ Returns:
|
||||
// Fill in compressed size and original size
|
||||
//
|
||||
mDst = DstBuffer;
|
||||
PutDword(mCompSize + 1);
|
||||
PutDword(mCompSize+1);
|
||||
PutDword(mOrigSize);
|
||||
|
||||
//
|
||||
@ -332,8 +332,7 @@ Returns:
|
||||
if (mCompSize + 1 + 8 > *DstSize) {
|
||||
*DstSize = mCompSize + 1 + 8;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
*DstSize = mCompSize + 1 + 8;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -342,10 +341,10 @@ Returns:
|
||||
|
||||
EFI_STATUS
|
||||
TianoCompress(
|
||||
IN CONST VOID *SrcBuffer,
|
||||
IN UINT32 SrcSize,
|
||||
IN VOID *DstBuffer,
|
||||
IN OUT UINT32 *DstSize
|
||||
IN CONST VOID *SrcBuffer,
|
||||
IN UINT32 SrcSize,
|
||||
IN VOID *DstBuffer,
|
||||
IN OUT UINT32 *DstSize
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -440,7 +439,7 @@ STATIC
|
||||
VOID
|
||||
PutDword(
|
||||
IN UINT32 Data
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -456,7 +455,7 @@ Returns: (VOID)
|
||||
--*/
|
||||
{
|
||||
if (mDst < mDstUpperLimit) {
|
||||
*mDst++ = (UINT8)(((UINT8)(Data)) & 0xff);
|
||||
*mDst++ = (UINT8)(((UINT8)(Data )) & 0xff);
|
||||
}
|
||||
|
||||
if (mDst < mDstUpperLimit) {
|
||||
@ -474,7 +473,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
AllocateMemory()
|
||||
AllocateMemory ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -492,20 +491,24 @@ Returns:
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
mText = malloc(WNDSIZ * 2 + MAXMATCH);
|
||||
if (NULL == mText)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
for (i = 0; i < WNDSIZ * 2 + MAXMATCH; i++) {
|
||||
mText = malloc (WNDSIZ * 2 + MAXMATCH);
|
||||
if (!mText) return EFI_OUT_OF_RESOURCES;
|
||||
for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {
|
||||
mText[i] = 0;
|
||||
}
|
||||
|
||||
mLevel = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mLevel));
|
||||
if (!mLevel) return EFI_OUT_OF_RESOURCES;
|
||||
mChildCount = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mChildCount));
|
||||
if (!mChildCount) return EFI_OUT_OF_RESOURCES;
|
||||
mPosition = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mPosition));
|
||||
if (!mPosition) return EFI_OUT_OF_RESOURCES;
|
||||
mParent = malloc(WNDSIZ * 2 * sizeof(*mParent));
|
||||
if (!mParent) return EFI_OUT_OF_RESOURCES;
|
||||
mPrev = malloc(WNDSIZ * 2 * sizeof(*mPrev));
|
||||
if (!mPrev) return EFI_OUT_OF_RESOURCES;
|
||||
mNext = malloc((MAX_HASH_VAL + 1) * sizeof(*mNext));
|
||||
if (!mNext) return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
mBufSiz = 16 * 1024U;
|
||||
while ((mBuf = malloc(mBufSiz)) == NULL) {
|
||||
@ -520,7 +523,7 @@ Returns:
|
||||
}
|
||||
|
||||
VOID
|
||||
FreeMemory()
|
||||
FreeMemory ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -534,35 +537,35 @@ Returns: (VOID)
|
||||
--*/
|
||||
{
|
||||
if (mText) {
|
||||
free(mText);
|
||||
free (mText);
|
||||
}
|
||||
|
||||
if (mLevel) {
|
||||
free(mLevel);
|
||||
free (mLevel);
|
||||
}
|
||||
|
||||
if (mChildCount) {
|
||||
free(mChildCount);
|
||||
free (mChildCount);
|
||||
}
|
||||
|
||||
if (mPosition) {
|
||||
free(mPosition);
|
||||
free (mPosition);
|
||||
}
|
||||
|
||||
if (mParent) {
|
||||
free(mParent);
|
||||
free (mParent);
|
||||
}
|
||||
|
||||
if (mPrev) {
|
||||
free(mPrev);
|
||||
free (mPrev);
|
||||
}
|
||||
|
||||
if (mNext) {
|
||||
free(mNext);
|
||||
free (mNext);
|
||||
}
|
||||
|
||||
if (mBuf) {
|
||||
free(mBuf);
|
||||
free (mBuf);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -571,7 +574,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InitSlide()
|
||||
InitSlide ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -607,10 +610,10 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
NODE
|
||||
Child(
|
||||
Child (
|
||||
IN NODE q,
|
||||
IN UINT8 c
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -641,11 +644,11 @@ Returns:
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeChild(
|
||||
MakeChild (
|
||||
IN NODE q,
|
||||
IN UINT8 c,
|
||||
IN NODE r
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -677,8 +680,8 @@ Returns: (VOID)
|
||||
STATIC
|
||||
VOID
|
||||
Split (
|
||||
IN NODE Old
|
||||
)
|
||||
NODE Old
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -713,7 +716,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InsertNode()
|
||||
InsertNode ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -755,8 +758,7 @@ Returns: (VOID)
|
||||
if (t < (NODE)WNDSIZ) {
|
||||
mPosition[t] = (NODE)(mPos | PERC_FLAG);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
//
|
||||
// Locate the target tree
|
||||
@ -778,12 +780,11 @@ Returns: (VOID)
|
||||
// Node split or creation is involved.
|
||||
//
|
||||
|
||||
for (; ; ) {
|
||||
for ( ; ; ) {
|
||||
if (r >= (NODE)WNDSIZ) {
|
||||
j = MAXMATCH;
|
||||
mMatchPos = r;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
j = mLevel[r];
|
||||
mMatchPos = (NODE)(mPosition[r] & ~PERC_FLAG);
|
||||
}
|
||||
@ -830,7 +831,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
DeleteNode()
|
||||
DeleteNode ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -904,7 +905,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
GetNextMatch()
|
||||
GetNextMatch ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -933,7 +934,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
Encode()
|
||||
Encode ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -987,8 +988,7 @@ Returns:
|
||||
//
|
||||
|
||||
Output(mText[mPos - 1], 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
//
|
||||
// Outputting a pointer is beneficial enough, do it.
|
||||
@ -1012,7 +1012,7 @@ Returns:
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
CountTFreq()
|
||||
CountTFreq ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1045,19 +1045,15 @@ Returns: (VOID)
|
||||
}
|
||||
if (Count <= 2) {
|
||||
mTFreq[0] = (UINT16)(mTFreq[0] + Count);
|
||||
}
|
||||
else if (Count <= 18) {
|
||||
} else if (Count <= 18) {
|
||||
mTFreq[1]++;
|
||||
}
|
||||
else if (Count == 19) {
|
||||
} else if (Count == 19) {
|
||||
mTFreq[0]++;
|
||||
mTFreq[1]++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mTFreq[2]++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mTFreq[k + 2]++;
|
||||
}
|
||||
}
|
||||
@ -1065,11 +1061,11 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
WritePTLen(
|
||||
WritePTLen (
|
||||
IN INT32 n,
|
||||
IN INT32 nbit,
|
||||
IN INT32 Special
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1097,8 +1093,7 @@ Returns: (VOID)
|
||||
k = mPTLen[i++];
|
||||
if (k <= 6) {
|
||||
PutBits(3, k);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(k - 3, (1U << (k - 3)) - 2);
|
||||
}
|
||||
if (i == Special) {
|
||||
@ -1112,7 +1107,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
WriteCLen()
|
||||
WriteCLen ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1145,22 +1140,18 @@ Returns: (VOID)
|
||||
for (k = 0; k < Count; k++) {
|
||||
PutBits(mPTLen[0], mPTCode[0]);
|
||||
}
|
||||
}
|
||||
else if (Count <= 18) {
|
||||
} else if (Count <= 18) {
|
||||
PutBits(mPTLen[1], mPTCode[1]);
|
||||
PutBits(4, Count - 3);
|
||||
}
|
||||
else if (Count == 19) {
|
||||
} else if (Count == 19) {
|
||||
PutBits(mPTLen[0], mPTCode[0]);
|
||||
PutBits(mPTLen[1], mPTCode[1]);
|
||||
PutBits(4, 15);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(mPTLen[2], mPTCode[2]);
|
||||
PutBits(CBIT, Count - 20);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(mPTLen[k + 2], mPTCode[k + 2]);
|
||||
}
|
||||
}
|
||||
@ -1168,18 +1159,18 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EncodeC(
|
||||
EncodeC (
|
||||
IN INT32 c
|
||||
)
|
||||
)
|
||||
{
|
||||
PutBits(mCLen[c], mCCode[c]);
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EncodeP(
|
||||
EncodeP (
|
||||
IN UINT32 p
|
||||
)
|
||||
)
|
||||
{
|
||||
UINT32 c, q;
|
||||
|
||||
@ -1197,7 +1188,7 @@ EncodeP(
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
SendBlock()
|
||||
SendBlock ()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1221,14 +1212,12 @@ Returns: (VOID)
|
||||
Root = MakeTree(NT, mTFreq, mPTLen, mPTCode);
|
||||
if (Root >= NT) {
|
||||
WritePTLen(NT, TBIT, 3);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(TBIT, 0);
|
||||
PutBits(TBIT, Root);
|
||||
}
|
||||
WriteCLen();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(TBIT, 0);
|
||||
PutBits(TBIT, 0);
|
||||
PutBits(CBIT, 0);
|
||||
@ -1237,8 +1226,7 @@ Returns: (VOID)
|
||||
Root = MakeTree(NP, mPFreq, mPTLen, mPTCode);
|
||||
if (Root >= NP) {
|
||||
WritePTLen(NP, gPBIT, -1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PutBits(gPBIT, 0);
|
||||
PutBits(gPBIT, Root);
|
||||
}
|
||||
@ -1246,8 +1234,7 @@ Returns: (VOID)
|
||||
for (i = 0; i < Size; i++) {
|
||||
if (i % UINT8_BIT == 0) {
|
||||
Flags = mBuf[Pos++];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Flags <<= 1;
|
||||
}
|
||||
if (Flags & (1U << (UINT8_BIT - 1))) {
|
||||
@ -1255,8 +1242,7 @@ Returns: (VOID)
|
||||
k = mBuf[Pos++] << UINT8_BIT;
|
||||
k += mBuf[Pos++];
|
||||
EncodeP(k);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EncodeC(mBuf[Pos++]);
|
||||
}
|
||||
}
|
||||
@ -1271,10 +1257,10 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
Output(
|
||||
Output (
|
||||
IN UINT32 c,
|
||||
IN UINT32 p
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1301,12 +1287,12 @@ Returns: (VOID)
|
||||
CPos = mOutputPos++;
|
||||
mBuf[CPos] = 0;
|
||||
}
|
||||
mBuf[mOutputPos++] = (UINT8)c;
|
||||
mBuf[mOutputPos++] = (UINT8) c;
|
||||
mCFreq[c]++;
|
||||
if (c >= (1U << UINT8_BIT)) {
|
||||
mBuf[CPos] |= mOutputMask;
|
||||
mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT);
|
||||
mBuf[mOutputPos++] = (UINT8)p;
|
||||
mBuf[mOutputPos++] = (UINT8) p;
|
||||
c = 0;
|
||||
while (p) {
|
||||
p >>= 1;
|
||||
@ -1318,7 +1304,7 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
HufEncodeStart()
|
||||
HufEncodeStart ()
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
@ -1335,7 +1321,7 @@ HufEncodeStart()
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
HufEncodeEnd()
|
||||
HufEncodeEnd ()
|
||||
{
|
||||
SendBlock();
|
||||
|
||||
@ -1350,7 +1336,7 @@ HufEncodeEnd()
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeCrcTable()
|
||||
MakeCrcTable ()
|
||||
{
|
||||
UINT32 i, j, r;
|
||||
|
||||
@ -1359,8 +1345,7 @@ MakeCrcTable()
|
||||
for (j = 0; j < UINT8_BIT; j++) {
|
||||
if (r & 1) {
|
||||
r = (r >> 1) ^ CRCPOLY;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
r >>= 1;
|
||||
}
|
||||
}
|
||||
@ -1370,10 +1355,10 @@ MakeCrcTable()
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PutBits(
|
||||
PutBits (
|
||||
IN INT32 n,
|
||||
IN UINT32 x
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1393,8 +1378,7 @@ Returns: (VOID)
|
||||
|
||||
if (n < mBitCount) {
|
||||
mSubBitBuf |= x << (mBitCount -= n);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount)));
|
||||
if (mDst < mDstUpperLimit) {
|
||||
@ -1404,8 +1388,7 @@ Returns: (VOID)
|
||||
|
||||
if (n < UINT8_BIT) {
|
||||
mSubBitBuf = x << (mBitCount = UINT8_BIT - n);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
Temp = (UINT8)(x >> (n - UINT8_BIT));
|
||||
if (mDst < mDstUpperLimit) {
|
||||
@ -1420,10 +1403,10 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
INT32
|
||||
FreadCrc(
|
||||
FreadCrc (
|
||||
OUT UINT8 *p,
|
||||
IN INT32 n
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1459,7 +1442,7 @@ Returns:
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InitPutBits()
|
||||
InitPutBits ()
|
||||
{
|
||||
mBitCount = UINT8_BIT;
|
||||
mSubBitBuf = 0;
|
||||
@ -1467,9 +1450,9 @@ InitPutBits()
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
CountLen(
|
||||
CountLen (
|
||||
IN INT32 i
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1488,10 +1471,9 @@ Returns: (VOID)
|
||||
|
||||
if (i < mN) {
|
||||
mLenCnt[(Depth < 16) ? Depth : 16]++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Depth++;
|
||||
CountLen(mLeft[i]);
|
||||
CountLen(mLeft [i]);
|
||||
CountLen(mRight[i]);
|
||||
Depth--;
|
||||
}
|
||||
@ -1499,9 +1481,9 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeLen(
|
||||
MakeLen (
|
||||
IN INT32 Root
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1536,7 +1518,7 @@ Arguments:
|
||||
for (i = 15; i > 0; i--) {
|
||||
if (mLenCnt[i] != 0) {
|
||||
mLenCnt[i]--;
|
||||
mLenCnt[i + 1] += 2;
|
||||
mLenCnt[i+1] += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1552,9 +1534,9 @@ Arguments:
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
DownHeap(
|
||||
DownHeap (
|
||||
IN INT32 i
|
||||
)
|
||||
)
|
||||
{
|
||||
INT32 j, k;
|
||||
|
||||
@ -1578,11 +1560,11 @@ DownHeap(
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
MakeCode(
|
||||
MakeCode (
|
||||
IN INT32 n,
|
||||
IN UINT8 Len[],
|
||||
OUT UINT16 Code[]
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -1613,12 +1595,12 @@ Returns: (VOID)
|
||||
|
||||
STATIC
|
||||
INT32
|
||||
MakeTree(
|
||||
MakeTree (
|
||||
IN INT32 NParm,
|
||||
IN UINT16 FreqParm[],
|
||||
OUT UINT8 LenParm[],
|
||||
OUT UINT16 CodeParm[]
|
||||
)
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
@ -20,8 +20,8 @@ Header file for compression routine.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _EFITIANOCOMPRESS_H_
|
||||
#define _EFITIANOCOMPRESS_H_
|
||||
#ifndef EFITIANOCOMPRESS_H
|
||||
#define EFITIANOCOMPRESS_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -57,11 +57,12 @@ extern "C" {
|
||||
--*/
|
||||
EFI_STATUS
|
||||
TianoCompress(
|
||||
IN CONST VOID *SrcBuffer,
|
||||
IN UINT32 SrcSize,
|
||||
IN VOID *DstBuffer,
|
||||
IN OUT UINT32 *DstSize
|
||||
);
|
||||
CONST VOID *SrcBuffer,
|
||||
UINT32 SrcSize,
|
||||
VOID *DstBuffer,
|
||||
UINT32 *DstSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
TianoCompressLegacy(
|
||||
@ -69,7 +70,8 @@ extern "C" {
|
||||
UINT32 SrcSize,
|
||||
VOID *DstBuffer,
|
||||
UINT32 *DstSize
|
||||
);
|
||||
)
|
||||
;
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@ -95,21 +97,22 @@ extern "C" {
|
||||
--*/
|
||||
EFI_STATUS
|
||||
EfiCompress(
|
||||
IN CONST VOID *SrcBuffer,
|
||||
IN UINT32 SrcSize,
|
||||
IN VOID *DstBuffer,
|
||||
IN OUT UINT32 *DstSize
|
||||
);
|
||||
|
||||
CONST VOID *SrcBuffer,
|
||||
UINT32 SrcSize,
|
||||
VOID *DstBuffer,
|
||||
UINT32 *DstSize
|
||||
)
|
||||
;
|
||||
EFI_STATUS
|
||||
EfiCompressLegacy(
|
||||
CONST VOID *SrcBuffer,
|
||||
UINT32 SrcSize,
|
||||
VOID *DstBuffer,
|
||||
UINT32 *DstSize
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // EFITIANOCOMPRESS_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -82,8 +82,8 @@ typedef struct {
|
||||
STATIC
|
||||
VOID
|
||||
FillBuf(
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfBits
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfBits
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -130,8 +130,8 @@ Returns: (VOID)
|
||||
STATIC
|
||||
UINT32
|
||||
GetBits(
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfBits
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfBits
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -164,11 +164,11 @@ The bits that are popped out.
|
||||
STATIC
|
||||
UINT16
|
||||
MakeTable(
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfChar,
|
||||
IN UINT8 *BitLen,
|
||||
IN UINT16 TableBits,
|
||||
OUT UINT16 *Table
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 NumOfChar,
|
||||
IN UINT8 *BitLen,
|
||||
IN UINT16 TableBits,
|
||||
OUT UINT16 *Table
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -324,7 +324,7 @@ BAD_TABLE - The table is corrupted.
|
||||
STATIC
|
||||
UINT32
|
||||
DecodeP(
|
||||
IN SCRATCH_DATA *Sd
|
||||
IN SCRATCH_DATA *Sd
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -378,10 +378,10 @@ The position value decoded.
|
||||
STATIC
|
||||
UINT16
|
||||
ReadPTLen(
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 nn,
|
||||
IN UINT16 nbit,
|
||||
IN UINT16 Special
|
||||
IN SCRATCH_DATA *Sd,
|
||||
IN UINT16 nn,
|
||||
IN UINT16 nbit,
|
||||
IN UINT16 Special
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -472,7 +472,7 @@ BAD_TABLE - Table is corrupted.
|
||||
STATIC
|
||||
VOID
|
||||
ReadCLen(
|
||||
SCRATCH_DATA *Sd
|
||||
SCRATCH_DATA *Sd
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -563,7 +563,7 @@ Returns: (VOID)
|
||||
STATIC
|
||||
UINT16
|
||||
DecodeC(
|
||||
SCRATCH_DATA *Sd
|
||||
SCRATCH_DATA *Sd
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -630,7 +630,7 @@ The value decoded.
|
||||
STATIC
|
||||
VOID
|
||||
Decode(
|
||||
SCRATCH_DATA *Sd
|
||||
SCRATCH_DATA *Sd
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -702,10 +702,10 @@ Returns: (VOID)
|
||||
|
||||
EFI_STATUS
|
||||
GetInfo(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
OUT UINT32 *DstSize,
|
||||
OUT UINT32 *ScratchSize
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
OUT UINT32 *DstSize,
|
||||
OUT UINT32 *ScratchSize
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -742,13 +742,13 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
|
||||
EFI_STATUS
|
||||
Decompress(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize,
|
||||
IN UINT8 Version
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize,
|
||||
IN UINT8 Version
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -869,10 +869,10 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiTianoGetInfo(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
OUT UINT32 *DstSize,
|
||||
OUT UINT32 *ScratchSize
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
OUT UINT32 *DstSize,
|
||||
OUT UINT32 *ScratchSize
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -906,12 +906,12 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDecompress(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
)
|
||||
/*++
|
||||
|
||||
@ -953,12 +953,12 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TianoDecompress(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
)
|
||||
/*++
|
||||
|
||||
|
@ -21,8 +21,8 @@ Providing both EFI and Tiano decompress algorithms.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFITIANODECOMPRESS_H_
|
||||
#define _EFITIANODECOMPRESS_H_
|
||||
#ifndef EFITIANODECOMPRESS_H
|
||||
#define EFITIANODECOMPRESS_H
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -32,109 +32,107 @@ Providing both EFI and Tiano decompress algorithms.
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
typedef struct EFI_TIANO_HEADER_ {
|
||||
UINT32 CompSize;
|
||||
UINT32 OrigSize;
|
||||
} EFI_TIANO_HEADER;
|
||||
} EFI_TIANO_HEADER;
|
||||
|
||||
EFI_STATUS
|
||||
EfiTianoGetInfo(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
OUT UINT32 *DstSize,
|
||||
OUT UINT32 *ScratchSize
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiTianoGetInfo(
|
||||
const VOID *Source,
|
||||
UINT32 SrcSize,
|
||||
UINT32 *DstSize,
|
||||
UINT32 *ScratchSize
|
||||
)
|
||||
/*++
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo().
|
||||
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo().
|
||||
|
||||
Arguments:
|
||||
Arguments:
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Returns:
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successfully retrieved.
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successfully retrieved.
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
|
||||
--*/
|
||||
;
|
||||
--*/
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDecompress(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDecompress(
|
||||
const VOID *Source,
|
||||
UINT32 SrcSize,
|
||||
VOID *Destination,
|
||||
UINT32 DstSize,
|
||||
VOID *Scratch,
|
||||
UINT32 ScratchSize
|
||||
);
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().
|
||||
|
||||
Arguments:
|
||||
|
||||
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.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Decompression is successful
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TianoDecompress(
|
||||
const VOID *Source,
|
||||
UINT32 SrcSize,
|
||||
VOID *Destination,
|
||||
UINT32 DstSize,
|
||||
VOID *Scratch,
|
||||
UINT32 ScratchSize
|
||||
)
|
||||
/*++
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Routine Description:
|
||||
|
||||
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().
|
||||
The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
|
||||
|
||||
Arguments:
|
||||
Arguments:
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Returns:
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Decompression is successful
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
EFI_SUCCESS - Decompression is successful
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TianoDecompress(
|
||||
IN const VOID *Source,
|
||||
IN UINT32 SrcSize,
|
||||
IN OUT VOID *Destination,
|
||||
IN UINT32 DstSize,
|
||||
IN OUT VOID *Scratch,
|
||||
IN UINT32 ScratchSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
|
||||
|
||||
Arguments:
|
||||
|
||||
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.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Decompression is successful
|
||||
EFI_INVALID_PARAMETER - The source data is corrupted
|
||||
|
||||
--*/
|
||||
;
|
||||
--*/
|
||||
;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // EFITIANODECOMPRESS_H
|
||||
|
@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef uint8_t BOOLEAN;
|
||||
typedef int8_t INT8;
|
||||
@ -28,7 +29,7 @@ typedef int64_t INT64;
|
||||
typedef uint64_t UINT64;
|
||||
typedef char CHAR8;
|
||||
typedef uint16_t CHAR16;
|
||||
typedef unsigned int UINTN;
|
||||
typedef size_t UINTN;
|
||||
|
||||
#define CONST const
|
||||
#define VOID void
|
||||
|
@ -2741,7 +2741,13 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
|
||||
else if (algorithm)
|
||||
*algorithm = COMPRESSION_ALGORITHM_TIANO;
|
||||
|
||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
||||
if (decompressedSize > INT32_MAX) {
|
||||
delete[] decompressed;
|
||||
delete[] scratch;
|
||||
return ERR_STANDARD_DECOMPRESSION_FAILED;
|
||||
}
|
||||
|
||||
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
|
||||
|
||||
delete[] decompressed;
|
||||
delete[] scratch;
|
||||
@ -2778,7 +2784,8 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
|
||||
}
|
||||
|
||||
// Decompress section data again
|
||||
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
||||
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)
|
||||
|| decompressedSize > INT32_MAX) {
|
||||
if (algorithm)
|
||||
*algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||
delete[] decompressed;
|
||||
@ -2787,13 +2794,17 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
|
||||
else {
|
||||
if (algorithm)
|
||||
*algorithm = COMPRESSION_ALGORITHM_IMLZMA;
|
||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
||||
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (decompressedSize > INT32_MAX) {
|
||||
delete[] decompressed;
|
||||
return ERR_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||
}
|
||||
if (algorithm)
|
||||
*algorithm = COMPRESSION_ALGORITHM_LZMA;
|
||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
||||
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
|
||||
}
|
||||
|
||||
delete[] decompressed;
|
||||
|
Loading…
Reference in New Issue
Block a user