]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Core/DxeIplPeim/DxeLoad.c
(1) Using EfiCompress in place of TianoCompress as EFI_STANDARD_COMPRESSION type...
[mirror_edk2.git] / EdkModulePkg / Core / DxeIplPeim / DxeLoad.c
index 8dbc3763d656cd4e97481df19abfd6cbb2eea2b0..6a4c53b9223e53963682d8d1454436ebcf483696 100644 (file)
@@ -669,6 +669,13 @@ Returns:
   EFI_COMPRESSION_SECTION         *CompressionSection;\r
   UINT32                          FvAlignment;\r
 \r
+  //\r
+  // Initialize local variables.\r
+  //\r
+  DecompressLibrary = NULL;\r
+  DstBuffer         = NULL;\r
+  DstBufferSize     = 0;\r
+\r
   Status = PeiServicesFfsFindSectionData (\r
              EFI_SECTION_COMPRESSION,\r
              FfsFileHeader,\r
@@ -784,8 +791,11 @@ Returns:
 \r
         switch (CompressionSection->CompressionType) {\r
         case EFI_STANDARD_COMPRESSION:\r
+          //\r
+          // Load EFI standard compression.\r
+          //\r
           if (FeaturePcdGet (PcdDxeIplSupportTianoDecompress)) {\r
-            DecompressLibrary = &gTianoDecompress;\r
+            DecompressLibrary = &gEfiDecompress;\r
           } else {\r
             ASSERT (FALSE);\r
             return EFI_NOT_FOUND;\r
@@ -794,7 +804,7 @@ Returns:
 \r
         case EFI_CUSTOMIZED_COMPRESSION:\r
           //\r
-          // Load user customized compression protocol.\r
+          // Load user customized compression.\r
           //\r
           if (FeaturePcdGet (PcdDxeIplSupportCustomDecompress)) {\r
             DecompressLibrary = &gCustomDecompress;\r
@@ -805,52 +815,71 @@ Returns:
           break;\r
 \r
         case EFI_NOT_COMPRESSED:\r
+          //\r
+          // Allocate destination buffer\r
+          //\r
+          DstBufferSize = CompressionSection->UncompressedLength;\r
+          DstBuffer     = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));\r
+          if (DstBuffer == NULL) {\r
+            return EFI_OUT_OF_RESOURCES;\r
+          }\r
+          //\r
+          // stream is not actually compressed, just encapsulated.  So just copy it.\r
+          //\r
+          CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize);\r
+          break;\r
+\r
         default:\r
           //\r
-          // Need to support not compressed file\r
+          // Don't support other unknown compression type.\r
           //\r
           ASSERT_EFI_ERROR (Status);\r
           return EFI_NOT_FOUND;\r
         }\r
-\r
-        Status = DecompressLibrary->GetInfo (\r
-                   (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
-                   (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION),\r
-                   &DstBufferSize,\r
-                   &ScratchBufferSize\r
-                   );\r
-        if (EFI_ERROR (Status)) {\r
+        \r
+        if (CompressionSection->CompressionType != EFI_NOT_COMPRESSED) {\r
           //\r
-          // GetInfo failed\r
+          // For compressed data, decompress them to dstbuffer.\r
           //\r
-          return EFI_NOT_FOUND;\r
-        }\r
-\r
-        //\r
-        // Allocate scratch buffer\r
-        //\r
-        ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));\r
-        if (ScratchBuffer == NULL) {\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        //\r
-        // Allocate destination buffer\r
-        //\r
-        DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));\r
-        if (DstBuffer == NULL) {\r
-          return EFI_OUT_OF_RESOURCES;\r
+          Status = DecompressLibrary->GetInfo (\r
+                     (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+                     (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION),\r
+                     &DstBufferSize,\r
+                     &ScratchBufferSize\r
+                     );\r
+          if (EFI_ERROR (Status)) {\r
+            //\r
+            // GetInfo failed\r
+            //\r
+            return EFI_NOT_FOUND;\r
+          }\r
+  \r
+          //\r
+          // Allocate scratch buffer\r
+          //\r
+          ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));\r
+          if (ScratchBuffer == NULL) {\r
+            return EFI_OUT_OF_RESOURCES;\r
+          }\r
+  \r
+          //\r
+          // Allocate destination buffer\r
+          //\r
+          DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize));\r
+          if (DstBuffer == NULL) {\r
+            return EFI_OUT_OF_RESOURCES;\r
+          }\r
+  \r
+          //\r
+          // Call decompress function\r
+          //\r
+          Status = DecompressLibrary->Decompress (\r
+                      (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+                      DstBuffer,\r
+                      ScratchBuffer\r
+                      );\r
         }\r
-\r
-        //\r
-        // Call decompress function\r
-        //\r
-        Status = DecompressLibrary->Decompress (\r
-                    (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
-                    DstBuffer,\r
-                    ScratchBuffer\r
-                    );\r
-\r
+        \r
         CmpSection = (EFI_COMMON_SECTION_HEADER *) DstBuffer;\r
         if (CmpSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) {\r
           // \r
@@ -909,7 +938,6 @@ Returns:
             } else {\r
               return EFI_NOT_FOUND;\r
             }\r
-\r
           }\r
         }\r
         //\r