]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
Add core FFS3 support, PeiCore and DxeIpl.
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / DxeLoad.c
index e6836596d8c2a8b83af42e56304f327dd5ba1517..d0baf2eb9120ee6d84680583769af094b0602029 100644 (file)
@@ -515,21 +515,32 @@ Decompress (
   UINT8                           *ScratchBuffer;\r
   UINT32                          DstBufferSize;\r
   UINT32                          ScratchBufferSize;\r
   UINT8                           *ScratchBuffer;\r
   UINT32                          DstBufferSize;\r
   UINT32                          ScratchBufferSize;\r
-  EFI_COMMON_SECTION_HEADER       *Section;\r
-  UINT32                          SectionLength;\r
+  VOID                            *CompressionSource;\r
+  UINT32                          CompressionSourceSize;\r
+  UINT32                          UncompressedLength;\r
+  UINT8                           CompressionType;\r
 \r
   if (CompressionSection->CommonHeader.Type != EFI_SECTION_COMPRESSION) {\r
     ASSERT (FALSE);\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
 \r
   if (CompressionSection->CommonHeader.Type != EFI_SECTION_COMPRESSION) {\r
     ASSERT (FALSE);\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Section = (EFI_COMMON_SECTION_HEADER *) CompressionSection;\r
-  SectionLength = *(UINT32 *) (Section->Size) & 0x00ffffff;\r
+  if (IS_SECTION2 (CompressionSection)) {\r
+    CompressionSource = (VOID *) ((UINT8 *) CompressionSection + sizeof (EFI_COMPRESSION_SECTION2));\r
+    CompressionSourceSize = (UINT32) (SECTION2_SIZE (CompressionSection) - sizeof (EFI_COMPRESSION_SECTION2));\r
+    UncompressedLength = ((EFI_COMPRESSION_SECTION2 *) CompressionSection)->UncompressedLength;\r
+    CompressionType = ((EFI_COMPRESSION_SECTION2 *) CompressionSection)->CompressionType;\r
+  } else {\r
+    CompressionSource = (VOID *) ((UINT8 *) CompressionSection + sizeof (EFI_COMPRESSION_SECTION));\r
+    CompressionSourceSize = (UINT32) (SECTION_SIZE (CompressionSection) - sizeof (EFI_COMPRESSION_SECTION));\r
+    UncompressedLength = CompressionSection->UncompressedLength;\r
+    CompressionType = CompressionSection->CompressionType;\r
+  }\r
   \r
   //\r
   // This is a compression set, expand it\r
   //\r
   \r
   //\r
   // This is a compression set, expand it\r
   //\r
-  switch (CompressionSection->CompressionType) {\r
+  switch (CompressionType) {\r
   case EFI_STANDARD_COMPRESSION:\r
     if (FeaturePcdGet(PcdDxeIplSupportUefiDecompress)) {\r
       //\r
   case EFI_STANDARD_COMPRESSION:\r
     if (FeaturePcdGet(PcdDxeIplSupportUefiDecompress)) {\r
       //\r
@@ -537,8 +548,8 @@ Decompress (
       // For compressed data, decompress them to destination buffer.\r
       //\r
       Status = UefiDecompressGetInfo (\r
       // For compressed data, decompress them to destination buffer.\r
       //\r
       Status = UefiDecompressGetInfo (\r
-                 (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
-                 SectionLength - sizeof (EFI_COMPRESSION_SECTION),\r
+                 CompressionSource,\r
+                 CompressionSourceSize,\r
                  &DstBufferSize,\r
                  &ScratchBufferSize\r
                  );\r
                  &DstBufferSize,\r
                  &ScratchBufferSize\r
                  );\r
@@ -572,7 +583,7 @@ Decompress (
       // Call decompress function\r
       //\r
       Status = UefiDecompress (\r
       // Call decompress function\r
       //\r
       Status = UefiDecompress (\r
-                  (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+                  CompressionSource,\r
                   DstBuffer,\r
                   ScratchBuffer\r
                   );\r
                   DstBuffer,\r
                   ScratchBuffer\r
                   );\r
@@ -597,7 +608,7 @@ Decompress (
     //\r
     // Allocate destination buffer\r
     //\r
     //\r
     // Allocate destination buffer\r
     //\r
-    DstBufferSize = CompressionSection->UncompressedLength;\r
+    DstBufferSize = UncompressedLength;\r
     DstBuffer     = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);\r
     if (DstBuffer == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     DstBuffer     = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize) + 1);\r
     if (DstBuffer == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -610,7 +621,7 @@ Decompress (
     //\r
     // stream is not actually compressed, just encapsulated.  So just copy it.\r
     //\r
     //\r
     // stream is not actually compressed, just encapsulated.  So just copy it.\r
     //\r
-    CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize);\r
+    CopyMem (DstBuffer, CompressionSource, DstBufferSize);\r
     break;\r
 \r
   default:\r
     break;\r
 \r
   default:\r