add WATCHDOG_RESET to allow LZMA kernel decompression on slow machines

Signed-off-by: rhabarber1848@web.de
This commit is contained in:
rhabarber1848@web.de 2009-07-24 08:16:30 +02:00 committed by Wolfgang Denk
parent 3c972849f2
commit fafbb2c3e4
2 changed files with 30 additions and 0 deletions

View file

@ -1,6 +1,9 @@
/* LzmaDec.c -- LZMA Decoder /* LzmaDec.c -- LZMA Decoder
2008-11-06 : Igor Pavlov : Public domain */ 2008-11-06 : Igor Pavlov : Public domain */
#include <config.h>
#include <common.h>
#include <watchdog.h>
#include "LzmaDec.h" #include "LzmaDec.h"
#include <string.h> #include <string.h>
@ -156,6 +159,8 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
UInt32 range = p->range; UInt32 range = p->range;
UInt32 code = p->code; UInt32 code = p->code;
WATCHDOG_RESET();
do do
{ {
CLzmaProb *prob; CLzmaProb *prob;
@ -176,6 +181,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
if (state < kNumLitStates) if (state < kNumLitStates)
{ {
symbol = 1; symbol = 1;
WATCHDOG_RESET();
do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
} }
else else
@ -183,6 +191,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned offs = 0x100; unsigned offs = 0x100;
symbol = 1; symbol = 1;
WATCHDOG_RESET();
do do
{ {
unsigned bit; unsigned bit;
@ -316,6 +327,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
{ {
UInt32 mask = 1; UInt32 mask = 1;
unsigned i = 1; unsigned i = 1;
WATCHDOG_RESET();
do do
{ {
GET_BIT2(prob + i, i, ; , distance |= mask); GET_BIT2(prob + i, i, ; , distance |= mask);
@ -327,6 +341,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
else else
{ {
numDirectBits -= kNumAlignBits; numDirectBits -= kNumAlignBits;
WATCHDOG_RESET();
do do
{ {
NORMALIZE NORMALIZE
@ -399,12 +416,18 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
const Byte *lim = dest + curLen; const Byte *lim = dest + curLen;
dicPos += curLen; dicPos += curLen;
WATCHDOG_RESET();
do do
*(dest) = (Byte)*(dest + src); *(dest) = (Byte)*(dest + src);
while (++dest != lim); while (++dest != lim);
} }
else else
{ {
WATCHDOG_RESET();
do do
{ {
dic[dicPos++] = dic[pos]; dic[dicPos++] = dic[pos];
@ -417,6 +440,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
} }
} }
while (dicPos < limit && buf < bufLimit); while (dicPos < limit && buf < bufLimit);
WATCHDOG_RESET();
NORMALIZE; NORMALIZE;
p->buf = buf; p->buf = buf;
p->range = range; p->range = range;

View file

@ -36,6 +36,7 @@
#include <config.h> #include <config.h>
#include <common.h> #include <common.h>
#include <watchdog.h>
#ifdef CONFIG_LZMA #ifdef CONFIG_LZMA
@ -112,6 +113,9 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
/* Decompress */ /* Decompress */
outProcessed = outSizeFull; outProcessed = outSizeFull;
WATCHDOG_RESET();
res = LzmaDecode( res = LzmaDecode(
outStream, &outProcessed, outStream, &outProcessed,
inStream + LZMA_DATA_OFFSET, &compressedSize, inStream + LZMA_DATA_OFFSET, &compressedSize,