/** @file\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2004 - 2008, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
Module Name:\r
- \r
+\r
Decompress.c\r
\r
Abstract:\r
\r
- Decompressor. Algorithm Ported from OPSD code (Decomp.asm) \r
+ Decompressor. Algorithm Ported from OPSD code (Decomp.asm)\r
for Efi and Tiano compress algorithm.\r
- \r
+\r
--*/\r
\r
#include "Decompress.h"\r
} SCRATCH_DATA;\r
\r
STATIC UINT16 mPbit = EFIPBIT;\r
- \r
+\r
STATIC\r
VOID\r
FillBuf (\r
\r
Routine Description:\r
\r
- Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
- NumOfBits of bits from source. Returns NumOfBits of bits that are \r
+ Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent\r
+ NumOfBits of bits from source. Returns NumOfBits of bits that are\r
popped out.\r
\r
Arguments:\r
BitLen - Code length array\r
TableBits - The width of the mapping table\r
Table - The table\r
- \r
+\r
Returns:\r
- \r
+\r
0 - OK.\r
BAD_TABLE - The table is corrupted.\r
\r
Sd - The global scratch data\r
nn - Number of symbols\r
nbit - Number of bits needed to represent nn\r
- Special - The special symbol that needs to be taken care of \r
+ Special - The special symbol that needs to be taken care of\r
\r
Returns:\r
\r
mPbit = MAXPBIT;\r
return Decompress (Source, SrcSize, Destination, DstSize, Scratch, ScratchSize);\r
}\r
+\r
+EFI_STATUS\r
+Extract (\r
+ IN VOID *Source,\r
+ IN UINT32 SrcSize,\r
+ OUT VOID **Destination,\r
+ OUT UINT32 *DstSize,\r
+ IN UINTN Algorithm\r
+ )\r
+{\r
+ VOID *Scratch;\r
+ UINT32 ScratchSize;\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+ switch (Algorithm) {\r
+ case 0:\r
+ *Destination = (VOID *)malloc(SrcSize);\r
+ if (*Destination != NULL) {\r
+ memcpy(*Destination, Source, SrcSize);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
+ break;\r
+ case 1:\r
+ Status = EfiGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
+ if (Status == EFI_SUCCESS) {\r
+ Scratch = (VOID *)malloc(ScratchSize);\r
+ *Destination = (VOID *)malloc(*DstSize);\r
+ if (Scratch != NULL && *Destination != NULL) {\r
+ Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ break;\r
+ case 2:\r
+ Status = TianoGetInfo(Source, SrcSize, DstSize, &ScratchSize);\r
+ if (Status == EFI_SUCCESS) {\r
+ Scratch = (VOID *)malloc(ScratchSize);\r
+ *Destination = (VOID *)malloc(*DstSize);\r
+ if (Scratch != NULL && *Destination != NULL) {\r
+ Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);\r
+ } else {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+ break;\r
+ default:\r
+ Status = EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r