3 Coreboot interface to memory-saving variant of LZMA decoder
5 (C)opyright 2006 Carl-Daniel Hailfinger
6 Released under the GNU GPL v2 or later
8 Parts of this file are based on C/7zip/Compress/LZMA_C/LzmaTest.c from the LZMA
9 SDK 4.42, which is written and distributed to public domain by Igor Pavlov.
13 #include "lzmadecode.c"
14 #include <console/console.h>
18 unsigned long ulzma(unsigned char * src, unsigned char * dst)
20 unsigned char properties[LZMA_PROPERTIES_SIZE];
25 CLzmaDecoderState state;
27 unsigned char scratchpad[15980];
29 memcpy(properties, src, LZMA_PROPERTIES_SIZE);
30 outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
31 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
32 printk(BIOS_WARNING, "lzma: Incorrect stream properties.\n");
35 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
36 if (mallocneeds > 15980) {
37 printk(BIOS_WARNING, "lzma: Decoder scratchpad too small!\n");
40 state.Probs = (CProb *)scratchpad;
41 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
42 dst, outSize, &outProcessed);
44 printk(BIOS_WARNING, "lzma: Decoding error = %d\n", res);