qoriq: add kernel 6.1 support
[openwrt/openwrt.git] / tools / mtd-utils / patches / 130-lzma_jffs2.patch
index b994b9d698402fbae89d8b10e44ddffa99293c72..db683063d5895024b32c25bdd16f660e083589af 100644 (file)
@@ -1,52 +1,60 @@
---- a/Makefile 
-+++ b/Makefile 
-@@ -1,7 +1,7 @@
+--- a/jffsX-utils/Makemodule.am
++++ b/jffsX-utils/Makemodule.am
+@@ -4,7 +4,10 @@ mkfs_jffs2_SOURCES = \
+       jffsX-utils/compr_zlib.c \
+       jffsX-utils/compr.h \
+       jffsX-utils/rbtree.c \
+-      jffsX-utils/compr_lzo.c \
++      jffsX-utils/compr_lzma.c \
++      jffsX-utils/lzma/LzFind.c \
++      jffsX-utils/lzma/LzmaEnc.c \
++      jffsX-utils/lzma/LzmaDec.c \
+       jffsX-utils/compr.c \
+       jffsX-utils/compr_rtime.c \
+       jffsX-utils/compr.h \
+@@ -12,8 +15,13 @@ mkfs_jffs2_SOURCES = \
+       jffsX-utils/summary.h \
+       include/linux/jffs2.h \
+       include/mtd/jffs2-user.h
++
++if !WITHOUT_LZO
++mkfs_jffs2_SOURCES += jffsX-utils/compr_lzo.c
++endif
++
+ mkfs_jffs2_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS)
+-mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS)
++mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) -I./include/linux/lzma
  
- # -*- sh -*-
--CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
-+CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) -I./include/linux/lzma
- ifeq ($(WITHOUT_XATTR), 1)
-   CPPFLAGS += -DWITHOUT_XATTR
-@@ -45,7 +45,9 @@
-       ln -sf ../fs/jffs2/$@ $@
- $(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
--      crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o $(if $(NO_LZO),,compr_lzo.o) \
-+      crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o \
-+      $(if $(NO_LZO),,compr_lzo.o) \
-+      compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o\
-       compr.o rbtree.o)
- LDFLAGS_mkfs.jffs2 := $(ZLIBLDFLAGS)
---- a/compr.c  2009-06-05 16:59:08.000000000 +0200
-+++ b/compr.c  2010-03-20 23:16:14.556367000 +0100
-@@ -520,6 +520,9 @@
+ jffs2reader_SOURCES = jffsX-utils/jffs2reader.c       include/mtd/jffs2-user.h
+ jffs2reader_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS)
+--- a/jffsX-utils/compr.c
++++ b/jffsX-utils/compr.c
+@@ -520,6 +520,9 @@ int jffs2_compressors_init(void)
  #ifdef CONFIG_JFFS2_LZO
        jffs2_lzo_init();
  #endif
 +#ifdef CONFIG_JFFS2_LZMA
-+        jffs2_lzma_init();
++      jffs2_lzma_init();
 +#endif
        return 0;
  }
  
-@@ -534,5 +537,8 @@
+@@ -534,5 +537,8 @@ int jffs2_compressors_exit(void)
  #ifdef CONFIG_JFFS2_LZO
        jffs2_lzo_exit();
  #endif
 +#ifdef CONFIG_JFFS2_LZMA
-+        jffs2_lzma_exit();
++      jffs2_lzma_exit();
 +#endif
        return 0;
  }
---- a/compr.h  2010-03-20 23:08:46.289595000 +0100
-+++ b/compr.h  2010-03-20 23:51:41.953345921 +0100
-@@ -18,12 +18,14 @@
+--- a/jffsX-utils/compr.h
++++ b/jffsX-utils/compr.h
+@@ -18,13 +18,14 @@
  
  #define CONFIG_JFFS2_ZLIB
  #define CONFIG_JFFS2_RTIME
+-#define CONFIG_JFFS2_LZO
 +#define CONFIG_JFFS2_LZMA
  
  #define JFFS2_RUBINMIPS_PRIORITY 10
