Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // base\omap_hrp\h4_bootloader\inflate2.h
21 #ifndef __INFLATE2_H__
22 #define __INFLATE2_H__
24 #define __CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ 0x8000
27 const TInt KInflateWindowSize=__CONFIGURABLE_F32_LOADER_INFLATE_WINDOW_SIZE__ ;
32 TUint iPhysicalSector;
33 TUint iSemiPhysicalSector;
37 //#define __JUMP(cc,r) asm("mov"#cc " pc, "#r )
38 //#define __POPRET(rlist) asm("ldmfd sp!, {"##rlist##"pc} ")
40 void memcpy1(TAny*, const TAny*, TUint);
41 void memset1(void *, int, unsigned);
42 TInt memcmp1(const TUint8* aTrg, const TUint8* aSrc, TInt aLength);
45 extern "C" void memdump(TUint32* aAddr, TUint32* aEnd);
50 extern void countout(void);
51 extern void charout(TUint8 aChar);
53 extern void WriteW(TUint32);
54 extern void WriteB(TUint8);
55 extern void mmuoff(void);
62 /** Bit input stream. Good for reading bit streams for packed, compressed or huffman
69 TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
70 void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0);
73 TUint ReadL(TInt aSize);
74 TUint HuffmanL(const TUint32* aTree);
76 virtual void UnderflowL();
81 const TUint32* volatile iPtr;
84 const TInt KHuffTerminate=0x0001;
85 const TUint32 KBranch1=sizeof(TUint32)<<16;
88 /** Huffman code toolkit.
90 This class builds a huffman encoding from a frequency table and builds
91 a decoding tree from a code-lengths table
93 The encoding generated is based on the rule that given two symbols s1 and s2, with
94 code length l1 and l2, and huffman codes h1 and h2:
96 if l1<l2 then h1<h2 when compared lexicographically
97 if l1==l2 and s1<s2 then h1<h2 ditto
99 This allows the encoding to be stored compactly as a table of code lengths
104 enum {KMaxCodeLength=27};
105 enum {KMetaCodes=KMaxCodeLength+1};
106 enum {KMaxCodes=0x8000};
108 static void Decoding(const TUint32 aHuffman[],TInt aNumCodes,TUint32 aDecodeTree[],TInt aSymbolBase=0);
109 static TBool IsValid(const TUint32 aHuffman[],TInt aNumCodes);
111 static void InternalizeL(TBitInput& aInput,TUint32 aHuffman[],TInt aNumCodes);
115 // deflation constants
116 const TInt KDeflateLengthMag=8;
117 const TInt KDeflateDistanceMag=12;
119 const TInt KDeflateMinLength=3;
120 const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1<<KDeflateLengthMag);
121 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag);
122 const TInt KDeflateDistCodeBase=0x200;
128 enum {ELiterals=256,ELengths=(KDeflateLengthMag-1)*4,ESpecials=1,EDistances=(KDeflateDistanceMag-1)*4};
129 enum {ELitLens=ELiterals+ELengths+ESpecials};
130 enum {EEos=ELiterals+ELengths};
132 TUint32 iLitLen[ELitLens];
133 TUint32 iDistance[EDistances];
136 const TInt KDeflationCodes=TEncoding::ELitLens+TEncoding::EDistances;
141 static TInt Inflate(TBitInput& aBits, TUint8* aBuffer, TInt aSize);
143 static TInt Init(TBitInput& aBits, TEncoding& aEncoding);
144 static TInt DoInflate(TBitInput& aBits, TEncoding& aEncoding, TUint8* aBuffer, TInt aSize);
148 class TFileInput : public TBitInput
150 enum {KBufSize=KInflateWindowSize};
153 TFileInput(TInt aBlockLen, TInt aFileSize);
162 TUint8 iBuf1[KBufSize];
166 TInt iImageReadProgress;