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>
17 unsigned long ulzma(unsigned char * src, unsigned char * dst);
19 unsigned long ulzma(unsigned char * src, unsigned char * dst)
21 unsigned char properties[LZMA_PROPERTIES_SIZE];
26 CLzmaDecoderState state;
28 unsigned char scratchpad[15980];
30 memcpy(properties, src, LZMA_PROPERTIES_SIZE);
31 outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
32 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
33 printk_warning("lzma: Incorrect stream properties.\n");
36 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
37 if (mallocneeds > 15980) {
38 printk_warning("lzma: Decoder scratchpad too small!\n");
41 state.Probs = (CProb *)scratchpad;
42 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
43 dst, outSize, &outProcessed);
45 printk_warning("lzma: Decoding error = %d\n", res);