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