]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c
Set Hob type for FvMainCompactFv to EFI_HOB_TYPE_UNUSED after decompressed. The can...
[mirror_edk2.git] / EdkModulePkg / Core / DxeIplX64Peim / DxeLoadX64.c
index 4211dd3075ccef3fee9c711806e70de6b36a2415..33ca3bbb04ff4f5981dfbf09139c4958c4054c8f 100644 (file)
@@ -26,15 +26,6 @@ Abstract:
 \r
 BOOLEAN gInMemory = FALSE;\r
 \r
-//\r
-// GUID for EM64T\r
-//\r
-#define EFI_PPI_NEEDED_BY_DXE \\r
-  { \\r
-    0x4d37da42, 0x3a0c, 0x4eda, 0xb9, 0xeb, 0xbc, 0x0e, 0x1d, 0xb4, 0x71, 0x3b \\r
-  }\r
-EFI_GUID mPpiNeededByDxeGuid = EFI_PPI_NEEDED_BY_DXE;\r
-\r
 //\r
 // Module Globals used in the DXE to PEI handoff\r
 // These must be module globals, so the stack can be switched\r
@@ -71,17 +62,17 @@ static EFI_PEI_PPI_DESCRIPTOR     mPpiSignal = {
   NULL\r
 };\r
 \r
-DECOMPRESS_LIBRARY  gEfiDecompress = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED DECOMPRESS_LIBRARY  gEfiDecompress = {\r
   UefiDecompressGetInfo,\r
   UefiDecompress\r
 };\r
 \r
-DECOMPRESS_LIBRARY  gTianoDecompress = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED DECOMPRESS_LIBRARY  gTianoDecompress = {\r
   TianoDecompressGetInfo,\r
   TianoDecompress\r
 };\r
 \r
-DECOMPRESS_LIBRARY  gCustomDecompress = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED DECOMPRESS_LIBRARY  gCustomDecompress = {\r
   CustomDecompressGetInfo,\r
   CustomDecompress\r
 };\r
@@ -256,12 +247,8 @@ Returns:
   //\r
   // Install the PEI Protocols that are shared between PEI and DXE\r
   //\r
-#ifdef EFI_NT_EMULATOR\r
   PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderProtocol ();\r
   ASSERT (PeiEfiPeiPeCoffLoader != NULL);\r
-#else\r
-  PeiEfiPeiPeCoffLoader = (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)GetPeCoffLoaderX64Protocol ();\r
-#endif \r
 \r
   //\r
   // Allocate 128KB for the Stack\r
@@ -295,7 +282,10 @@ Returns:
 \r
     ASSERT_EFI_ERROR (Status);\r
     Status = PeiRecovery->LoadRecoveryCapsule (PeiServices, PeiRecovery);\r
-    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "Load Recovery Capsule Failed.(Status = %r)\n", Status));\r
+      CpuDeadLoop ();\r
+    }\r
   }\r
 \r
   //\r
@@ -309,15 +299,6 @@ Returns:
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Transfer control to the DXE Core\r
-  // The handoff state is simply a pointer to the HOB list\r
-  //\r
-  // PEI_PERF_END (PeiServices, L"DxeIpl", NULL, 0);\r
-\r
-  Status = PeiServicesInstallPpi (&mPpiSignal);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   //\r
   // Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA \\r
   // memory, it may be corrupted when copying FV to high-end memory \r
@@ -332,7 +313,7 @@ Returns:
   //\r
   // Load the DXE Core from a Firmware Volume\r
   //\r
-  Status = PeiLoadx64File (\r
+  Status = PeiLoadPeImage (\r
              PeiEfiPeiPeCoffLoader,\r
              DxeCorePe32Data,\r
              EfiBootServicesData,\r
@@ -342,6 +323,14 @@ Returns:
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Transfer control to the DXE Core\r
+  // The handoff state is simply a pointer to the HOB list\r
+  //\r
+\r
+  Status = PeiServicesInstallPpi (&mPpiSignal);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
   //\r
   // Add HOB for the DXE Core\r
@@ -376,8 +365,10 @@ Returns:
 \r
   //\r
   // If we get here, then the DXE Core returned.  This is an error\r
+  // Dxe Core should not return.\r
   //\r
-  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (FALSE);\r
+  CpuDeadLoop ();\r
 \r
   return EFI_OUT_OF_RESOURCES;\r
 }\r
@@ -444,7 +435,8 @@ Returns:
       Status = PeiProcessFile (\r
                  SectionType,\r
                  &FfsFileHeader,\r
-                 Pe32Data\r
+                 Pe32Data,\r
+                 &Hob\r
                  );\r
       CopyMem (FileName, &FfsFileHeader->Name, sizeof (EFI_GUID));\r
       return Status;\r
@@ -455,7 +447,7 @@ Returns:
 }\r
 \r
 EFI_STATUS\r
