blob: 42746e1029da806736cebd18874021c5580d8e0f [file] [log] [blame]
Carl-Daniel Hailfingercba07dd2006-09-14 15:12:36 +00001/*
2
3LinuxBIOS interface to memory-saving variant of LZMA decoder
4(C)opyright 2006 Carl-Daniel Hailfinger
5Released under the GNU GPL
6
7*/
8
9#include "lzmadecode.c"
10
11
12static unsigned long ulzma(unsigned char * src, unsigned char * dst)
13{
14 unsigned char properties[LZMA_PROPERTIES_SIZE];
15 UInt32 outSize;
16 SizeT inProcessed;
17 SizeT outProcessed;
18 int res;
19 CLzmaDecoderState state;
20 SizeT mallocneeds;
21 unsigned char scratchpad[15980];
22
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");
27 }
28 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
29 if (mallocneeds > 15980) {
30 printk_warning("Decoder scratchpad too small!\n");
31 }
32 state.Probs = (CProb *)scratchpad;
33 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
34 dst, outSize, &outProcessed);
35 if (res != 0) {
36 printk_warning("Decoding error = %d\n", res);
37 }
38 return outSize;
39}