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