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