@@ -60,7 +68,7 @@
  
  #define JFFS2_COMPR_MODE_NONE       0
  #define JFFS2_COMPR_MODE_PRIORITY   1
-@@ -114,5 +116,10 @@
+@@ -115,5 +116,10 @@ void jffs2_rtime_exit(void);
  int jffs2_lzo_init(void);
  void jffs2_lzo_exit(void);
  #endif
@@ -71,8 +79,8 @@
 +
  
  #endif /* __JFFS2_COMPR_H__ */
---- a/compr_lzma.c     1970-01-01 01:00:00.000000000 +0100
-+++ b/compr_lzma.c     2010-03-20 23:16:15.048654497 +0100
+--- /dev/null
++++ b/jffsX-utils/compr_lzma.c
 @@ -0,0 +1,128 @@
 +/*
 + * JFFS2 -- Journalling Flash File System, Version 2.
 +              return -1;
 +      }
 +
-+        return 0;
++      return 0;
 +}
 +
 +STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out,
-+                            uint32_t *sourcelen, uint32_t *dstlen, void *model)
++                            uint32_t *sourcelen, uint32_t *dstlen)
 +{
 +      SizeT compress_size = (SizeT)(*dstlen);
 +      int ret;
 +}
 +
 +STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out,
-+                               uint32_t srclen, uint32_t destlen, void *model)
++                               uint32_t srclen, uint32_t destlen)
 +{
 +      int ret;
 +      SizeT dl = (SizeT)destlen;
 +
 +int INIT jffs2_lzma_init(void)
 +{
-+        int ret;
++      int ret;
 +      CLzmaEncProps props;
 +      LzmaEncProps_Init(&props);
 +
-+        props.dictSize = LZMA_BEST_DICT(0x2000);
-+        props.level = LZMA_BEST_LEVEL;
-+        props.lc = LZMA_BEST_LC;
-+        props.lp = LZMA_BEST_LP;
-+        props.pb = LZMA_BEST_PB;
-+        props.fb = LZMA_BEST_FB;
++      props.dictSize = LZMA_BEST_DICT(0x2000);
++      props.level = LZMA_BEST_LEVEL;
++      props.lc = LZMA_BEST_LC;
++      props.lp = LZMA_BEST_LP;
++      props.pb = LZMA_BEST_PB;
++      props.fb = LZMA_BEST_FB;
 +
 +      ret = lzma_alloc_workspace(&props);
-+        if (ret < 0)
-+                return ret;
++      if (ret < 0)
++              return ret;
 +
 +      ret = jffs2_register_compressor(&jffs2_lzma_comp);
 +      if (ret)
 +              lzma_free_workspace();
 +      
-+        return ret;
++      return ret;
 +}
 +
 +void jffs2_lzma_exit(void)
 +      jffs2_unregister_compressor(&jffs2_lzma_comp);
 +      lzma_free_workspace();
 +}
---- a/include/linux/jffs2.h    2009-06-05 16:59:08.000000000 +0200
-+++ b/include/linux/jffs2.h    2010-03-20 23:16:15.305246000 +0100
+--- a/include/linux/jffs2.h
++++ b/include/linux/jffs2.h
 @@ -47,6 +47,7 @@
  #define JFFS2_COMPR_DYNRUBIN  0x05
  #define JFFS2_COMPR_ZLIB      0x06
  /* Compatibility flags. */
  #define JFFS2_COMPAT_MASK 0xc000      /* What do to if an unknown nodetype is found */
  #define JFFS2_NODE_ACCURATE 0x2000
---- a/include/linux/lzma.h     1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma.h     2010-03-20 23:16:16.380508712 +0100
-@@ -0,0 +1,62 @@
+--- /dev/null
++++ b/include/linux/lzma.h
+@@ -0,0 +1,61 @@
 +#ifndef __LZMA_H__
 +#define __LZMA_H__
 +
 +      #include <stdio.h>
 +      #include <unistd.h>
 +      #include <string.h>
