From 6198dc82710083e63844a2c0401a7b11548acaa2 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Fri, 23 May 2008 19:56:50 +0000 Subject: [PATCH] Print current and wanted LZMA scratchpad size in the decompression routine. That allows people to either adjust compression parameters or scratchpad size. Having a similar check during build time would be nice. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Myles Watson git-svn-id: svn://coreboot.org/repository/coreboot-v3@684 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- lib/lzma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/lzma.c b/lib/lzma.c index ec0d00e766..f37ba1724d 100644 --- a/lib/lzma.c +++ b/lib/lzma.c @@ -14,6 +14,7 @@ SDK 4.42, which is written and distributed to public domain by Igor Pavlov. #include "string.h" #include "console.h" +#define LZMA_SCRATCHPAD_SIZE 15980 unsigned long ulzma(u8 *src, u8 *dst) { @@ -24,7 +25,7 @@ unsigned long ulzma(u8 *src, u8 *dst) int res; CLzmaDecoderState state; SizeT mallocneeds; - unsigned char scratchpad[15980]; + unsigned char scratchpad[LZMA_SCRATCHPAD_SIZE]; memcpy(properties, src, LZMA_PROPERTIES_SIZE); outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE); @@ -32,8 +33,9 @@ unsigned long ulzma(u8 *src, u8 *dst) printk(BIOS_WARNING, "Incorrect stream properties\n"); } mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); - if (mallocneeds > 15980) { - printk(BIOS_WARNING, "Decoder scratchpad too small!\n"); + if (mallocneeds > LZMA_SCRATCHPAD_SIZE) { + printk(BIOS_WARNING,("Decoder scratchpad too small, have %i, need %i!\n", + LZMA_SCRATCHPAD_SIZE, mallocneeds); } state.Probs = (CProb *)scratchpad; res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,