]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/EfiLdr/TianoDecompress.c
1) Fix some casting working in X64 building
[mirror_edk2.git] / DuetPkg / EfiLdr / TianoDecompress.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Decompress.c
15
16 Abstract:
17
18 Decompressor. Algorithm Ported from OPSD code (Decomp.asm)
19
20 --*/
21 #include <TianoDecompress.h>
22 //
23 // Decompression algorithm begins here
24 //
25 #define BITBUFSIZ 32
26 #define MAXMATCH 256
27 #define THRESHOLD 3
28 #define CODE_BIT 16
29 #define UINT8_MAX 0xff
30 #define BAD_TABLE - 1
31
32 //
33 // C: Char&Len Set; P: Position Set; T: exTra Set
34 //
35 #define NC (0xff + MAXMATCH + 2 - THRESHOLD)
36 #define CBIT 9
37 #define MAXPBIT 5
38 #define TBIT 5
39 #define MAXNP ((1U << MAXPBIT) - 1)
40 #define NT (CODE_BIT + 3)
41 #if NT > MAXNP
42 #define NPT NT
43 #else
44 #define NPT MAXNP
45 #endif
46
47 typedef struct {
48 UINT8 *mSrcBase; // Starting address of compressed data
49 UINT8 *mDstBase; // Starting address of decompressed data
50 UINT32 mOutBuf;
51 UINT32 mInBuf;
52
53 UINT16 mBitCount;
54 UINT32 mBitBuf;
55 UINT32 mSubBitBuf;
56 UINT16 mBlockSize;
57 UINT32 mCompSize;
58 UINT32 mOrigSize;
59
60 UINT16 mBadTableFlag;
61
62 UINT16 mLeft[2 * NC - 1];
63 UINT16 mRight[2 * NC - 1];
64 UINT8 mCLen[NC];
65 UINT8 mPTLen[NPT];
66 UINT16 mCTable[4096];
67 UINT16 mPTTable[256];
68
69 //
70 // The length of the field 'Position Set Code Length Array Size' in Block Header.
71 // For EFI 1.1 de/compression algorithm, mPBit = 4
72 // For Tiano de/compression algorithm, mPBit = 5
73 //
74 UINT8 mPBit;
75 } SCRATCH_DATA;
76
77 STATIC
78 VOID
79 FillBuf (
80 IN SCRATCH_DATA *Sd,
81 IN UINT16 NumOfBits
82 )
83 /*++
84
85 Routine Description:
86
87 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
88
89 Arguments:
90
91 Sd - The global scratch data
92 NumOfBits - The number of bits to shift and read.
93
94 Returns: (VOID)
95
96 --*/
97 {
98 Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
99
100 while (NumOfBits > Sd->mBitCount) {
101
102 Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));
103
104 if (Sd->mCompSize > 0) {
105 //
106 // Get 1 byte into SubBitBuf
107 //
108 Sd->mCompSize--;
109 Sd->mSubBitBuf = 0;
110 Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
111 Sd->mBitCount = 8;
112
113 } else {
114 //
115 // No more bits from the source, just pad zero bit.
116 //
117 Sd->mSubBitBuf = 0;
118 Sd->mBitCount = 8;
119
120 }
121 }
122
123 Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);
124 Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;
125 }
126
127 STATIC
128 UINT32
129 GetBits (
130 IN SCRATCH_DATA *Sd,
131 IN UINT16 NumOfBits
132 )
133 /*++
134
135 Routine Description:
136
137 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
138 NumOfBits of bits from source. Returns NumOfBits of bits that are
139 popped out.
140
141 Arguments:
142
143 Sd - The global scratch data.
144 NumOfBits - The number of bits to pop and read.
145
146 Returns:
147
148 The bits that are popped out.
149
150 --*/
151 {
152 UINT32 OutBits;
153
154 OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));
155
156 FillBuf (Sd, NumOfBits);
157
158 return OutBits;
159 }
160
161 STATIC
162 UINT16
163 MakeTable (
164 IN SCRATCH_DATA *Sd,
165 IN UINT16 NumOfChar,
166 IN UINT8 *BitLen,
167 IN UINT16 TableBits,
168 OUT UINT16 *Table
169 )
170 /*++
171
172 Routine Description:
173
174 Creates Huffman Code mapping table according to code length array.
175
176 Arguments:
177
178 Sd - The global scratch data
179 NumOfChar - Number of symbols in the symbol set
180 BitLen - Code length array
181 TableBits - The width of the mapping table
182 Table - The table
183
184 Returns:
185
186 0 - OK.
187 BAD_TABLE - The table is corrupted.
188
189 --*/
190 {
191 UINT16 Count[17];
192 UINT16 Weight[17];
193 UINT16 Start[18];
194 UINT16 *Pointer;
195 UINT16 Index3;
196 UINT16 Index;
197 UINT16 Len;
198 UINT16 Char;
199 UINT16 JuBits;
200 UINT16 Avail;
201 UINT16 NextCode;
202 UINT16 Mask;
203
204 SetMem (&Count[1], sizeof(UINT16) * 16, 0);
205
206 for (Index = 0; Index < NumOfChar; Index++) {
207 Count[BitLen[Index]]++;
208 }
209
210 Start[1] = 0;
211
212 for (Index = 1; Index <= 16; Index++) {
213 Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
214 }
215
216 if (Start[17] != 0) {
217 /*(1U << 16)*/
218 return (UINT16) BAD_TABLE;
219 }
220
221 JuBits = (UINT16) (16 - TableBits);
222
223 for (Index = 1; Index <= TableBits; Index++) {
224 Start[Index] >>= JuBits;
225 Weight[Index] = (UINT16) (1U << (TableBits - Index));
226 }
227
228 while (Index <= 16) {
229 Weight[Index++] = (UINT16) (1U << (16 - Index));
230 }
231
232 Index = (UINT16) (Start[TableBits + 1] >> JuBits);
233
234 if (Index != 0) {
235 Index3 = (UINT16) (1U << TableBits);
236 SetMem(&Table[Index], sizeof(UINT16) * (Index3 - Index + 1), 0);
237 }
238
239 Avail = NumOfChar;
240 Mask = (UINT16) (1U << (15 - TableBits));
241
242 for (Char = 0; Char < NumOfChar; Char++) {
243
244 Len = BitLen[Char];
245 if (Len == 0) {
246 continue;
247 }
248
249 NextCode = (UINT16) (Start[Len] + Weight[Len]);
250
251 if (Len <= TableBits) {
252
253 for (Index = Start[Len]; Index < NextCode; Index++) {
254 Table[Index] = Char;
255 }
256
257 } else {
258
259 Index3 = Start[Len];
260 Pointer = &Table[Index3 >> JuBits];
261 Index = (UINT16) (Len - TableBits);
262
263 while (Index != 0) {
264 if (*Pointer == 0) {
265 Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
266 *Pointer = Avail++;
267 }
268
269 if (Index3 & Mask) {
270 Pointer = &Sd->mRight[*Pointer];
271 } else {
272 Pointer = &Sd->mLeft[*Pointer];
273 }
274
275 Index3 <<= 1;
276 Index--;
277 }
278
279 *Pointer = Char;
280
281 }
282
283 Start[Len] = NextCode;
284 }
285 //
286 // Succeeds
287 //
288 return 0;
289 }
290
291 STATIC
292 UINT32
293 DecodeP (
294 IN SCRATCH_DATA *Sd
295 )
296 /*++
297
298 Routine Description:
299
300 Decodes a position value.
301
302 Arguments:
303
304 Sd - the global scratch data
305
306 Returns:
307
308 The position value decoded.
309
310 --*/
311 {
312 UINT16 Val;
313 UINT32 Mask;
314 UINT32 Pos;
315
316 Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
317
318 if (Val >= MAXNP) {
319 Mask = 1U << (BITBUFSIZ - 1 - 8);
320
321 do {
322
323 if (Sd->mBitBuf & Mask) {
324 Val = Sd->mRight[Val];
325 } else {
326 Val = Sd->mLeft[Val];
327 }
328
329 Mask >>= 1;
330 } while (Val >= MAXNP);
331 }
332 //
333 // Advance what we have read
334 //
335 FillBuf (Sd, Sd->mPTLen[Val]);
336
337 Pos = Val;
338 if (Val > 1) {
339 Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));
340 }
341
342 return Pos;
343 }
344
345 STATIC
346 UINT16
347 ReadPTLen (
348 IN SCRATCH_DATA *Sd,
349 IN UINT16 nn,
350 IN UINT16 nbit,
351 IN UINT16 Special
352 )
353 /*++
354
355 Routine Description:
356
357 Reads code lengths for the Extra Set or the Position Set
358
359 Arguments:
360
361 Sd - The global scratch data
362 nn - Number of symbols
363 nbit - Number of bits needed to represent nn
364 Special - The special symbol that needs to be taken care of
365
366 Returns:
367
368 0 - OK.
369 BAD_TABLE - Table is corrupted.
370
371 --*/
372 {
373 UINT16 Number;
374 UINT16 CharC;
375 UINT16 Index;
376 UINT32 Mask;
377
378 Number = (UINT16) GetBits (Sd, nbit);
379
380 if (Number == 0) {
381 CharC = (UINT16) GetBits (Sd, nbit);
382
383 for (Index = 0; Index < 256; Index++) {
384 Sd->mPTTable[Index] = CharC;
385 }
386
387 SetMem ((VOID*) &Sd->mPTLen, nn * sizeof(UINT8), 0);
388
389 return 0;
390 }
391
392 Index = 0;
393
394 while (Index < Number) {
395
396 CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
397
398 if (CharC == 7) {
399 Mask = 1U << (BITBUFSIZ - 1 - 3);
400 while (Mask & Sd->mBitBuf) {
401 Mask >>= 1;
402 CharC += 1;
403 }
404 }
405
406 FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
407
408 Sd->mPTLen[Index++] = (UINT8) CharC;
409
410 if (Index == Special) {
411 CharC = (UINT16) GetBits (Sd, 2);
412 while ((INT16) (--CharC) >= 0) {
413 Sd->mPTLen[Index++] = 0;
414 }
415 }
416 }
417
418 SetMem ((VOID*) &Sd->mPTLen[Index], (nn - Index) * sizeof(UINT8), 0);
419 return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
420 }
421
422 STATIC
423 VOID
424 ReadCLen (
425 SCRATCH_DATA *Sd
426 )
427 /*++
428
429 Routine Description:
430
431 Reads code lengths for Char&Len Set.
432
433 Arguments:
434
435 Sd - the global scratch data
436
437 Returns: (VOID)
438
439 --*/
440 {
441 UINT16 Number;
442 UINT16 CharC;
443 UINT16 Index;
444 UINT32 Mask;
445
446 Number = (UINT16) GetBits (Sd, CBIT);
447
448 if (Number == 0) {
449 CharC = (UINT16) GetBits (Sd, CBIT);
450
451 SetMem ((VOID*)&Sd->mCLen, sizeof(UINT8) * NC, 0);
452
453 for (Index = 0; Index < 4096; Index++) {
454 Sd->mCTable[Index] = CharC;
455 }
456
457 return ;
458 }
459
460 Index = 0;
461 while (Index < Number) {
462
463 CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
464 if (CharC >= NT) {
465 Mask = 1U << (BITBUFSIZ - 1 - 8);
466
467 do {
468
469 if (Mask & Sd->mBitBuf) {
470 CharC = Sd->mRight[CharC];
471 } else {
472 CharC = Sd->mLeft[CharC];
473 }
474
475 Mask >>= 1;
476
477 } while (CharC >= NT);
478 }
479 //
480 // Advance what we have read
481 //
482 FillBuf (Sd, Sd->mPTLen[CharC]);
483
484 if (CharC <= 2) {
485
486 if (CharC == 0) {
487 CharC = 1;
488 } else if (CharC == 1) {
489 CharC = (UINT16) (GetBits (Sd, 4) + 3);
490 } else if (CharC == 2) {
491 CharC = (UINT16) (GetBits (Sd, CBIT) + 20);
492 }
493
494 while ((INT16) (--CharC) >= 0) {
495 Sd->mCLen[Index++] = 0;
496 }
497
498 } else {
499
500 Sd->mCLen[Index++] = (UINT8) (CharC - 2);
501
502 }
503 }
504
505 SetMem ((VOID*) &Sd->mCLen[Index], sizeof(UINT8) * (NC - Index), 0);
506
507 MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);
508
509 return ;
510 }
511
512 STATIC
513 UINT16
514 DecodeC (
515 SCRATCH_DATA *Sd
516 )
517 /*++
518
519 Routine Description:
520
521 Decode a character/length value.
522
523 Arguments:
524
525 Sd - The global scratch data.
526
527 Returns:
528
529 The value decoded.
530
531 --*/
532 {
533 UINT16 Index2;
534 UINT32 Mask;
535
536 if (Sd->mBlockSize == 0) {
537 //
538 // Starting a new block
539 //
540 Sd->mBlockSize = (UINT16) GetBits (Sd, 16);
541 Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);
542 if (Sd->mBadTableFlag != 0) {
543 return 0;
544 }
545
546 ReadCLen (Sd);
547
548 Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));
549 if (Sd->mBadTableFlag != 0) {
550 return 0;
551 }
552 }
553
554 Sd->mBlockSize--;
555 Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];
556
557 if (Index2 >= NC) {
558 Mask = 1U << (BITBUFSIZ - 1 - 12);
559
560 do {
561 if (Sd->mBitBuf & Mask) {
562 Index2 = Sd->mRight[Index2];
563 } else {
564 Index2 = Sd->mLeft[Index2];
565 }
566
567 Mask >>= 1;
568 } while (Index2 >= NC);
569 }
570 //
571 // Advance what we have read
572 //
573 FillBuf (Sd, Sd->mCLen[Index2]);
574
575 return Index2;
576 }
577
578 STATIC
579 VOID
580 Decode (
581 SCRATCH_DATA *Sd
582 )
583 /*++
584
585 Routine Description:
586
587 Decode the source data and put the resulting data into the destination buffer.
588
589 Arguments:
590
591 Sd - The global scratch data
592
593 Returns: (VOID)
594
595 --*/
596 {
597 UINT16 BytesRemain;
598 UINT32 DataIdx;
599 UINT16 CharC;
600
601 BytesRemain = (UINT16) (-1);
602
603 DataIdx = 0;
604
605 for (;;) {
606 CharC = DecodeC (Sd);
607 if (Sd->mBadTableFlag != 0) {
608 return ;
609 }
610
611 if (CharC < 256) {
612 //
613 // Process an Original character
614 //
615 if (Sd->mOutBuf >= Sd->mOrigSize) {
616 return ;
617 } else {
618 Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;
619 }
620
621 } else {
622 //
623 // Process a Pointer
624 //
625 CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));
626
627 BytesRemain = CharC;
628
629 DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;
630
631 BytesRemain--;
632 while ((INT16) (BytesRemain) >= 0) {
633 Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
634 if (Sd->mOutBuf >= Sd->mOrigSize) {
635 return ;
636 }
637
638 BytesRemain--;
639 }
640 }
641 }
642
643 return ;
644 }
645
646 EFI_STATUS
647 GetInfo (
648 IN VOID *Source,
649 IN UINT32 SrcSize,
650 OUT UINT32 *DstSize,
651 OUT UINT32 *ScratchSize
652 )
653 /*++
654
655 Routine Description:
656
657 The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
658
659 Arguments:
660
661 Source - The source buffer containing the compressed data.
662 SrcSize - The size of source buffer
663 DstSize - The size of destination buffer.
664 ScratchSize - The size of scratch buffer.
665
666 Returns:
667
668 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
669 EFI_INVALID_PARAMETER - The source data is corrupted
670
671 --*/
672 {
673 UINT8 *Src;
674
675 *ScratchSize = sizeof (SCRATCH_DATA);
676
677 Src = Source;
678 if (SrcSize < 8) {
679 return EFI_INVALID_PARAMETER;
680 }
681
682 *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
683 return EFI_SUCCESS;
684 }
685
686 EFI_STATUS
687 Decompress (
688 IN VOID *Source,
689 IN UINT32 SrcSize,
690 IN OUT VOID *Destination,
691 IN UINT32 DstSize,
692 IN OUT VOID *Scratch,
693 IN UINT32 ScratchSize,
694 IN UINT8 Version
695 )
696 /*++
697
698 Routine Description:
699
700 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
701
702 Arguments:
703
704 Source - The source buffer containing the compressed data.
705 SrcSize - The size of source buffer
706 Destination - The destination buffer to store the decompressed data
707 DstSize - The size of destination buffer.
708 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
709 ScratchSize - The size of scratch buffer.
710 Version - The version of de/compression algorithm.
711 Version 1 for EFI 1.1 de/compression algorithm.
712 Version 2 for Tiano de/compression algorithm.
713
714 Returns:
715
716 EFI_SUCCESS - Decompression is successfull
717 EFI_INVALID_PARAMETER - The source data is corrupted
718
719 --*/
720 {
721 UINT32 CompSize;
722 UINT32 OrigSize;
723 EFI_STATUS Status;
724 SCRATCH_DATA *Sd;
725 UINT8 *Src;
726 UINT8 *Dst;
727
728 Status = EFI_SUCCESS;
729 Src = Source;
730 Dst = Destination;
731
732 if (ScratchSize < sizeof (SCRATCH_DATA)) {
733 return EFI_INVALID_PARAMETER;
734 }
735
736 Sd = (SCRATCH_DATA *) Scratch;
737
738 if (SrcSize < 8) {
739 return EFI_INVALID_PARAMETER;
740 }
741
742 CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
743 OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
744
745 //
746 // If compressed file size is 0, return
747 //
748 if (OrigSize == 0) {
749 return Status;
750 }
751
752 if (SrcSize < CompSize + 8) {
753 return EFI_INVALID_PARAMETER;
754 }
755
756 if (DstSize != OrigSize) {
757 return EFI_INVALID_PARAMETER;
758 }
759
760 Src = Src + 8;
761
762 SetMem ((VOID*) Sd, sizeof(SCRATCH_DATA), 0);
763
764 //
765 // The length of the field 'Position Set Code Length Array Size' in Block Header.
766 // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4
767 // For Tiano de/compression algorithm(Version 2), mPBit = 5
768 //
769 switch (Version) {
770 case 1:
771 Sd->mPBit = 4;
772 break;
773
774 case 2:
775 Sd->mPBit = 5;
776 break;
777
778 default:
779 //
780 // Currently, only have 2 versions
781 //
782 return EFI_INVALID_PARAMETER;
783 }
784
785 Sd->mSrcBase = Src;
786 Sd->mDstBase = Dst;
787 Sd->mCompSize = CompSize;
788 Sd->mOrigSize = OrigSize;
789
790 //
791 // Fill the first BITBUFSIZ bits
792 //
793 FillBuf (Sd, BITBUFSIZ);
794
795 //
796 // Decompress it
797 //
798 Decode (Sd);
799
800 if (Sd->mBadTableFlag != 0) {
801 //
802 // Something wrong with the source
803 //
804 Status = EFI_INVALID_PARAMETER;
805 }
806
807 return Status;
808 }
809
810 EFI_STATUS
811 EFIAPI
812 EfiGetInfo (
813 IN VOID *Source,
814 IN UINT32 SrcSize,
815 OUT UINT32 *DstSize,
816 OUT UINT32 *ScratchSize
817 )
818 /*++
819
820 Routine Description:
821
822 The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo().
823
824 Arguments:
825
826 This - The protocol instance pointer
827 Source - The source buffer containing the compressed data.
828 SrcSize - The size of source buffer
829 DstSize - The size of destination buffer.
830 ScratchSize - The size of scratch buffer.
831
832 Returns:
833
834 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
835 EFI_INVALID_PARAMETER - The source data is corrupted
836
837 --*/
838 {
839 return GetInfo (
840 Source,
841 SrcSize,
842 DstSize,
843 ScratchSize
844 );
845 }
846
847 EFI_STATUS
848 EFIAPI
849 EfiDecompress (
850 IN VOID *Source,
851 IN UINT32 SrcSize,
852 IN OUT VOID *Destination,
853 IN UINT32 DstSize,
854 IN OUT VOID *Scratch,
855 IN UINT32 ScratchSize
856 )
857 /*++
858
859 Routine Description:
860
861 The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().
862
863 Arguments:
864
865 This - The protocol instance pointer
866 Source - The source buffer containing the compressed data.
867 SrcSize - The size of source buffer
868 Destination - The destination buffer to store the decompressed data
869 DstSize - The size of destination buffer.
870 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
871 ScratchSize - The size of scratch buffer.
872
873 Returns:
874
875 EFI_SUCCESS - Decompression is successfull
876 EFI_INVALID_PARAMETER - The source data is corrupted
877
878 --*/
879 {
880 //
881 // For EFI 1.1 de/compression algorithm, the version is 1.
882 //
883 return Decompress (
884 Source,
885 SrcSize,
886 Destination,
887 DstSize,
888 Scratch,
889 ScratchSize,
890 1
891 );
892 }
893
894 EFI_STATUS
895 EFIAPI
896 TianoGetInfo (
897 IN VOID *Source,
898 IN UINT32 SrcSize,
899 OUT UINT32 *DstSize,
900 OUT UINT32 *ScratchSize
901 )
902 /*++
903
904 Routine Description:
905
906 The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().
907
908 Arguments:
909
910 This - The protocol instance pointer
911 Source - The source buffer containing the compressed data.
912 SrcSize - The size of source buffer
913 DstSize - The size of destination buffer.
914 ScratchSize - The size of scratch buffer.
915
916 Returns:
917
918 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
919 EFI_INVALID_PARAMETER - The source data is corrupted
920
921 --*/
922 {
923 return GetInfo (
924 Source,
925 SrcSize,
926 DstSize,
927 ScratchSize
928 );
929 }
930
931 EFI_STATUS
932 EFIAPI
933 TianoDecompress (
934 IN VOID *Source,
935 IN UINT32 SrcSize,
936 IN OUT VOID *Destination,
937 IN UINT32 DstSize,
938 IN OUT VOID *Scratch,
939 IN UINT32 ScratchSize
940 )
941 /*++
942
943 Routine Description:
944
945 The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
946
947 Arguments:
948
949 This - The protocol instance pointer
950 Source - The source buffer containing the compressed data.
951 SrcSize - The size of source buffer
952 Destination - The destination buffer to store the decompressed data
953 DstSize - The size of destination buffer.
954 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
955 ScratchSize - The size of scratch buffer.
956
957 Returns:
958
959 EFI_SUCCESS - Decompression is successfull
960 EFI_INVALID_PARAMETER - The source data is corrupted
961
962 --*/
963 {
964 //
965 // For Tiano de/compression algorithm, the version is 2.
966 //
967 return Decompress (
968 Source,
969 SrcSize,
970 Destination,
971 DstSize,
972 Scratch,
973 ScratchSize,
974 2
975 );
976 }
977