3 Coreboot interface to memory-saving variant of LZMA decoder
4 (C)opyright 2006 Carl-Daniel Hailfinger
5 Released under the GNU GPL
9 #include "lzmadecode.c"
12 static unsigned long ulzma(unsigned char * src, unsigned char * dst)
14 unsigned char properties[LZMA_PROPERTIES_SIZE];
19 CLzmaDecoderState state;
21 unsigned char scratchpad[15980];
23 memcpy(properties, src, LZMA_PROPERTIES_SIZE);
24 outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
25 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
26 printk_warning("Incorrect stream properties\n");
28 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
29 if (mallocneeds > 15980) {
30 printk_warning("Decoder scratchpad too small!\n");
32 state.Probs = (CProb *)scratchpad;
33 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
34 dst, outSize, &outProcessed);
36 printk_warning("Decoding error = %d\n", res);