Wolfgang Denk wrote:

> Keep the update of the lzma code and the
> watchdog stuff separated in two patches - and use git-format-patch to
> create and git-send-email to post the patches, please.

Hi,

please forgive me when I am posting the patches again as binary attachments
(hopefully now readable) as I do not use git here.

Both patches are to be used for the LZMA 4.65 update proposed by
Luigi 'Comio' Mantellini.

lzma.diff
fix return size of uncompressed image

watchdog.diff
reset watchdog timer to avoid reboot during decompression on slow machines.

Cheers, rhabarber1848
diff -uNr u-boot-2009.06.org/lib_generic/lzma/LzmaTools.c u-boot-2009.06/lib_generic/lzma/LzmaTools.c
--- u-boot-2009.06.org/lib_generic/lzma/LzmaTools.c	2009-07-17 13:33:06.000000000 +0200
+++ u-boot-2009.06/lib_generic/lzma/LzmaTools.c	2009-07-17 13:34:19.000000000 +0200
@@ -116,6 +117,7 @@
         outStream, &outProcessed,
         inStream + LZMA_DATA_OFFSET, &compressedSize,
         inStream, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &state, &g_Alloc);
+    *uncompressedSize = outProcessed;
     if (res != SZ_OK)  {
         return res;
     }

diff -uNr u-boot-2009.06.org/lib_generic/lzma/LzmaDec.c u-boot-2009.06/lib_generic/lzma/LzmaDec.c
--- u-boot-2009.06.org/lib_generic/lzma/LzmaDec.c	2009-07-17 13:33:06.000000000 +0200
+++ u-boot-2009.06/lib_generic/lzma/LzmaDec.c	2009-07-17 13:33:38.000000000 +0200
@@ -1,6 +1,9 @@
 /* LzmaDec.c -- LZMA Decoder
 2008-11-06 : Igor Pavlov : Public domain */
 
+#include <config.h>
+#include <common.h>
+#include <watchdog.h>
 #include "LzmaDec.h"
 
 #include <string.h>
@@ -156,6 +159,9 @@
   UInt32 range = p->range;
   UInt32 code = p->code;
 
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
   do
   {
     CLzmaProb *prob;
@@ -176,6 +182,9 @@
       if (state < kNumLitStates)
       {
         symbol = 1;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
         do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
       }
       else
@@ -183,6 +192,9 @@
         unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
         unsigned offs = 0x100;
         symbol = 1;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
         do
         {
           unsigned bit;
@@ -316,6 +328,9 @@
             {
               UInt32 mask = 1;
               unsigned i = 1;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
               do
               {
                 GET_BIT2(prob + i, i, ; , distance |= mask);
@@ -327,6 +342,9 @@
           else
           {
             numDirectBits -= kNumAlignBits;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
             do
             {
               NORMALIZE
@@ -399,12 +417,18 @@
           ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
           const Byte *lim = dest + curLen;
           dicPos += curLen;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
           do
             *(dest) = (Byte)*(dest + src);
           while (++dest != lim);
         }
         else
         {
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
           do
           {
             dic[dicPos++] = dic[pos];
@@ -417,6 +441,9 @@
     }
   }
   while (dicPos < limit && buf < bufLimit);
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
   NORMALIZE;
   p->buf = buf;
   p->range = range;
diff -uNr u-boot-2009.06.org/lib_generic/lzma/LzmaTools.c u-boot-2009.06/lib_generic/lzma/LzmaTools.c
--- u-boot-2009.06.org/lib_generic/lzma/LzmaTools.c	2009-07-17 13:33:06.000000000 +0200
+++ u-boot-2009.06/lib_generic/lzma/LzmaTools.c	2009-07-17 13:33:54.000000000 +0200
@@ -36,6 +36,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <watchdog.h>
 
 #ifdef CONFIG_LZMA
 
@@ -112,6 +113,9 @@
 
     /* Decompress */
     outProcessed = outSizeFull;
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+	WATCHDOG_RESET();
+#endif
     res = LzmaDecode(
         outStream, &outProcessed,
         inStream + LZMA_DATA_OFFSET, &compressedSize,

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to