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"
16 static unsigned long ulzma(unsigned char * src, unsigned char * dst)
18 unsigned char properties[LZMA_PROPERTIES_SIZE];
23 CLzmaDecoderState state;
25 unsigned char scratchpad[15980];
27 memcpy(properties, src, LZMA_PROPERTIES_SIZE);
28 outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
29 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
30 printk_warning("Incorrect stream properties\n");
33 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
34 if (mallocneeds > 15980) {
35 printk_warning("Decoder scratchpad too small!\n");
38 state.Probs = (CProb *)scratchpad;
39 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
40 dst, outSize, &outProcessed);
42 printk_warning("Decoding error = %d\n", res);