-PeiLoadx64File (\r
+PeiLoadPeImage (\r
   IN  EFI_PEI_PE_COFF_LOADER_PROTOCOL           *PeiEfiPeiPeCoffLoader,\r
   IN  VOID                                      *Pe32Data,\r
   IN  EFI_MEMORY_TYPE                           MemoryType,\r
@@ -587,7 +579,7 @@ Returns:
   //\r
   // Relocate DxeIpl into memory by using loadfile service\r
   //\r
-  Status = PeiLoadx64File (\r
+  Status = PeiLoadPeImage (\r
             PeiEfiPeiPeCoffLoader,\r
             (VOID *) (Section + 1),\r
             EfiBootServicesData,\r
@@ -659,7 +651,8 @@ Returns:
   Status = PeiProcessFile (\r
             EFI_SECTION_PE32,\r
             &FfsHeader,\r
-            &Pe32Data\r
+            &Pe32Data,\r
+            NULL\r
             );\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -668,7 +661,7 @@ Returns:
   //\r
   // Load the PE image from the FFS file\r
   //\r
-  Status = PeiLoadx64File (\r
+  Status = PeiLoadPeImage (\r
             PeiEfiPeiPeCoffLoader,\r
             Pe32Data,\r
             EfiBootServicesData,\r
@@ -684,7 +677,8 @@ EFI_STATUS
 PeiProcessFile (\r
   IN      UINT16                 SectionType,\r
   IN OUT  EFI_FFS_FILE_HEADER    **RealFfsFileHeader,\r
-  OUT     VOID                   **Pe32Data\r
+  OUT     VOID                   **Pe32Data,\r
+  IN      EFI_PEI_HOB_POINTERS   *OrigHob\r
   )\r
 /*++\r
 \r
@@ -851,14 +845,24 @@ Returns:
 \r
         switch (CompressionSection->CompressionType) {\r
         case EFI_STANDARD_COMPRESSION:\r
-          DecompressLibrary = &gTianoDecompress;\r
+          if (FeaturePcdGet (PcdDxeIplSupportTianoDecompress)) {\r
+            DecompressLibrary = &gTianoDecompress;\r
+          } else {\r
+            ASSERT (FALSE);\r
+            return EFI_NOT_FOUND;\r
+          }\r
           break;\r
 \r
         case EFI_CUSTOMIZED_COMPRESSION:\r
           //\r
           // Load user customized compression protocol.\r
           //\r
-          DecompressLibrary = &gCustomDecompress;\r
+          if (FeaturePcdGet (PcdDxeIplSupportCustomDecompress)) {\r
+            DecompressLibrary = &gCustomDecompress;\r
+          } else {\r
+            ASSERT (FALSE);\r
+            return EFI_NOT_FOUND;\r
+          }\r
           break;\r
 \r
         case EFI_NOT_COMPRESSED:\r
@@ -929,11 +933,17 @@ Returns:
               return EFI_NOT_FOUND;\r
             }\r
 \r
+            if (OrigHob != NULL) {\r
+              //\r
+              // \r
+              OrigHob->Header->HobType = EFI_HOB_TYPE_UNUSED;\r
+            }\r
+            \r
             //\r
             // Reture the FfsHeader that contain Pe32Data.\r
             //\r
             *RealFfsFileHeader = FfsFileHeader;\r
-            return PeiProcessFile (SectionType, RealFfsFileHeader, Pe32Data);\r
+            return PeiProcessFile (SectionType, RealFfsFileHeader, Pe32Data, OrigHob);\r
           }\r
         }\r
         //\r