2 * coreboot interface to memory-saving variant of LZMA decoder
4 * Copyright (C) 2006 Carl-Daniel Hailfinger
5 * Released under the BSD license
7 * Parts of this file are based on C/7zip/Compress/LZMA_C/LzmaTest.c from the LZMA
8 * SDK 4.42, which is written and distributed to public domain by Igor Pavlov.
15 #include "lzmadecode.c"
17 unsigned long ulzma(unsigned char * src, unsigned char * dst)
19 unsigned char properties[LZMA_PROPERTIES_SIZE];
24 CLzmaDecoderState state;
26 unsigned char scratchpad[15980];
28 memcpy(properties, src, LZMA_PROPERTIES_SIZE);
29 outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
30 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
31 printf("lzma: Incorrect stream properties.\n");
34 mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
35 if (mallocneeds > 15980) {
36 printf("lzma: Decoder scratchpad too small!\n");
39 state.Probs = (CProb *)scratchpad;
40 res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
41 dst, outSize, &outProcessed);
43 printf("lzma: Decoding error = %d\n", res);