]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/EfiLdr/TianoDecompress.c
Fix bundle of issue for ICC build
[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 }
636
637 EFI_STATUS
638 GetInfo (
639 IN VOID *Source,
640 IN UINT32 SrcSize,
641 OUT UINT32 *DstSize,
642 OUT UINT32 *ScratchSize
643 )
644 /*++
645
646 Routine Description:
647
648 The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
649
650 Arguments:
651
652 Source - The source buffer containing the compressed data.
653 SrcSize - The size of source buffer
654 DstSize - The size of destination buffer.
655 ScratchSize - The size of scratch buffer.
656
657 Returns:
658
659 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
660 EFI_INVALID_PARAMETER - The source data is corrupted
661
662 --*/
663 {
664 UINT8 *Src;
665
666 *ScratchSize = sizeof (SCRATCH_DATA);
667
668 Src = Source;
669 if (SrcSize < 8) {
670 return EFI_INVALID_PARAMETER;
671 }
672
673 *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
674 return EFI_SUCCESS;
675 }
676
677 EFI_STATUS
678 Decompress (
679 IN VOID *Source,
680 IN UINT32 SrcSize,
681 IN OUT VOID *Destination,
682 IN UINT32 DstSize,
683 IN OUT VOID *Scratch,
684 IN UINT32 ScratchSize,
685 IN UINT8 Version
686 )
687 /*++
688
689 Routine Description:
690
691 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
692
693 Arguments:
694
695 Source - The source buffer containing the compressed data.
696 SrcSize - The size of source buffer
697 Destination - The destination buffer to store the decompressed data
698 DstSize - The size of destination buffer.
699 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
700 ScratchSize - The size of scratch buffer.
701 Version - The version of de/compression algorithm.
702 Version 1 for EFI 1.1 de/compression algorithm.
703 Version 2 for Tiano de/compression algorithm.
704
705 Returns:
706
707 EFI_SUCCESS - Decompression is successfull
708 EFI_INVALID_PARAMETER - The source data is corrupted
709
710 --*/
711 {
712 UINT32 CompSize;
713 UINT32 OrigSize;
714 EFI_STATUS Status;
715 SCRATCH_DATA *Sd;
716 UINT8 *Src;
717 UINT8 *Dst;
718
719 Status = EFI_SUCCESS;
720 Src = Source;
721 Dst = Destination;
722
723 if (ScratchSize < sizeof (SCRATCH_DATA)) {
724 return EFI_INVALID_PARAMETER;
725 }
726
727 Sd = (SCRATCH_DATA *) Scratch;
728
729 if (SrcSize < 8) {
730 return EFI_INVALID_PARAMETER;
731 }
732
733 CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
734 OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
735
736 //
737 // If compressed file size is 0, return
738 //
739 if (OrigSize == 0) {
740 return Status;
741 }
742
743 if (SrcSize < CompSize + 8) {
744 return EFI_INVALID_PARAMETER;
745 }
746
747 if (DstSize != OrigSize) {
748 return EFI_INVALID_PARAMETER;
749 }
750
751 Src = Src + 8;
752
753 SetMem ((VOID*) Sd, sizeof(SCRATCH_DATA), 0);
754
755 //
756 // The length of the field 'Position Set Code Length Array Size' in Block Header.
757 // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4
758 // For Tiano de/compression algorithm(Version 2), mPBit = 5
759 //
760 switch (Version) {
761 case 1:
762 Sd->mPBit = 4;
763 break;
764
765 case 2:
766 Sd->mPBit = 5;
767 break;
768
769 default:
770 //
771 // Currently, only have 2 versions
772 //
773 return EFI_INVALID_PARAMETER;
774 }
775
776 Sd->mSrcBase = Src;
777 Sd->mDstBase = Dst;
778 Sd->mCompSize = CompSize;
779 Sd->mOrigSize = OrigSize;
780
781 //
782 // Fill the first BITBUFSIZ bits
783 //
784 FillBuf (Sd, BITBUFSIZ);
785
786 //
787 // Decompress it
788 //
789 Decode (Sd);
790
791 if (Sd->mBadTableFlag != 0) {
792 //
793 // Something wrong with the source
794 //
795 Status = EFI_INVALID_PARAMETER;
796 }
797
798 return Status;
799 }
800
801 EFI_STATUS
802 EFIAPI
803 EfiGetInfo (
804 IN VOID *Source,
805 IN UINT32 SrcSize,
806 OUT UINT32 *DstSize,
807 OUT UINT32 *ScratchSize
808 )
809 /*++
810
811 Routine Description:
812
813 The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo().
814
815 Arguments:
816
817 This - The protocol instance pointer
818 Source - The source buffer containing the compressed data.
819 SrcSize - The size of source buffer
820 DstSize - The size of destination buffer.
821 ScratchSize - The size of scratch buffer.
822
823 Returns:
824
825 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
826 EFI_INVALID_PARAMETER - The source data is corrupted
827
828 --*/
829 {
830 return GetInfo (
831 Source,
832 SrcSize,
833 DstSize,
834 ScratchSize
835 );
836 }
837
838 EFI_STATUS
839 EFIAPI
840 EfiDecompress (
841 IN VOID *Source,
842 IN UINT32 SrcSize,
843 IN OUT VOID *Destination,
844 IN UINT32 DstSize,
845 IN OUT VOID *Scratch,
846 IN UINT32 ScratchSize
847 )
848 /*++
849
850 Routine Description:
851
852 The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().
853
854 Arguments:
855
856 This - The protocol instance pointer
857 Source - The source buffer containing the compressed data.
858 SrcSize - The size of source buffer
859 Destination - The destination buffer to store the decompressed data
860 DstSize - The size of destination buffer.
861 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
862 ScratchSize - The size of scratch buffer.
863
864 Returns:
865
866 EFI_SUCCESS - Decompression is successfull
867 EFI_INVALID_PARAMETER - The source data is corrupted
868
869 --*/
870 {
871 //
872 // For EFI 1.1 de/compression algorithm, the version is 1.
873 //
874 return Decompress (
875 Source,
876 SrcSize,
877 Destination,
878 DstSize,
879 Scratch,
880 ScratchSize,
881 1
882 );
883 }
884
885 EFI_STATUS
886 EFIAPI
887 TianoGetInfo (
888 IN VOID *Source,
889 IN UINT32 SrcSize,
890 OUT UINT32 *DstSize,
891 OUT UINT32 *ScratchSize
892 )
893 /*++
894
895 Routine Description:
896
897 The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().
898
899 Arguments:
900
901 This - The protocol instance pointer
902 Source - The source buffer containing the compressed data.
903 SrcSize - The size of source buffer
904 DstSize - The size of destination buffer.
905 ScratchSize - The size of scratch buffer.
906
907 Returns:
908
909 EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
910 EFI_INVALID_PARAMETER - The source data is corrupted
911
912 --*/
913 {
914 return GetInfo (
915 Source,
916 SrcSize,
917 DstSize,
918 ScratchSize
919 );
920 }
921
922 EFI_STATUS
923 EFIAPI
924 TianoDecompress (
925 IN VOID *Source,
926 IN UINT32 SrcSize,
927 IN OUT VOID *Destination,
928 IN UINT32 DstSize,
929 IN OUT VOID *Scratch,
930 IN UINT32 ScratchSize
931 )
932 /*++
933
934 Routine Description:
935
936 The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
937
938 Arguments:
939
940 This - The protocol instance pointer
941 Source - The source buffer containing the compressed data.
942 SrcSize - The size of source buffer
943 Destination - The destination buffer to store the decompressed data
944 DstSize - The size of destination buffer.
945 Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
946 ScratchSize - The size of scratch buffer.
947
948 Returns:
949
950 EFI_SUCCESS - Decompression is successfull
951 EFI_INVALID_PARAMETER - The source data is corrupted
952
953 --*/
954 {
955 //
956 // For Tiano de/compression algorithm, the version is 2.
957 //
958 return Decompress (
959 Source,
960 SrcSize,
961 Destination,
962 DstSize,
963 Scratch,
964 ScratchSize,
965 2
966 );
967 }
968