]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLibInternals.h
EdkCompatibilityPkg: Fix typos in comments
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseUefiDecompressLib / BaseUefiDecompressLibInternals.h
CommitLineData
3eb9473e 1/*++\r
2\r
2c7e5c2f
HT
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 BaseUefiDecompressLibInternals.h\r
15 \r
16Abstract: \r
17\r
18 Header file for Base Uefi Decompress Library.\r
19 \r
20--*/\r
21\r
22#ifndef __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\r
23#define __BASE_UEFI_DECOMPRESS_LIB_INTERNALS_H__\r
24\r
25#include "EdkIIGlueBase.h"\r
26\r
27//\r
28// Decompression algorithm begins here\r
29//\r
30#define BITBUFSIZ 32\r
31#define MAXMATCH 256\r
32#define THRESHOLD 3\r
33#define CODE_BIT 16\r
34#define BAD_TABLE - 1\r
35\r
36//\r
37// C: Char&Len Set; P: Position Set; T: exTra Set\r
38//\r
39#define NC (0xff + MAXMATCH + 2 - THRESHOLD)\r
40#define CBIT 9\r
41#define MAXPBIT 5\r
42#define TBIT 5\r
43#define MAXNP ((1U << MAXPBIT) - 1)\r
44#define NT (CODE_BIT + 3)\r
45#if NT > MAXNP\r
46#define NPT NT\r
47#else\r
48#define NPT MAXNP\r
49#endif\r
50\r
51typedef struct {\r
52 UINT8 *mSrcBase; ///< Starting address of compressed data\r
53 UINT8 *mDstBase; ///< Starting address of decompressed data\r
54 UINT32 mOutBuf;\r
55 UINT32 mInBuf;\r
56\r
57 UINT16 mBitCount;\r
58 UINT32 mBitBuf;\r
59 UINT32 mSubBitBuf;\r
60 UINT16 mBlockSize;\r
61 UINT32 mCompSize;\r
62 UINT32 mOrigSize;\r
63\r
64 UINT16 mBadTableFlag;\r
65\r
66 UINT16 mLeft[2 * NC - 1];\r
67 UINT16 mRight[2 * NC - 1];\r
68 UINT8 mCLen[NC];\r
69 UINT8 mPTLen[NPT];\r
70 UINT16 mCTable[4096];\r
71 UINT16 mPTTable[256];\r
72\r
73 ///\r
74 /// The length of the field 'Position Set Code Length Array Size' in Block Header.\r
75 /// For EFI 1.1 de/compression algorithm, mPBit = 4\r
76 /// For Tiano de/compression algorithm, mPBit = 5\r
77 ///\r
78 UINT8 mPBit;\r
79} SCRATCH_DATA;\r
80\r
81/**\r
82 Read NumOfBit of bits from source into mBitBuf\r
83\r
84 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
85\r
86 @param Sd The global scratch data\r
87 @param NumOfBits The number of bits to shift and read.\r
88\r
89**/\r
90VOID\r
91GlueFillBuf (\r
92 IN SCRATCH_DATA *Sd,\r
93 IN UINT16 NumOfBits\r
94 );\r
95\r
96/**\r
97 Get NumOfBits of bits out from mBitBuf\r
98\r
99 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
100 NumOfBits of bits from source. Returns NumOfBits of bits that are \r
101 popped out.\r
102\r
103 @param Sd The global scratch data.\r
104 @param NumOfBits The number of bits to pop and read.\r
105\r
106 @return The bits that are popped out.\r
107\r
108**/\r
109UINT32\r
110GlueGetBits (\r
111 IN SCRATCH_DATA *Sd,\r
112 IN UINT16 NumOfBits\r
113 );\r
114\r
115/**\r
116 Creates Huffman Code mapping table according to code length array.\r
117\r
118 Creates Huffman Code mapping table for Extra Set, Char&Len Set \r
119 and Position Set according to code length array.\r
120\r
121 @param Sd The global scratch data\r
122 @param NumOfChar Number of symbols in the symbol set\r
123 @param BitLen Code length array\r
124 @param TableBits The width of the mapping table\r
125 @param Table The table\r
126\r
127 @retval 0 OK.\r
128 @retval BAD_TABLE The table is corrupted.\r
129\r
130**/\r
131UINT16\r
132GlueMakeTable (\r
133 IN SCRATCH_DATA *Sd,\r
134 IN UINT16 NumOfChar,\r
135 IN UINT8 *BitLen,\r
136 IN UINT16 TableBits,\r
137 OUT UINT16 *Table\r
138 );\r
139\r
140/**\r
141 Decodes a position value.\r
142\r
143 Get a position value according to Position Huffman Table.\r
144 \r
145 @param Sd the global scratch data\r
146\r
147 @return The position value decoded.\r
148\r
149**/\r
150UINT32\r
151GlueDecodeP (\r
152 IN SCRATCH_DATA *Sd\r
153 );\r
154\r
155/**\r
156 Reads code lengths for the Extra Set or the Position Set.\r
157\r
4fc0be87 158 Read in the Extra Set or Position Set Length Array, then\r
3eb9473e 159 generate the Huffman code mapping for them.\r
160\r
161 @param Sd The global scratch data.\r
162 @param nn Number of symbols.\r
163 @param nbit Number of bits needed to represent nn.\r
164 @param Special The special symbol that needs to be taken care of.\r
165\r
166 @retval 0 OK.\r
167 @retval BAD_TABLE Table is corrupted.\r
168\r
169**/\r
170UINT16\r
171GlueReadPTLen (\r
172 IN SCRATCH_DATA *Sd,\r
173 IN UINT16 nn,\r
174 IN UINT16 nbit,\r
175 IN UINT16 Special\r
176 );\r
177\r
178/**\r
179 Reads code lengths for Char&Len Set.\r
180 \r
181 Read in and decode the Char&Len Set Code Length Array, then\r
182 generate the Huffman Code mapping table for the Char&Len Set.\r
183\r
184 @param Sd the global scratch data\r
185\r
186**/\r
187VOID\r
188GlueReadCLen (\r
189 SCRATCH_DATA *Sd\r
190 );\r
191\r
192/**\r
193 Decode a character/length value.\r
194 \r
195 Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates\r
196 Huffman code mapping table for Extra Set, Code&Len Set and\r
197 Position Set.\r
198\r
199 @param Sd The global scratch data.\r
200\r
201 @return The value decoded.\r
202\r
203**/\r
204UINT16\r
205GlueDecodeC (\r
206 SCRATCH_DATA *Sd\r
207 );\r
208\r
209/**\r
210 Decode the source data and put the resulting data into the destination buffer.\r
211\r
212 Decode the source data and put the resulting data into the destination buffer.\r
213 \r
214 @param Sd The global scratch data\r
215\r
216**/\r
217VOID\r
218GlueDecode (\r
219 SCRATCH_DATA *Sd\r
220 );\r
221\r
222#endif\r