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