Rename Protocol/FrameworkHii.h to Protocol/HiiFramework.h to follow the naming conven...
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
CommitLineData
54bd896e 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
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 BaseUefiTianoCustomDecompressLib.c\r
15\r
16Abstract:\r
17\r
18 UEFI and Custom Decompress Library \r
19\r
20--*/\r
21\r
54bd896e 22#include "BaseUefiTianoCustomDecompressLibInternals.h"\r
23\r
24VOID\r
25FillBuf (\r
26 IN SCRATCH_DATA *Sd,\r
27 IN UINT16 NumOfBits\r
28 )\r
29/*++\r
30\r
31Routine Description:\r
32\r
33 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.\r
34\r
35Arguments:\r
36\r
37 Sd - The global scratch data\r
38 NumOfBits - The number of bits to shift and read.\r
39\r
40Returns: (VOID)\r
41\r
42--*/\r
43{\r
44 Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);\r
45\r
46 while (NumOfBits > Sd->mBitCount) {\r
47\r
48 Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));\r
49\r
50 if (Sd->mCompSize > 0) {\r
51 //\r
52 // Get 1 byte into SubBitBuf\r
53 //\r
54 Sd->mCompSize--;\r
55 Sd->mSubBitBuf = 0;\r
56 Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];\r
57 Sd->mBitCount = 8;\r
58\r
59 } else {\r
60 //\r
61 // No more bits from the source, just pad zero bit.\r
62 //\r
63 Sd->mSubBitBuf = 0;\r
64 Sd->mBitCount = 8;\r
65\r
66 }\r
67 }\r
68\r
69 Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);\r
70 Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;\r
71}\r
72\r
73UINT32\r
74GetBits (\r
75 IN SCRATCH_DATA *Sd,\r
76 IN UINT16 NumOfBits\r
77 )\r
78/*++\r
79\r
80Routine Description:\r
81\r
82 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent \r
83 NumOfBits of bits from source. Returns NumOfBits of bits that are \r
84 popped out.\r
85\r
86Arguments:\r
87\r
88 Sd - The global scratch data.\r
89 NumOfBits - The number of bits to pop and read.\r
90\r
91Returns:\r
92\r
93 The bits that are popped out.\r
94\r
95--*/\r
96{\r
97 UINT32 OutBits;\r
98\r
99 OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));\r
100\r
101 FillBuf (Sd, NumOfBits);\r
102\r
103 return OutBits;\r
104}\r
105\r
106UINT16\r
107MakeTable (\r
108 IN SCRATCH_DATA *Sd,\r
109 IN UINT16 NumOfChar,\r
110 IN UINT8 *BitLen,\r
111 IN UINT16 TableBits,\r
112 OUT UINT16 *Table\r
113 )\r
114/*++\r
115\r
116Routine Description:\r
117\r
118 Creates Huffman Code mapping table according to code length array.\r
119\r
120Arguments:\r
121\r
122 Sd - The global scratch data\r
123 NumOfChar - Number of symbols in the symbol set\r
124 BitLen - Code length array\r
125 TableBits - The width of the mapping table\r
126 Table - The table\r
127 \r
128Returns:\r
129 \r
130 0 - OK.\r
131 BAD_TABLE - The table is corrupted.\r
132\r
133--*/\r
134{\r
135 UINT16 Count[17];\r
136 UINT16 Weight[17];\r
137 UINT16 Start[18];\r
138 UINT16 *Pointer;\r
139 UINT16 Index3;\r
140 volatile UINT16 Index;\r
141 UINT16 Len;\r
142 UINT16 Char;\r
143 UINT16 JuBits;\r
144 UINT16 Avail;\r
145 UINT16 NextCode;\r
146 UINT16 Mask;\r
147 UINT16 WordOfStart;\r
148 UINT16 WordOfCount;\r
149\r
150 for (Index = 1; Index <= 16; Index++) {\r
151 Count[Index] = 0;\r
152 }\r
153\r
154 for (Index = 0; Index < NumOfChar; Index++) {\r
155 Count[BitLen[Index]]++;\r
156 }\r
157\r
158 Start[1] = 0;\r
159\r
160 for (Index = 1; Index <= 16; Index++) {\r
161 WordOfStart = Start[Index];\r
162 WordOfCount = Count[Index];\r
163 Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));\r
164 }\r
165\r
166 if (Start[17] != 0) {\r
167 /*(1U << 16)*/\r
168 return (UINT16) BAD_TABLE;\r
169 }\r
170\r
171 JuBits = (UINT16) (16 - TableBits);\r
172\r
173 for (Index = 1; Index <= TableBits; Index++) {\r
174 Start[Index] >>= JuBits;\r
175 Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
176 }\r
177\r
178 while (Index <= 16) {\r
179 Weight[Index] = (UINT16) (1U << (16 - Index));\r
180 Index++;\r
181 }\r
182\r
183 Index = (UINT16) (Start[TableBits + 1] >> JuBits);\r
184\r
185 if (Index != 0) {\r
186 Index3 = (UINT16) (1U << TableBits);\r
187 while (Index != Index3) {\r
188 Table[Index++] = 0;\r
189 }\r
190 }\r
191\r
192 Avail = NumOfChar;\r
193 Mask = (UINT16) (1U << (15 - TableBits));\r
194\r
195 for (Char = 0; Char < NumOfChar; Char++) {\r
196\r
197 Len = BitLen[Char];\r
198 if (Len == 0) {\r
199 continue;\r
200 }\r
201\r
202 NextCode = (UINT16) (Start[Len] + Weight[Len]);\r
203\r
204 if (Len <= TableBits) {\r
205\r
206 for (Index = Start[Len]; Index < NextCode; Index++) {\r
207 Table[Index] = Char;\r
208 }\r
209\r
210 } else {\r
211\r
212 Index3 = Start[Len];\r
213 Pointer = &Table[Index3 >> JuBits];\r
214 Index = (UINT16) (Len - TableBits);\r
215\r
216 while (Index != 0) {\r
217 if (*Pointer == 0) {\r
218 Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;\r
219 *Pointer = Avail++;\r
220 }\r
221\r
222 if (Index3 & Mask) {\r
223 Pointer = &Sd->mRight[*Pointer];\r
224 } else {\r
225 Pointer = &Sd->mLeft[*Pointer];\r
226 }\r
227\r
228 Index3 <<= 1;\r
229 Index--;\r
230 }\r
231\r
232 *Pointer = Char;\r
233\r
234 }\r
235\r
236 Start[Len] = NextCode;\r
237 }\r
238 //\r
239 // Succeeds\r
240 //\r
241 return 0;\r
242}\r
243\r
244UINT32\r
245DecodeP (\r
246 IN SCRATCH_DATA *Sd\r
247 )\r
248/*++\r
249\r
250Routine Description:\r
251\r
252 Decodes a position value.\r
253\r
254Arguments:\r
255\r
256 Sd - the global scratch data\r
257\r
258Returns:\r
259\r
260 The position value decoded.\r
261\r
262--*/\r
263{\r
264 UINT16 Val;\r
265 UINT32 Mask;\r
266 UINT32 Pos;\r
267\r
268 Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
269\r
270 if (Val >= MAXNP) {\r
271 Mask = 1U << (BITBUFSIZ - 1 - 8);\r
272\r
273 do {\r
274\r
275 if (Sd->mBitBuf & Mask) {\r
276 Val = Sd->mRight[Val];\r
277 } else {\r
278 Val = Sd->mLeft[Val];\r
279 }\r
280\r
281 Mask >>= 1;\r
282 } while (Val >= MAXNP);\r
283 }\r
284 //\r
285 // Advance what we have read\r
286 //\r
287 FillBuf (Sd, Sd->mPTLen[Val]);\r
288\r
289 Pos = Val;\r
290 if (Val > 1) {\r
291 Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));\r
292 }\r
293\r
294 return Pos;\r
295}\r
296\r
297UINT16\r
298ReadPTLen (\r
299 IN SCRATCH_DATA *Sd,\r
300 IN UINT16 nn,\r
301 IN UINT16 nbit,\r
302 IN UINT16 Special\r
303 )\r
304/*++\r
305\r
306Routine Description:\r
307\r
308 Reads code lengths for the Extra Set or the Position Set\r
309\r
310Arguments:\r
311\r
312 Sd - The global scratch data\r
313 nn - Number of symbols\r
314 nbit - Number of bits needed to represent nn\r
315 Special - The special symbol that needs to be taken care of \r
316\r
317Returns:\r
318\r
319 0 - OK.\r
320 BAD_TABLE - Table is corrupted.\r
321\r
322--*/\r
323{\r
324 UINT16 Number;\r
325 UINT16 CharC;\r
326 volatile UINT16 Index;\r
327 UINT32 Mask;\r
328\r
329 Number = (UINT16) GetBits (Sd, nbit);\r
330\r
331 if (Number == 0) {\r
332 CharC = (UINT16) GetBits (Sd, nbit);\r
333\r
334 for (Index = 0; Index < 256; Index++) {\r
335 Sd->mPTTable[Index] = CharC;\r
336 }\r
337\r
338 for (Index = 0; Index < nn; Index++) {\r
339 Sd->mPTLen[Index] = 0;\r
340 }\r
341\r
342 return 0;\r
343 }\r
344\r
345 Index = 0;\r
346\r
347 while (Index < Number) {\r
348\r
349 CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
350\r
351 if (CharC == 7) {\r
352 Mask = 1U << (BITBUFSIZ - 1 - 3);\r
353 while (Mask & Sd->mBitBuf) {\r
354 Mask >>= 1;\r
355 CharC += 1;\r
356 }\r
357 }\r
358\r
359 FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));\r
360\r
361 Sd->mPTLen[Index++] = (UINT8) CharC;\r
362\r
363 if (Index == Special) {\r
364 CharC = (UINT16) GetBits (Sd, 2);\r
365 while ((INT16) (--CharC) >= 0) {\r
366 Sd->mPTLen[Index++] = 0;\r
367 }\r
368 }\r
369 }\r
370\r
371 while (Index < nn) {\r
372 Sd->mPTLen[Index++] = 0;\r
373 }\r
374\r
375 return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);\r
376}\r
377\r
378VOID\r
379ReadCLen (\r
380 SCRATCH_DATA *Sd\r
381 )\r
382/*++\r
383\r
384Routine Description:\r
385\r
386 Reads code lengths for Char&Len Set.\r
387\r
388Arguments:\r
389\r
390 Sd - the global scratch data\r
391\r
392Returns: (VOID)\r
393\r
394--*/\r
395{\r
396 UINT16 Number;\r
397 UINT16 CharC;\r
398 volatile UINT16 Index;\r
399 UINT32 Mask;\r
400\r
401 Number = (UINT16) GetBits (Sd, CBIT);\r
402\r
403 if (Number == 0) {\r
404 CharC = (UINT16) GetBits (Sd, CBIT);\r
405\r
406 for (Index = 0; Index < NC; Index++) {\r
407 Sd->mCLen[Index] = 0;\r
408 }\r
409\r
410 for (Index = 0; Index < 4096; Index++) {\r
411 Sd->mCTable[Index] = CharC;\r
412 }\r
413\r
414 return ;\r
415 }\r
416\r
417 Index = 0;\r
418 while (Index < Number) {\r
419\r
420 CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
421 if (CharC >= NT) {\r
422 Mask = 1U << (BITBUFSIZ - 1 - 8);\r
423\r
424 do {\r
425\r
426 if (Mask & Sd->mBitBuf) {\r
427 CharC = Sd->mRight[CharC];\r
428 } else {\r
429 CharC = Sd->mLeft[CharC];\r
430 }\r
431\r
432 Mask >>= 1;\r
433\r
434 } while (CharC >= NT);\r
435 }\r
436 //\r
437 // Advance what we have read\r
438 //\r
439 FillBuf (Sd, Sd->mPTLen[CharC]);\r
440\r
441 if (CharC <= 2) {\r
442\r
443 if (CharC == 0) {\r
444 CharC = 1;\r
445 } else if (CharC == 1) {\r
446 CharC = (UINT16) (GetBits (Sd, 4) + 3);\r
447 } else if (CharC == 2) {\r
448 CharC = (UINT16) (GetBits (Sd, CBIT) + 20);\r
449 }\r
450\r
451 while ((INT16) (--CharC) >= 0) {\r
452 Sd->mCLen[Index++] = 0;\r
453 }\r
454\r
455 } else {\r
456\r
457 Sd->mCLen[Index++] = (UINT8) (CharC - 2);\r
458\r
459 }\r
460 }\r
461\r
462 while (Index < NC) {\r
463 Sd->mCLen[Index++] = 0;\r
464 }\r
465\r
466 MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
467\r
468 return ;\r
469}\r
470\r
471UINT16\r
472DecodeC (\r
473 SCRATCH_DATA *Sd\r
474 )\r
475/*++\r
476\r
477Routine Description:\r
478\r
479 Decode a character/length value.\r
480\r
481Arguments:\r
482\r
483 Sd - The global scratch data.\r
484\r
485Returns:\r
486\r
487 The value decoded.\r
488\r
489--*/\r
490{\r
491 UINT16 Index2;\r
492 UINT32 Mask;\r
493\r
494 if (Sd->mBlockSize == 0) {\r
495 //\r
496 // Starting a new block\r
497 //\r
498 Sd->mBlockSize = (UINT16) GetBits (Sd, 16);\r
499 Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);\r
500 if (Sd->mBadTableFlag != 0) {\r
501 return 0;\r
502 }\r
503\r
504 ReadCLen (Sd);\r
505\r
506 Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));\r
507 if (Sd->mBadTableFlag != 0) {\r
508 return 0;\r
509 }\r
510 }\r
511\r
512 Sd->mBlockSize--;\r
513 Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];\r
514\r
515 if (Index2 >= NC) {\r
516 Mask = 1U << (BITBUFSIZ - 1 - 12);\r
517\r
518 do {\r
519 if (Sd->mBitBuf & Mask) {\r
520 Index2 = Sd->mRight[Index2];\r
521 } else {\r
522 Index2 = Sd->mLeft[Index2];\r
523 }\r
524\r
525 Mask >>= 1;\r
526 } while (Index2 >= NC);\r
527 }\r
528 //\r
529 // Advance what we have read\r
530 //\r
531 FillBuf (Sd, Sd->mCLen[Index2]);\r
532\r
533 return Index2;\r
534}\r
535\r
536VOID\r
537Decode (\r
538 SCRATCH_DATA *Sd\r
539 )\r
540/*++\r
541\r
542Routine Description:\r
543\r
544 Decode the source data and put the resulting data into the destination buffer.\r
545\r
546Arguments:\r
547\r
548 Sd - The global scratch data\r
549\r
550Returns: (VOID)\r
551\r
552 --*/\r
553{\r
554 UINT16 BytesRemain;\r
555 UINT32 DataIdx;\r
556 UINT16 CharC;\r
557\r
558 BytesRemain = (UINT16) (-1);\r
559\r
560 DataIdx = 0;\r
561\r
562 for (;;) {\r
563 CharC = DecodeC (Sd);\r
564 if (Sd->mBadTableFlag != 0) {\r
565 goto Done ;\r
566 }\r
567\r
568 if (CharC < 256) {\r
569 //\r
570 // Process an Original character\r
571 //\r
572 if (Sd->mOutBuf >= Sd->mOrigSize) {\r
573 goto Done ;\r
574 } else {\r
575 Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;\r
576 }\r
577\r
578 } else {\r
579 //\r
580 // Process a Pointer\r
581 //\r
582 CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));\r
583\r
584 BytesRemain = CharC;\r
585\r
586 DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;\r
587\r
588 BytesRemain--;\r
589 while ((INT16) (BytesRemain) >= 0) {\r
590 Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];\r
591 if (Sd->mOutBuf >= Sd->mOrigSize) {\r
592 goto Done ;\r
593 }\r
594\r
595 BytesRemain--;\r
596 }\r
597 }\r
598 }\r
599\r
600Done:\r
601 return ;\r
602}\r
603\r
604RETURN_STATUS\r
605EFIAPI\r
606UefiDecompressGetInfo (\r
607 IN CONST VOID *Source,\r
608 IN UINT32 SourceSize,\r
609 OUT UINT32 *DestinationSize,\r
610 OUT UINT32 *ScratchSize\r
611 )\r
612/*++\r
613\r
614Routine Description:\r
615\r
616 The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
617\r
618Arguments:\r
619\r
620 Source - The source buffer containing the compressed data.\r
621 SourceSize - The size of source buffer\r
622 DestinationSize - The size of destination buffer.\r
623 ScratchSize - The size of scratch buffer.\r
624\r
625Returns:\r
626\r
627 RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
628 RETURN_INVALID_PARAMETER - The source data is corrupted\r
629\r
630--*/\r
631{\r
632 UINT32 CompressedSize;\r
633\r
634 ASSERT (Source != NULL);\r
635 ASSERT (DestinationSize != NULL);\r
636 ASSERT (ScratchSize != NULL);\r
637\r
638 *ScratchSize = sizeof (SCRATCH_DATA);\r
639\r
640 if (SourceSize < 8) {\r
641 return RETURN_INVALID_PARAMETER;\r
642 }\r
643\r
644 CopyMem (&CompressedSize, Source, sizeof (UINT32));\r
645 CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32));\r
646\r
647 if (SourceSize < (CompressedSize + 8)) {\r
648 return RETURN_INVALID_PARAMETER;\r
649 }\r
650\r
651 return RETURN_SUCCESS;\r
652}\r
653\r
654RETURN_STATUS\r
655EFIAPI\r
656UefiTianoDecompress (\r
657 IN CONST VOID *Source,\r
658 IN OUT VOID *Destination,\r
659 IN OUT VOID *Scratch,\r
660 IN UINT32 Version\r
661 )\r
662/*++\r
663\r
664Routine Description:\r
665\r
666 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
667\r
668Arguments:\r
669\r
670 Source - The source buffer containing the compressed data.\r
671 Destination - The destination buffer to store the decompressed data\r
672 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.\r
673 Version - 1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm\r
674\r
675Returns:\r
676\r
677 RETURN_SUCCESS - Decompression is successfull\r
678 RETURN_INVALID_PARAMETER - The source data is corrupted\r
679\r
680--*/\r
681{\r
682 volatile UINT32 Index;\r
683 UINT32 CompSize;\r
684 UINT32 OrigSize;\r
685 SCRATCH_DATA *Sd;\r
686 CONST UINT8 *Src;\r
687 UINT8 *Dst;\r
688\r
689 ASSERT (Source != NULL);\r
690 ASSERT (Destination != NULL);\r
691 ASSERT (Scratch != NULL);\r
692\r
693 Src = Source;\r
694 Dst = Destination;\r
695\r
696 Sd = (SCRATCH_DATA *) Scratch;\r
697\r
698 CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);\r
699 OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);\r
700\r
701 //\r
702 // If compressed file size is 0, return\r
703 //\r
704 if (OrigSize == 0) {\r
705 return RETURN_SUCCESS;\r
706 }\r
707\r
708 Src = Src + 8;\r
709\r
710 for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
711 ((UINT8 *) Sd)[Index] = 0;\r
712 }\r
713 //\r
714 // The length of the field 'Position Set Code Length Array Size' in Block Header.\r
715 // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4\r
716 // For Tiano de/compression algorithm(Version 2), mPBit = 5\r
717 //\r
718 switch (Version) {\r
719 case 1 :\r
720 Sd->mPBit = 4;\r
721 break;\r
722 case 2 :\r
723 Sd->mPBit = 5;\r
724 break;\r
725 default:\r
726 ASSERT (FALSE);\r
727 }\r
728 Sd->mSrcBase = (UINT8 *)Src;\r
729 Sd->mDstBase = Dst;\r
730 Sd->mCompSize = CompSize;\r
731 Sd->mOrigSize = OrigSize;\r
732\r
733 //\r
734 // Fill the first BITBUFSIZ bits\r
735 //\r
736 FillBuf (Sd, BITBUFSIZ);\r
737\r
738 //\r
739 // Decompress it\r
740 //\r
741 Decode (Sd);\r
742\r
743 if (Sd->mBadTableFlag != 0) {\r
744 //\r
745 // Something wrong with the source\r
746 //\r
747 return RETURN_INVALID_PARAMETER;\r
748 }\r
749\r
750 return RETURN_SUCCESS;\r
751}\r
752\r
753RETURN_STATUS\r
754EFIAPI\r
755UefiDecompress (\r
756 IN CONST VOID *Source,\r
757 IN OUT VOID *Destination,\r
758 IN OUT VOID *Scratch\r
759 )\r
760/*++\r
761\r
762Routine Description:\r
763\r
764 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
765\r
766Arguments:\r
767\r
768 Source - The source buffer containing the compressed data.\r
769 Destination - The destination buffer to store the decompressed data\r
770 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.\r
771\r
772Returns:\r
773\r
774 RETURN_SUCCESS - Decompression is successfull\r
775 RETURN_INVALID_PARAMETER - The source data is corrupted\r
776\r
777--*/\r
778{\r
779 return UefiTianoDecompress (Source, Destination, Scratch, 1);\r
780}\r
781\r
782RETURN_STATUS\r
783EFIAPI\r
784CustomDecompressGetInfo (\r
785 IN CONST VOID *Source,\r
786 IN UINT32 SourceSize,\r
787 OUT UINT32 *DestinationSize,\r
788 OUT UINT32 *ScratchSize\r
789 )\r
790/*++\r
791\r
792Routine Description:\r
793\r
794 The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
795\r
796Arguments:\r
797\r
798 Source - The source buffer containing the compressed data.\r
799 SourceSize - The size of source buffer\r
800 DestinationSize - The size of destination buffer.\r
801 ScratchSize - The size of scratch buffer.\r
802\r
803Returns:\r
804\r
805 RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
806 RETURN_INVALID_PARAMETER - The source data is corrupted\r
807\r
808--*/\r
809{\r
810 return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
811}\r
812\r
813RETURN_STATUS\r
814EFIAPI\r
815CustomDecompress (\r
816 IN CONST VOID *Source,\r
817 IN OUT VOID *Destination,\r
818 IN OUT VOID *Scratch\r
819 )\r
820/*++\r
821\r
822Routine Description:\r
823\r
824 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
825\r
826Arguments:\r
827\r
828 Source - The source buffer containing the compressed data.\r
829 Destination - The destination buffer to store the decompressed data\r
830 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.\r
831\r
832Returns:\r
833\r
834 RETURN_SUCCESS - Decompression is successfull\r
835 RETURN_INVALID_PARAMETER - The source data is corrupted\r
836\r
837--*/\r
838{\r
839 return UefiTianoDecompress (Source, Destination, Scratch, 2);\r
840}\r