summaryrefslogtreecommitdiff
path: root/package/uboot-ifxmips/files/lib_generic
diff options
context:
space:
mode:
authorthl <thl@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-11-19 17:40:05 +0000
committerthl <thl@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-11-19 17:40:05 +0000
commit09b96811e8ca8ad48fc6604f55690978158d0596 (patch)
tree82989cd5ea141baf9cdc51d0578368e36cd15a67 /package/uboot-ifxmips/files/lib_generic
parent25a958e9bfd467a5a394adb76601cb6dc525375d (diff)
[ifxmips] cleanup uboot package
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13291 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uboot-ifxmips/files/lib_generic')
-rw-r--r--package/uboot-ifxmips/files/lib_generic/LzmaDecode.c26
-rw-r--r--package/uboot-ifxmips/files/lib_generic/LzmaDecode.h113
-rw-r--r--package/uboot-ifxmips/files/lib_generic/LzmaTypes.h45
-rw-r--r--package/uboot-ifxmips/files/lib_generic/LzmaWrapper.c23
4 files changed, 46 insertions, 161 deletions
diff --git a/package/uboot-ifxmips/files/lib_generic/LzmaDecode.c b/package/uboot-ifxmips/files/lib_generic/LzmaDecode.c
index 99d1117701..1ce2398f47 100644
--- a/package/uboot-ifxmips/files/lib_generic/LzmaDecode.c
+++ b/package/uboot-ifxmips/files/lib_generic/LzmaDecode.c
@@ -19,6 +19,9 @@
to this file, however, are subject to the LGPL or CPL terms.
*/
+#include <config.h>
+#include <common.h>
+
#ifdef CONFIG_LZMA
#include "LzmaDecode.h"
@@ -37,22 +40,31 @@
#ifdef _LZMA_IN_CB
+#ifndef CFG_BOOTSTRAP_CODE
#define RC_TEST { if (Buffer == BufferLim) \
{ SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) { printf("ERROR, %s, %d\n", __FILE__, __LINE__); return result; } \
BufferLim = Buffer + size; if (size == 0) { printf("ERROR, %s, %d\n", __FILE__, __LINE__); return LZMA_RESULT_DATA_ERROR; } }}
+#else //CFG_BOOTSTRAP_CODE
+#define RC_TEST { if (Buffer == BufferLim) \
+ { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) { return result; } \
+ BufferLim = Buffer + size; if (size == 0) { return LZMA_RESULT_DATA_ERROR; } }}
+#endif //CFG_BOOTSTRAP_CODE
#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
-#else
+#else //_LZMA_IN_CB
+#ifndef CFG_BOOTSTRAP_CODE
#define RC_TEST { if (Buffer == BufferLim) { printf("ERROR, %s, %d\n", __FILE__, __LINE__); return LZMA_RESULT_DATA_ERROR; } }
+#else //CFG_BOOTSTRAP_CODE
+#define RC_TEST { if (Buffer == BufferLim) { return LZMA_RESULT_DATA_ERROR; } }
+#endif //CFG_BOOTSTRAP_CODE
#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
-#endif
+#endif //_LZMA_IN_CB
#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
-
#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
@@ -124,13 +136,17 @@ int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsDa
unsigned char prop0;
if (size < LZMA_PROPERTIES_SIZE)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("ERROR: %s, %d\n", __FILE__, __LINE__);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
prop0 = propsData[0];
if (prop0 >= (9 * 5 * 5))
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("ERROR: %s, %d\n", __FILE__, __LINE__);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
{
@@ -380,7 +396,9 @@ int LzmaDecode(CLzmaDecoderState *vs,
if (nowPos == 0)
#endif
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("ERROR: %s, %d\n", __FILE__, __LINE__);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
@@ -540,7 +558,9 @@ int LzmaDecode(CLzmaDecoderState *vs,
if (rep0 > nowPos)
#endif
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("ERROR: %s, %d\n", __FILE__, __LINE__);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
diff --git a/package/uboot-ifxmips/files/lib_generic/LzmaDecode.h b/package/uboot-ifxmips/files/lib_generic/LzmaDecode.h
deleted file mode 100644
index 2870eeb9c9..0000000000
--- a/package/uboot-ifxmips/files/lib_generic/LzmaDecode.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- LzmaDecode.h
- LZMA Decoder interface
-
- LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
- http://www.7-zip.org/
-
- LZMA SDK is licensed under two licenses:
- 1) GNU Lesser General Public License (GNU LGPL)
- 2) Common Public License (CPL)
- It means that you can select one of these two licenses and
- follow rules of that license.
-
- SPECIAL EXCEPTION:
- Igor Pavlov, as the author of this code, expressly permits you to
- statically or dynamically link your code (or bind by name) to the
- interfaces of this file without subjecting your linked code to the
- terms of the CPL or GNU LGPL. Any modifications or additions
- to this file, however, are subject to the LGPL or CPL terms.
-*/
-
-#ifndef __LZMADECODE_H
-#define __LZMADECODE_H
-
-#include "LzmaTypes.h"
-
-/* #define _LZMA_IN_CB */
-/* Use callback for input data */
-
-/* #define _LZMA_OUT_READ */
-/* Use read function for output data */
-
-/* #define _LZMA_PROB32 */
-/* It can increase speed on some 32-bit CPUs,
- but memory usage will be doubled in that case */
-
-/* #define _LZMA_LOC_OPT */
-/* Enable local speed optimizations inside code */
-
-#ifdef _LZMA_PROB32
-#define CProb UInt32
-#else
-#define CProb UInt16
-#endif
-
-#define LZMA_RESULT_OK 0
-#define LZMA_RESULT_DATA_ERROR 1
-
-#ifdef _LZMA_IN_CB
-typedef struct _ILzmaInCallback
-{
- int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
-} ILzmaInCallback;
-#endif
-
-#define LZMA_BASE_SIZE 1846
-#define LZMA_LIT_SIZE 768
-
-#define LZMA_PROPERTIES_SIZE 5
-
-typedef struct _CLzmaProperties
-{
- int lc;
- int lp;
- int pb;
- #ifdef _LZMA_OUT_READ
- UInt32 DictionarySize;
- #endif
-}CLzmaProperties;
-
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
-
-#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
-
-#define kLzmaNeedInitId (-2)
-
-typedef struct _CLzmaDecoderState
-{
- CLzmaProperties Properties;
- CProb *Probs;
-
- #ifdef _LZMA_IN_CB
- const unsigned char *Buffer;
- const unsigned char *BufferLim;
- #endif
-
- #ifdef _LZMA_OUT_READ
- unsigned char *Dictionary;
- UInt32 Range;
- UInt32 Code;
- UInt32 DictionaryPos;
- UInt32 GlobalPos;
- UInt32 DistanceLimit;
- UInt32 Reps[4];
- int State;
- int RemainLen;
- unsigned char TempDictionary[4];
- #endif
-} CLzmaDecoderState;
-
-#ifdef _LZMA_OUT_READ
-#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
-#endif
-
-int LzmaDecode(CLzmaDecoderState *vs,
- #ifdef _LZMA_IN_CB
- ILzmaInCallback *inCallback,
- #else
- const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
- #endif
- unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
-
-#endif
diff --git a/package/uboot-ifxmips/files/lib_generic/LzmaTypes.h b/package/uboot-ifxmips/files/lib_generic/LzmaTypes.h
deleted file mode 100644
index 288c5e45d7..0000000000
--- a/package/uboot-ifxmips/files/lib_generic/LzmaTypes.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-LzmaTypes.h
-
-Types for LZMA Decoder
-
-This file written and distributed to public domain by Igor Pavlov.
-This file is part of LZMA SDK 4.40 (2006-05-01)
-*/
-
-#ifndef __LZMATYPES_H
-#define __LZMATYPES_H
-
-#ifndef _7ZIP_BYTE_DEFINED
-#define _7ZIP_BYTE_DEFINED
-typedef unsigned char Byte;
-#endif
-
-#ifndef _7ZIP_UINT16_DEFINED
-#define _7ZIP_UINT16_DEFINED
-typedef unsigned short UInt16;
-#endif
-
-#ifndef _7ZIP_UINT32_DEFINED
-#define _7ZIP_UINT32_DEFINED
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef unsigned long UInt32;
-#else
-typedef unsigned int UInt32;
-#endif
-#endif
-
-/* #define _LZMA_SYSTEM_SIZE_T */
-/* Use system's size_t. You can use it to enable 64-bit sizes supporting */
-
-#ifndef _7ZIP_SIZET_DEFINED
-#define _7ZIP_SIZET_DEFINED
-#ifdef _LZMA_SYSTEM_SIZE_T
-#include <stddef.h>
-typedef size_t SizeT;
-#else
-typedef UInt32 SizeT;
-#endif
-#endif
-
-#endif
diff --git a/package/uboot-ifxmips/files/lib_generic/LzmaWrapper.c b/package/uboot-ifxmips/files/lib_generic/LzmaWrapper.c
index 6c3d702461..1ee5c12ba8 100644
--- a/package/uboot-ifxmips/files/lib_generic/LzmaWrapper.c
+++ b/package/uboot-ifxmips/files/lib_generic/LzmaWrapper.c
@@ -20,6 +20,7 @@
** $Date $Author $Comment
** 2 Nov 2006 Lin Mars init version which derived from LzmaTest.c from
** LZMA v4.43 SDK
+** 24 May 2007 Lin Mars Fix issue for multiple lzma_inflate involved
*******************************************************************************/
#define LZMA_NO_STDIO
#ifndef LZMA_NO_STDIO
@@ -40,8 +41,10 @@
#include "LzmaDecode.h"
#include "LzmaWrapper.h"
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
static const char *kCantReadMessage = "Can not read from source buffer";
static const char *kCantAllocateMessage = "Not enough buffer for decompression";
+#endif
static size_t rpos=0, dpos=0;
@@ -76,9 +79,13 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
int res;
+ rpos=0; dpos=0;
+
if (sizeof(UInt32) < 4)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("LZMA decoder needs correct UInt32\n");
+#endif
return LZMA_RESULT_DATA_ERROR;
}
@@ -86,7 +93,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
long length=s_len;
if ((long)(SizeT)length != length)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("Too big compressed stream\n");
+#endif
return LZMA_RESULT_DATA_ERROR;
}
compressedSize = (SizeT)(length - (LZMA_PROPERTIES_SIZE + 8));
@@ -96,7 +105,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
if (!MyReadFileAndCheck(source, properties, sizeof(properties)))
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("%s\n", kCantReadMessage);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
@@ -108,7 +119,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
unsigned char b;
if (!MyReadFileAndCheck(source, &b, 1))
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("%s\n", kCantReadMessage);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
if (b != 0xFF)
@@ -121,7 +134,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
if (waitEOS)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("Stream with EOS marker is not supported");
+#endif
return LZMA_RESULT_DATA_ERROR;
}
outSizeFull = (SizeT)outSize;
@@ -129,7 +144,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("Too big uncompressed stream");
+#endif
return LZMA_RESULT_DATA_ERROR;
}
}
@@ -137,7 +154,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
/* Decode LZMA properties and allocate memory */
if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("Incorrect stream properties");
+#endif
return LZMA_RESULT_DATA_ERROR;
}
state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
@@ -168,7 +187,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
)
{
free(state.Probs);
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("%s\n", kCantAllocateMessage);
+#endif
return LZMA_RESULT_DATA_ERROR;
}
@@ -181,7 +202,9 @@ int lzma_inflate(unsigned char *source, int s_len, unsigned char *dest, int *d_l
outStream, outSizeFull, &outProcessed);
if (res != 0)
{
+#if defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF) || !defined(CFG_BOOTSTRAP_CODE)
printf("\nDecoding error = %d\n", res);
+#endif
res = 1;
}
else