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