]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Image/Image.c
MdeModulePkg: Update PeiCore dispatcher to handle PEIM and PEI_CORE only
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Image / Image.c
index 9c54192d86b7366c3ccedc608207e6c26b75ee4c..c75ef35eee2d0ee15dad367344c03992a3dcd422 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Load Image Support\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -358,7 +358,9 @@ LoadAndRelocatePeCoffImage (
   BOOLEAN                               IsXipImage;\r
   EFI_STATUS                            ReturnStatus;\r
   BOOLEAN                               IsS3Boot;\r
+  BOOLEAN                               IsPeiModule;\r
   BOOLEAN                               IsRegisterForShadow;\r
+  EFI_FV_FILE_INFO                      FileInfo;\r
 \r
   Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r
 \r
@@ -395,10 +397,26 @@ LoadAndRelocatePeCoffImage (
     IsXipImage = TRUE;\r
   }\r
 \r
+  //\r
+  // Get file type first\r
+  //\r
+  Status = PeiServicesFfsGetFileInfo (FileHandle, &FileInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  //\r
+  // Check whether the file type is PEI module.\r
+  //\r
+  IsPeiModule = FALSE;\r
+  if (FileInfo.FileType == EFI_FV_FILETYPE_PEI_CORE || \r
+      FileInfo.FileType == EFI_FV_FILETYPE_PEIM || \r
+      FileInfo.FileType == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER) {\r
+    IsPeiModule = TRUE;\r
+  }\r
+\r
   //\r
   // When Image has no reloc section, it can't be relocated into memory.\r
   //\r
-  if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && (\r
+  if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && ((!IsPeiModule) ||\r
       (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) {\r
     DEBUG ((EFI_D_INFO|EFI_D_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));\r
   }\r
@@ -413,7 +431,7 @@ LoadAndRelocatePeCoffImage (
   // On normal boot, PcdShadowPeimOnBoot decides whether load PEIM or PeiCore into memory.\r
   // On S3 boot, PcdShadowPeimOnS3Boot decides whether load PEIM or PeiCore into memory.\r
   //\r
-  if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && (\r
+  if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && ((!IsPeiModule) ||\r
       (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) {\r
     //\r
     // Allocate more buffer to avoid buffer overflow.\r