]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI
authorChasel, Chiu <chasel.chiu@intel.com>
Tue, 12 Feb 2019 12:29:19 +0000 (20:29 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Fri, 15 Feb 2019 05:40:30 +0000 (13:40 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1524

When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI
should be checked to see if PeiCore not in BFV, otherwise
just shadowing PeiCore from BFV.

Test: Verified on internal platform and booting successfully.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/Core/Pei/PeiMain.inf
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c

index 322e7cd84524b9c6029cfc531ac5de8504e6e160..a61da73fd8e4aa32786e5dde7885d525430ea46b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, 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
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/TemporaryRamSupport.h>\r
 #include <Ppi/TemporaryRamDone.h>\r
 #include <Ppi/SecHobData.h>\r
+#include <Ppi/PeiCoreFvLocation.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeiCoreEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
index 140c4444b1072a4138454bccd97378f4544d297f..5bab2aab8cc882c7e48b711507f72a9411faf871 100644 (file)
@@ -6,7 +6,7 @@
 # 2) Dispatch PEIM from discovered FV.\r
 # 3) Handoff control to DxeIpl to load DXE core and enter DXE phase.\r
 #\r
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   gEfiTemporaryRamDonePpiGuid                   ## SOMETIMES_CONSUMES\r
   gEfiPeiReset2PpiGuid                          ## SOMETIMES_CONSUMES\r
   gEfiSecHobDataPpiGuid                         ## SOMETIMES_CONSUMES\r
+  gEfiPeiCoreFvLocationPpiGuid                  ## SOMETIMES_CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize                  ## CONSUMES\r
index 4da80a8222bc164d60516ecda93852544fb4ae8b..a7da90e1497b9b6f75dc4be8153cf0e32fe50b4e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, 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
@@ -80,22 +80,49 @@ ShadowPeiCore (
   IN PEI_CORE_INSTANCE  *PrivateData\r
   )\r
 {\r
-  EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;\r
-  EFI_PHYSICAL_ADDRESS EntryPoint;\r
-  EFI_STATUS           Status;\r
-  UINT32               AuthenticationState;\r
+  EFI_PEI_FILE_HANDLE          PeiCoreFileHandle;\r
+  EFI_PHYSICAL_ADDRESS         EntryPoint;\r
+  EFI_STATUS                   Status;\r
+  UINT32                       AuthenticationState;\r
+  UINTN                        Index;\r
+  EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;\r
+  UINTN                        PeiCoreFvIndex;\r
 \r
   PeiCoreFileHandle = NULL;\r
-\r
   //\r
-  // Find the PEI Core in the BFV\r
+  // Default PeiCore is in BFV\r
+  //\r
+  PeiCoreFvIndex = 0;\r
+  //\r
+  // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI indicated FV or BFV\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiCoreFvLocationPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **) &PeiCoreFvLocationPpi\r
+             );\r
+  if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != NULL)) {\r
+    //\r
+    // If PeiCoreFvLocation present, the PEI Core should be found from indicated FV\r
+    //\r
+    for (Index = 0; Index < PrivateData->FvCount; Index ++) {\r
+      if (PrivateData->Fv[Index].FvHandle == PeiCoreFvLocationPpi->PeiCoreFvLocation) {\r
+        PeiCoreFvIndex = Index;\r
+        break;\r
+      }\r
+    }\r
+    ASSERT (Index < PrivateData->FvCount);\r
+  }\r
+  //\r
+  // Find PEI Core from the given FV index\r
   //\r
-  Status = PrivateData->Fv[0].FvPpi->FindFileByType (\r
-                                       PrivateData->Fv[0].FvPpi,\r
-                                       EFI_FV_FILETYPE_PEI_CORE,\r
-                                       PrivateData->Fv[0].FvHandle,\r
-                                       &PeiCoreFileHandle\r
-                                       );\r
+  Status = PrivateData->Fv[PeiCoreFvIndex].FvPpi->FindFileByType (\r
+                                                    PrivateData->Fv[PeiCoreFvIndex].FvPpi,\r
+                                                    EFI_FV_FILETYPE_PEI_CORE,\r
+                                                    PrivateData->Fv[PeiCoreFvIndex].FvHandle,\r
+                                                    &PeiCoreFileHandle\r
+                                                    );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r