-+      #include <asm/types.h>
 +      #include <errno.h>
 +      #include <linux/jffs2.h>
 +      #ifndef PAGE_SIZE
 +      #define LZMA_FREE free
 +      #define PRINT_ERROR(msg) fprintf(stderr, msg)
 +      #define INIT
-+      #define STATIC
++      #define STATIC static
 +#endif
 +
 +#include "lzma/LzmaDec.h"
 +
 +static void *p_lzma_malloc(void *p, size_t size)
 +{
-+        if (size == 0)
-+                return NULL;
++      if (size == 0)
++              return NULL;
 +
-+        return LZMA_MALLOC(size);
++      return LZMA_MALLOC(size);
 +}
 +
 +static void p_lzma_free(void *p, void *address)
 +{
-+        if (address != NULL)
-+                LZMA_FREE(address);
++      if (address != NULL)
++              LZMA_FREE(address);
 +}
 +
 +static ISzAlloc lzma_alloc = {p_lzma_malloc, p_lzma_free};
 +
 +#endif
---- a/include/linux/lzma/LzFind.h      1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma/LzFind.h      2010-03-20 23:19:44.189059515 +0100
+--- /dev/null
++++ b/include/linux/lzma/LzFind.h
 @@ -0,0 +1,116 @@
 +/* LzFind.h  -- Match finder for LZ algorithms
 +2008-04-04
 +void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
 +
 +#endif
---- a/include/linux/lzma/LzHash.h      1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma/LzHash.h      2010-03-20 23:19:44.588791287 +0100
+--- /dev/null
++++ b/include/linux/lzma/LzHash.h
 @@ -0,0 +1,56 @@
 +/* LzHash.h  -- HASH functions for LZ algorithms
 +2008-03-26
 +  hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
 +
 +#endif
---- a/include/linux/lzma/LzmaDec.h     1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma/LzmaDec.h     2010-03-20 23:19:43.766328000 +0100
+--- /dev/null
++++ b/include/linux/lzma/LzmaDec.h
 @@ -0,0 +1,232 @@
 +/* LzmaDec.h -- LZMA Decoder
 +2008-04-29
 +    ELzmaStatus *status, ISzAlloc *alloc);
 +
 +#endif
---- a/include/linux/lzma/LzmaEnc.h     1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma/LzmaEnc.h     2010-03-20 23:19:47.392642470 +0100
+--- /dev/null
++++ b/include/linux/lzma/LzmaEnc.h
 @@ -0,0 +1,74 @@
 +/*  LzmaEnc.h -- LZMA Encoder
 +2008-04-27
 +    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
 +
 +#endif
---- a/include/linux/lzma/Types.h       1970-01-01 01:00:00.000000000 +0100
-+++ b/include/linux/lzma/Types.h       2010-03-20 23:19:44.013465852 +0100
+--- /dev/null
++++ b/include/linux/lzma/Types.h
 @@ -0,0 +1,130 @@
 +/* Types.h -- Basic types
 +2008-04-11
 +#define IAlloc_Free(p, a) (p)->Free((p), a)
 +
 +#endif
---- a/lzma/LzFind.c    1970-01-01 01:00:00.000000000 +0100
-+++ b/lzma/LzFind.c    2010-03-20 23:19:47.990406000 +0100
+--- /dev/null
++++ b/jffsX-utils/lzma/LzFind.c
 @@ -0,0 +1,753 @@
 +/* LzFind.c  -- Match finder for LZ algorithms
 +2008-04-04
 +}
 +
 +Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
-+Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
++static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
 +
-+UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
++static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
 +
 +void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
 +{
 +    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
 +  }
 +}
---- a/lzma/LzmaDec.c   1970-01-01 01:00:00.000000000 +0100
-+++ b/lzma/LzmaDec.c   2010-03-20 23:19:44.413562000 +0100
+--- /dev/null
++++ b/jffsX-utils/lzma/LzmaDec.c
 @@ -0,0 +1,1014 @@
 +/* LzmaDec.c -- LZMA Decoder
 +2008-04-29
 +  p->needFlush = 0;
 +}
 +
-+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) 
++static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) 
 +{ 
 +  p->needFlush = 1; 
 +  p->remainLen = 0; 
 +  LzmaDec_FreeProbs(&p, alloc);
 +  return res;
 +}
---- a/lzma/LzmaEnc.c   1970-01-01 01:00:00.000000000 +0100
-+++ b/lzma/LzmaEnc.c   2010-03-20 23:19:47.815156000 +0100
+--- /dev/null
++++ b/jffsX-utils/lzma/LzmaEnc.c
 @@ -0,0 +1,2335 @@
 +/* LzmaEnc.c -- LZMA Encoder
 +2008-04-28
 +#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
 +#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
 +
-+void LzmaEnc_FastPosInit(Byte *g_FastPos)
++static void LzmaEnc_FastPosInit(Byte *g_FastPos)
 +{
 +  int c = 2, slotFast;
 +  g_FastPos[0] = 0;
 +  CSaveState saveState;
 +} CLzmaEnc;
 +
-+void LzmaEnc_SaveState(CLzmaEncHandle pp)
++static void LzmaEnc_SaveState(CLzmaEncHandle pp)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  CSaveState *dest = &p->saveState;
 +  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
 +}
 +
-+void LzmaEnc_RestoreState(CLzmaEncHandle pp)
++static void LzmaEnc_RestoreState(CLzmaEncHandle pp)
 +{
 +  CLzmaEnc *dest = (CLzmaEnc *)pp;
 +  const CSaveState *p = &dest->saveState;
 +  while (symbol < 0x10000);
 +}
 +
-+void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
++static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
 +{
 +  UInt32 i;
 +  for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
 +  p->matchPriceCount = 0;
 +}
 +
-+void LzmaEnc_Construct(CLzmaEnc *p)
++static void LzmaEnc_Construct(CLzmaEnc *p)
 +{
 +  RangeEnc_Construct(&p->rc);
 +  MatchFinder_Construct(&p->matchFinderBase);
 +  return p;
 +}
 +
-+void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
++static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
 +{
 +  alloc->Free(alloc, p->litProbs);
 +  alloc->Free(alloc, p->saveState.litProbs);
 +  p->saveState.litProbs = 0;
 +}
 +
-+void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
++static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  #ifdef COMPRESS_MF_MT
 +  MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
 +  return SZ_OK;
 +}
 +
-+void LzmaEnc_Init(CLzmaEnc *p)
++static void LzmaEnc_Init(CLzmaEnc *p)
 +{
 +  UInt32 i;
 +  p->state = 0;
 +  p->lpMask = (1 << p->lp) - 1;
 +}
 +
-+void LzmaEnc_InitPrices(CLzmaEnc *p)
++static void LzmaEnc_InitPrices(CLzmaEnc *p)
 +{
 +  if (!p->fastMode)
 +  {
 +  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
 +}
 +
-+SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
++static SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
 +    ISeqInStream *inStream, UInt32 keepWindowSize,
 +    ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  p->seqBufInStream.rem = srcLen;
 +}
 +
-+SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
++static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
 +    UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
 +}
 +
-+void LzmaEnc_Finish(CLzmaEncHandle pp)
++static void LzmaEnc_Finish(CLzmaEncHandle pp)
 +{
 +  #ifdef COMPRESS_MF_MT
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +}
 +
 +
-+UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
++static UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
 +{
 +  const CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
 +}
 +
-+const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
++static const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
 +{
 +  const CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
 +}
 +
-+SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
++static SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
 +    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  LzmaEnc_Destroy(p, alloc, allocBig);
 +  return res;
 +}
---- a/mkfs.jffs2.c     2009-06-05 16:59:08.000000000 +0200
-+++ b/mkfs.jffs2.c     2010-03-20 23:16:16.877026000 +0100
-@@ -1761,11 +1761,11 @@ int main(int argc, char **argv)
+--- a/jffsX-utils/mkfs.jffs2.c
++++ b/jffsX-utils/mkfs.jffs2.c
+@@ -1668,11 +1668,11 @@ int main(int argc, char **argv)
                                                  }
                                                  erase_block_size *= units;