]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c
Add core FFS3 support, ExtractGuidedSectionLib/GuidedSectionExtractionLib/PiFirmwareF...
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / LzmaCustomDecompressLib / GuidedSectionExtraction.c
index 0f8b3f755fd01ba2c174ca0c947638806323a228..f19e0d28cd18a1cae02ab18786af2a5ff9c615aa 100644 (file)
@@ -3,7 +3,7 @@
   It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces\r
   and registers them into GUIDed handler table.\r
 \r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 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
@@ -63,20 +63,37 @@ LzmaGuidedSectionGetInfo (
   ASSERT (ScratchBufferSize != NULL);\r
   ASSERT (SectionAttribute != NULL);\r
 \r
-  if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid, \r
+  if (IS_SECTION2 (InputSection)) {\r
+    if (!CompareGuid (\r
+        &gLzmaCustomDecompressGuid,\r
+        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+\r
+    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
+\r
+    return LzmaUefiDecompressGetInfo (\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
+        &gLzmaCustomDecompressGuid,\r
         &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
 \r
-  *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
+    *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
 \r
-  return LzmaUefiDecompressGetInfo (\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
+    return LzmaUefiDecompressGetInfo (\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
@@ -124,23 +141,43 @@ LzmaGuidedSectionExtraction (
   ASSERT (OutputBuffer != NULL);\r
   ASSERT (InputSection != NULL);\r
 \r
-  if (!CompareGuid (\r
-        &gLzmaCustomDecompressGuid, \r
+  if (IS_SECTION2 (InputSection)) {\r
+    if (!CompareGuid (\r
+        &gLzmaCustomDecompressGuid,\r
+        &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+\r
+    //\r
+    // Authentication is set to Zero, which may be ignored.\r
+    //\r
+    *AuthenticationStatus = 0;\r
+\r
+    return LzmaUefiDecompress (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
+             SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,\r
+             *OutputBuffer,\r
+             ScratchBuffer\r
+             );\r
+  } else {\r
+    if (!CompareGuid (\r
+        &gLzmaCustomDecompressGuid,\r
         &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
-    return RETURN_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Authentication is set to Zero, which may be ignored.\r
-  //\r
-  *AuthenticationStatus = 0;\r
-\r
-  return LzmaUefiDecompress (\r
-    (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-    SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
-    *OutputBuffer,\r
-    ScratchBuffer\r
+      return RETURN_INVALID_PARAMETER;\r
+    }\r
+\r
+    //\r
+    // Authentication is set to Zero, which may be ignored.\r
+    //\r
+    *AuthenticationStatus = 0;\r
+\r
+    return LzmaUefiDecompress (\r
+             (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+             SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+             *OutputBuffer,\r
+             ScratchBuffer\r
     );\r
+  }\r
 }\r
 \r
 \r