]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
Add some function/header comments.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
1 /**@file
2 UEFI and Custom Decompress Library
3 The function of UefiTianoDecompress() is interface for this module,
4 it will do tiano or uefi decompress with different verison parameter.
5 See EFI specification 1.1 Chapter 17 to get LZ77 compress/decompress.
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #include <Guid/CustomDecompress.h>
19 #include "BaseUefiTianoCustomDecompressLibInternals.h"
20
21 /**
22 Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
23
24 @param Sd The global scratch data
25 @param NumOfBits The number of bits to shift and read.
26 **/
27 VOID
28 FillBuf (
29 IN SCRATCH_DATA *Sd,
30 IN UINT16 NumOfBits
31 )
32 {
33 Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
34
35 while (NumOfBits > Sd->mBitCount) {
36
37 Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));
38
39 if (Sd->mCompSize > 0) {
40 //
41 // Get 1 byte into SubBitBuf
42 //
43 Sd->mCompSize--;
44 Sd->mSubBitBuf = 0;
45 Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
46 Sd->mBitCount = 8;
47
48 } else {
49 //
50 // No more bits from the source, just pad zero bit.
51 //
52 Sd->mSubBitBuf = 0;
53 Sd->mBitCount = 8;
54
55 }
56 }
57
58 Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);
59 Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;
60 }
61
62 /**
63 Get NumOfBits of bits out from mBitBuf
64
65 Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
66 NumOfBits of bits from source. Returns NumOfBits of bits that are
67 popped out.
68
69 @param Sd The global scratch data.
70 @param NumOfBits The number of bits to pop and read.
71
72 @return The bits that are popped out.
73
74 **/
75 UINT32
76 GetBits (
77 IN SCRATCH_DATA *Sd,
78 IN UINT16 NumOfBits
79 )
80 {
81 UINT32 OutBits;
82
83 OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));
84
85 FillBuf (Sd, NumOfBits);
86
87 return OutBits;
88 }
89
90 /**
91 Creates Huffman Code mapping table according to code length array.
92
93 Creates Huffman Code mapping table for Extra Set, Char&Len Set
94 and Position Set according to code length array.
95
96 @param Sd The global scratch data
97 @param NumOfChar Number of symbols in the symbol set
98 @param BitLen Code length array
99 @param TableBits The width of the mapping table
100 @param Table The table
101
102 @retval 0 OK.
103 @retval BAD_TABLE The table is corrupted.
104
105 **/
106 UINT16
107 MakeTable (
108 IN SCRATCH_DATA *Sd,
109 IN UINT16 NumOfChar,
110 IN UINT8 *BitLen,
111 IN UINT16 TableBits,
112 OUT UINT16 *Table
113 )
114 {
115 UINT16 Count[17];
116 UINT16 Weight[17];
117 UINT16 Start[18];
118 UINT16 *Pointer;
119 UINT16 Index3;
120 volatile UINT16 Index;
121 UINT16 Len;
122 UINT16 Char;
123 UINT16 JuBits;
124 UINT16 Avail;
125 UINT16 NextCode;
126 UINT16 Mask;
127 UINT16 WordOfStart;
128 UINT16 WordOfCount;
129
130 for (Index = 1; Index <= 16; Index++) {
131 Count[Index] = 0;
132 }
133
134 for (Index = 0; Index < NumOfChar; Index++) {
135 Count[BitLen[Index]]++;
136 }
137
138 Start[1] = 0;
139
140 for (Index = 1; Index <= 16; Index++) {
141 WordOfStart = Start[Index];
142 WordOfCount = Count[Index];
143 Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index)));
144 }
145
146 if (Start[17] != 0) {
147 /*(1U << 16)*/
148 return (UINT16) BAD_TABLE;
149 }
150
151 JuBits = (UINT16) (16 - TableBits);
152
153 for (Index = 1; Index <= TableBits; Index++) {
154 Start[Index] >>= JuBits;
155 Weight[Index] = (UINT16) (1U << (TableBits - Index));
156 }
157
158 while (Index <= 16) {
159 Weight[Index] = (UINT16) (1U << (16 - Index));
160 Index++;
161 }
162
163 Index = (UINT16) (Start[TableBits + 1] >> JuBits);
164
165 if (Index != 0) {
166 Index3 = (UINT16) (1U << TableBits);
167 while (Index != Index3) {
168 Table[Index++] = 0;
169 }
170 }
171
172 Avail = NumOfChar;
173 Mask = (UINT16) (1U << (15 - TableBits));
174
175 for (Char = 0; Char < NumOfChar; Char++) {
176
177 Len = BitLen[Char];
178 if (Len == 0) {
179 continue;
180 }
181
182 NextCode = (UINT16) (Start[Len] + Weight[Len]);
183
184 if (Len <= TableBits) {
185
186 for (Index = Start[Len]; Index < NextCode; Index++) {
187 Table[Index] = Char;
188 }
189
190 } else {
191
192 Index3 = Start[Len];
193 Pointer = &Table[Index3 >> JuBits];
194 Index = (UINT16) (Len - TableBits);
195
196 while (Index != 0) {
197 if (*Pointer == 0) {
198 Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
199 *Pointer = Avail++;
200 }
201
202 if (Index3 & Mask) {
203 Pointer = &Sd->mRight[*Pointer];
204 } else {
205 Pointer = &Sd->mLeft[*Pointer];
206 }
207
208 Index3 <<= 1;
209 Index--;
210 }
211
212 *Pointer = Char;
213
214 }
215
216 Start[Len] = NextCode;
217 }
218 //
219 // Succeeds
220 //
221 return 0;
222 }
223
224 /**
225 Decodes a position value.
226
227 @param Sd the global scratch data
228
229 @return The position value decoded.
230 **/
231 UINT32
232 DecodeP (
233 IN SCRATCH_DATA *Sd
234 )
235 {
236 UINT16 Val;
237 UINT32 Mask;
238 UINT32 Pos;
239
240 Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
241
242 if (Val >= MAXNP) {
243 Mask = 1U << (BITBUFSIZ - 1 - 8);
244
245 do {
246
247 if (Sd->mBitBuf & Mask) {
248 Val = Sd->mRight[Val];
249 } else {
250 Val = Sd->mLeft[Val];
251 }
252
253 Mask >>= 1;
254 } while (Val >= MAXNP);
255 }
256 //
257 // Advance what we have read
258 //
259 FillBuf (Sd, Sd->mPTLen[Val]);
260
261 Pos = Val;
262 if (Val > 1) {
263 Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));
264 }
265
266 return Pos;
267 }
268
269 /**
270 Reads code lengths for the Extra Set or the Position Set.
271
272 Read in the Extra Set or Pointion Set Length Arrary, then
273 generate the Huffman code mapping for them.
274
275 @param Sd The global scratch data.
276 @param nn Number of symbols.
277 @param nbit Number of bits needed to represent nn.
278 @param Special The special symbol that needs to be taken care of.
279
280 @retval 0 OK.
281 @retval BAD_TABLE Table is corrupted.
282
283 **/
284 UINT16
285 ReadPTLen (
286 IN SCRATCH_DATA *Sd,
287 IN UINT16 nn,
288 IN UINT16 nbit,
289 IN UINT16 Special
290 )
291 {
292 UINT16 Number;
293 UINT16 CharC;
294 volatile UINT16 Index;
295 UINT32 Mask;
296
297 Number = (UINT16) GetBits (Sd, nbit);
298
299 if (Number == 0) {
300 CharC = (UINT16) GetBits (Sd, nbit);
301
302 for (Index = 0; Index < 256; Index++) {
303 Sd->mPTTable[Index] = CharC;
304 }
305
306 for (Index = 0; Index < nn; Index++) {
307 Sd->mPTLen[Index] = 0;
308 }
309
310 return 0;
311 }
312
313 Index = 0;
314
315 while (Index < Number) {
316
317 CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
318
319 if (CharC == 7) {
320 Mask = 1U << (BITBUFSIZ - 1 - 3);
321 while (Mask & Sd->mBitBuf) {
322 Mask >>= 1;
323 CharC += 1;
324 }
325 }
326
327 FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
328
329 Sd->mPTLen[Index++] = (UINT8) CharC;
330
331 if (Index == Special) {
332 CharC = (UINT16) GetBits (Sd, 2);
333 while ((INT16) (--CharC) >= 0) {
334 Sd->mPTLen[Index++] = 0;
335 }
336 }
337 }
338
339 while (Index < nn) {
340 Sd->mPTLen[Index++] = 0;
341 }
342
343 return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
344 }
345
346 /**
347 Reads code lengths for Char&Len Set.
348
349 Read in and decode the Char&Len Set Code Length Array, then
350 generate the Huffman Code mapping table for the Char&Len Set.
351
352 @param Sd the global scratch data
353
354 **/
355 VOID
356 ReadCLen (
357 SCRATCH_DATA *Sd
358 )
359 {
360 UINT16 Number;
361 UINT16 CharC;
362 volatile UINT16 Index;
363 UINT32 Mask;
364
365 Number = (UINT16) GetBits (Sd, CBIT);
366
367 if (Number == 0) {
368 CharC = (UINT16) GetBits (Sd, CBIT);
369
370 for (Index = 0; Index < NC; Index++) {
371 Sd->mCLen[Index] = 0;
372 }
373
374 for (Index = 0; Index < 4096; Index++) {
375 Sd->mCTable[Index] = CharC;
376 }
377
378 return ;
379 }
380
381 Index = 0;
382 while (Index < Number) {
383
384 CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
385 if (CharC >= NT) {
386 Mask = 1U << (BITBUFSIZ - 1 - 8);
387
388 do {
389
390 if (Mask & Sd->mBitBuf) {
391 CharC = Sd->mRight[CharC];
392 } else {
393 CharC = Sd->mLeft[CharC];
394 }
395
396 Mask >>= 1;
397
398 } while (CharC >= NT);
399 }
400 //
401 // Advance what we have read
402 //
403 FillBuf (Sd, Sd->mPTLen[CharC]);
404
405 if (CharC <= 2) {
406
407 if (CharC == 0) {
408 CharC = 1;
409 } else if (CharC == 1) {
410 CharC = (UINT16) (GetBits (Sd, 4) + 3);
411 } else if (CharC == 2) {
412 CharC = (UINT16) (GetBits (Sd, CBIT) + 20);
413 }
414
415 while ((INT16) (--CharC) >= 0) {
416 Sd->mCLen[Index++] = 0;
417 }
418
419 } else {
420
421 Sd->mCLen[Index++] = (UINT8) (CharC - 2);
422
423 }
424 }
425
426 while (Index < NC) {
427 Sd->mCLen[Index++] = 0;
428 }
429
430 MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);
431
432 return ;
433 }
434
435 /**
436 Decode a character/length value.
437
438 Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
439 Huffman code mapping table for Extra Set, Code&Len Set and
440 Position Set.
441
442 @param Sd The global scratch data.
443
444 @return The value decoded.
445
446 **/
447 UINT16
448 DecodeC (
449 SCRATCH_DATA *Sd
450 )
451 {
452 UINT16 Index2;
453 UINT32 Mask;
454
455 if (Sd->mBlockSize == 0) {
456 //
457 // Starting a new block
458 //
459 Sd->mBlockSize = (UINT16) GetBits (Sd, 16);
460 Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);
461 if (Sd->mBadTableFlag != 0) {
462 return 0;
463 }
464
465 ReadCLen (Sd);
466
467 Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));
468 if (Sd->mBadTableFlag != 0) {
469 return 0;
470 }
471 }
472
473 Sd->mBlockSize--;
474 Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];
475
476 if (Index2 >= NC) {
477 Mask = 1U << (BITBUFSIZ - 1 - 12);
478
479 do {
480 if (Sd->mBitBuf & Mask) {
481 Index2 = Sd->mRight[Index2];
482 } else {
483 Index2 = Sd->mLeft[Index2];
484 }
485
486 Mask >>= 1;
487 } while (Index2 >= NC);
488 }
489 //
490 // Advance what we have read
491 //
492 FillBuf (Sd, Sd->mCLen[Index2]);
493
494 return Index2;
495 }
496
497 /**
498 Decode the source data ad put the resulting data into the destination buffer.
499
500 @param Sd - The global scratch data
501 **/
502 VOID
503 Decode (
504 SCRATCH_DATA *Sd
505 )
506 {
507 UINT16 BytesRemain;
508 UINT32 DataIdx;
509 UINT16 CharC;
510
511 BytesRemain = (UINT16) (-1);
512
513 DataIdx = 0;
514
515 for (;;) {
516 CharC = DecodeC (Sd);
517 if (Sd->mBadTableFlag != 0) {
518 goto Done ;
519 }
520
521 if (CharC < 256) {
522 //
523 // Process an Original character
524 //
525 if (Sd->mOutBuf >= Sd->mOrigSize) {
526 goto Done ;
527 } else {
528 Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;
529 }
530
531 } else {
532 //
533 // Process a Pointer
534 //
535 CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));
536
537 BytesRemain = CharC;
538
539 DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;
540
541 BytesRemain--;
542 while ((INT16) (BytesRemain) >= 0) {
543 Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
544 if (Sd->mOutBuf >= Sd->mOrigSize) {
545 goto Done ;
546 }
547
548 BytesRemain--;
549 }
550 }
551 }
552
553 Done:
554 return ;
555 }
556
557 /**
558 The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
559
560 @param Source The source buffer containing the compressed data.
561 @param SourceSize The size of source buffer
562 @param DestinationSize The size of destination buffer.
563 @param ScratchSize The size of scratch buffer.
564
565 @retval RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
566 @retval RETURN_INVALID_PARAMETER - The source data is corrupted
567 **/
568 RETURN_STATUS
569 EFIAPI
570 UefiDecompressGetInfo (
571 IN CONST VOID *Source,
572 IN UINT32 SourceSize,
573 OUT UINT32 *DestinationSize,
574 OUT UINT32 *ScratchSize
575 )
576 {
577 UINT32 CompressedSize;
578
579 ASSERT (Source != NULL);
580 ASSERT (DestinationSize != NULL);
581 ASSERT (ScratchSize != NULL);
582
583 if (SourceSize < 8) {
584 return RETURN_INVALID_PARAMETER;
585 }
586
587 CompressedSize = *(UINT32 *) Source;
588 if (SourceSize < (CompressedSize + 8)) {
589 return RETURN_INVALID_PARAMETER;
590 }
591
592 *ScratchSize = sizeof (SCRATCH_DATA);
593 *DestinationSize = *((UINT32 *) Source + 1);
594
595 return RETURN_SUCCESS;
596 }
597
598 /**
599 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
600
601 @param Source The source buffer containing the compressed data.
602 @param Destination The destination buffer to store the decompressed data
603 @param Scratch The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
604 @param Version 1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm
605
606 @retval RETURN_SUCCESS Decompression is successfull
607 @retval RETURN_INVALID_PARAMETER The source data is corrupted
608 **/
609 RETURN_STATUS
610 EFIAPI
611 UefiTianoDecompress (
612 IN CONST VOID *Source,
613 IN OUT VOID *Destination,
614 IN OUT VOID *Scratch,
615 IN UINT32 Version
616 )
617 {
618 volatile UINT32 Index;
619 UINT32 CompSize;
620 UINT32 OrigSize;
621 SCRATCH_DATA *Sd;
622 CONST UINT8 *Src;
623 UINT8 *Dst;
624
625 ASSERT (Source != NULL);
626 ASSERT (Destination != NULL);
627 ASSERT (Scratch != NULL);
628
629 Src = Source;
630 Dst = Destination;
631
632 Sd = (SCRATCH_DATA *) Scratch;
633
634 CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
635 OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
636
637 //
638 // If compressed file size is 0, return
639 //
640 if (OrigSize == 0) {
641 return RETURN_SUCCESS;
642 }
643
644 Src = Src + 8;
645
646 for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {
647 ((UINT8 *) Sd)[Index] = 0;
648 }
649 //
650 // The length of the field 'Position Set Code Length Array Size' in Block Header.
651 // For UEFI 2.0 de/compression algorithm(Version 1), mPBit = 4
652 // For Tiano de/compression algorithm(Version 2), mPBit = 5
653 //
654 switch (Version) {
655 case 1 :
656 Sd->mPBit = 4;
657 break;
658 case 2 :
659 Sd->mPBit = 5;
660 break;
661 default:
662 ASSERT (FALSE);
663 }
664 Sd->mSrcBase = (UINT8 *)Src;
665 Sd->mDstBase = Dst;
666 Sd->mCompSize = CompSize;
667 Sd->mOrigSize = OrigSize;
668
669 //
670 // Fill the first BITBUFSIZ bits
671 //
672 FillBuf (Sd, BITBUFSIZ);
673
674 //
675 // Decompress it
676 //
677 Decode (Sd);
678
679 if (Sd->mBadTableFlag != 0) {
680 //
681 // Something wrong with the source
682 //
683 return RETURN_INVALID_PARAMETER;
684 }
685
686 return RETURN_SUCCESS;
687 }
688
689 /**
690 The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
691
692 @param Source - The source buffer containing the compressed data.
693 @param Destination - The destination buffer to store the decompressed data
694 @param Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
695
696 @retval RETURN_SUCCESS - Decompression is successfull
697 @retval RETURN_INVALID_PARAMETER - The source data is corrupted
698 **/
699 RETURN_STATUS
700 EFIAPI
701 UefiDecompress (
702 IN CONST VOID *Source,
703 IN OUT VOID *Destination,
704 IN OUT VOID *Scratch
705 )
706 {
707 return UefiTianoDecompress (Source, Destination, Scratch, 1);
708 }
709
710 /**
711 The internal implementation of Tiano decompress GetInfo.
712
713 @param InputSection Buffer containing the input GUIDed section to be processed.
714 @param OutputBufferSize The size of OutputBuffer.
715 @param ScratchBufferSize The size of ScratchBuffer.
716 @param SectionAttribute The attribute of the input guided section.
717
718 @retval RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
719 @retval RETURN_INVALID_PARAMETER - The source data is corrupted
720 The GUID in InputSection does not match this instance guid.
721 **/
722 RETURN_STATUS
723 EFIAPI
724 TianoDecompressGetInfo (
725 IN CONST VOID *InputSection,
726 OUT UINT32 *OutputBufferSize,
727 OUT UINT32 *ScratchBufferSize,
728 OUT UINT16 *SectionAttribute
729 )
730
731 {
732 ASSERT (SectionAttribute != NULL);
733
734 if (InputSection == NULL) {
735 return RETURN_INVALID_PARAMETER;
736 }
737
738 if (!CompareGuid (
739 &gTianoCustomDecompressGuid,
740 &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
741 return RETURN_INVALID_PARAMETER;
742 }
743 //
744 // Get guid attribute of guid section.
745 //
746 *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
747
748 //
749 // Call Tiano GetInfo to get the required size info.
750 //
751 return UefiDecompressGetInfo (
752 (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
753 (*(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
754 OutputBufferSize,
755 ScratchBufferSize
756 );
757 }
758
759 /**
760 The implementation of Tiano Decompress().
761
762 @param InputSection Buffer containing the input GUIDed section to be processed.
763 @param OutputBuffer OutputBuffer to point to the start of the section's contents.
764 if guided data is not prcessed. Otherwise,
765 OutputBuffer to contain the output data, which is allocated by the caller.
766 @param ScratchBuffer A pointer to a caller-allocated buffer for function internal use.
767 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that indicates the
768 authentication status of the output buffer.
769
770 @retval RETURN_SUCCESS Decompression is successfull
771 @retval RETURN_INVALID_PARAMETER The source data is corrupted, or
772 The GUID in InputSection does not match this instance guid.
773
774 --*/
775 RETURN_STATUS
776 EFIAPI
777 TianoDecompress (
778 IN CONST VOID *InputSection,
779 OUT VOID **OutputBuffer,
780 IN VOID *ScratchBuffer, OPTIONAL
781 OUT UINT32 *AuthenticationStatus
782 )
783 {
784 ASSERT (OutputBuffer != NULL);
785
786 if (InputSection == NULL) {
787 return RETURN_INVALID_PARAMETER;
788 }
789
790 if (!CompareGuid (
791 &gTianoCustomDecompressGuid,
792 &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
793 return RETURN_INVALID_PARAMETER;
794 }
795
796 //
797 // Set Authentication to Zero.
798 //
799 *AuthenticationStatus = 0;
800
801 //
802 // Call Tiano Decompress to get the raw data
803 //
804 return UefiTianoDecompress (
805 (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
806 *OutputBuffer,
807 ScratchBuffer,
808 2
809 );
810 }
811
812 /**
813 Register TianoDecompress handler.
814
815 @retval RETURN_SUCCESS Register successfully.
816 @retval RETURN_OUT_OF_RESOURCES No enough memory to store this handler.
817 **/
818 EFI_STATUS
819 EFIAPI
820 TianoDecompressLibConstructor (
821 )
822 {
823 return ExtractGuidedSectionRegisterHandlers (
824 &gTianoCustomDecompressGuid,
825 TianoDecompressGetInfo,
826 TianoDecompress
827 );
828 }