]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
Add core FFS3 support, ExtractGuidedSectionLib/GuidedSectionExtractionLib/PiFirmwareF...
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / BaseUefiTianoCustomDecompressLib / BaseUefiTianoCustomDecompressLib.c
index fb60d029a8c4447c0e6b40241de0fb02047e97b7..bcc9764100ba1857d9b17e9b8251a9dbe95f6150 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   UEFI and Tiano Custom Decompress Library \r
-  Tt will do Tiano or UEFI decompress with different verison parameter.\r
+  It will do Tiano or UEFI decompress with different verison parameter.\r
   \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -897,25 +897,47 @@ TianoDecompressGetInfo (
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
-  if (!CompareGuid (\r
-        &gTianoCustomDecompressGuid, \r
+  if (IS_SECTION2 (InputSection)) {\r
+    if (!CompareGuid (\r
+        &gTianoCustomDecompressGuid,\r
+        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+    //\r
+    // Get guid attribute of guid section. \r
+    //\r
+    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
+\r
+    //\r
+    // Call Tiano GetInfo to get the required size info.\r
+    //\r
+    return UefiDecompressGetInfo (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
+             SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
+             OutputBufferSize,\r
+             ScratchBufferSize\r
+             );\r
+  } else {\r
+    if (!CompareGuid (\r
+        &gTianoCustomDecompressGuid,\r
         &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Get guid attribute of guid section. \r
-  //\r
-  *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+    //\r
+    // Get guid attribute of guid section. \r
+    //\r
+    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
 \r
-  //\r
-  // Call Tiano GetInfo to get the required size info.\r
-  //\r
-  return UefiDecompressGetInfo (\r
-          (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-          (*(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-          OutputBufferSize,\r
-          ScratchBufferSize\r
-         );\r
+    //\r
+    // Call Tiano GetInfo to get the required size info.\r
+    //\r
+    return UefiDecompressGetInfo (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+             SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+             OutputBufferSize,\r
+             ScratchBufferSize\r
+             );\r
+  }\r
 }\r
 \r
 /**\r
@@ -963,26 +985,49 @@ TianoDecompress (
   ASSERT (OutputBuffer != NULL);\r
   ASSERT (InputSection != NULL);\r
 \r
-  if (!CompareGuid (\r
-        &gTianoCustomDecompressGuid, \r
+  if (IS_SECTION2 (InputSection)) {\r
+    if (!CompareGuid (\r
+        &gTianoCustomDecompressGuid,\r
+        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+\r
+    //\r
+    // Set Authentication to Zero.\r
+    //\r
+    *AuthenticationStatus = 0;\r
+\r
+    //\r
+    // Call Tiano Decompress to get the raw data\r
+    //\r
+    return UefiTianoDecompress (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
+             *OutputBuffer,\r
+             ScratchBuffer,\r
+             2\r
+           );\r
+  } else {\r
+    if (!CompareGuid (\r
+        &gTianoCustomDecompressGuid,\r
         &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
 \r
-  //\r
-  // Set Authentication to Zero.\r
-  //\r
-  *AuthenticationStatus = 0;\r
-  \r
-  //\r
-  // Call Tiano Decompress to get the raw data\r
-  //\r
-  return UefiTianoDecompress (\r
-          (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-          *OutputBuffer,\r
-          ScratchBuffer,\r
-          2\r
-         );\r
+    //\r
+    // Set Authentication to Zero.\r
+    //\r
+    *AuthenticationStatus = 0;\r
+\r
+    //\r
+    // Call Tiano Decompress to get the raw data\r
+    //\r
+    return UefiTianoDecompress (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+             *OutputBuffer,\r
+             ScratchBuffer,\r
+             2\r
+           );\r
+  }\r
 }\r
 \r
 /**\r
@@ -1000,5 +1045,5 @@ TianoDecompressLibConstructor (
           &gTianoCustomDecompressGuid,\r
           TianoDecompressGetInfo,\r
           TianoDecompress\r
-          );      \r
+          );\r
 }\r