]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/SecCore/SecMain.c
DynamicTablesPkg: DT Table Generator
[mirror_edk2.git] / UefiCpuPkg / SecCore / SecMain.c
index c241d3704af72b9702b15fbcc277358aa195d678..752156a98e2e6ecdd89cd86d8253a155de93f451 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   C functions in SEC\r
 \r
-  Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 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
@@ -113,6 +113,7 @@ SecPerformancePpiCallBack (
   @param BootFirmwareVolume  Base address of the Boot Firmware Volume.\r
 **/\r
 VOID\r
+NORETURN\r
 EFIAPI\r
 SecStartup (\r
   IN UINT32                   SizeOfRam,\r
@@ -201,6 +202,11 @@ SecStartup (
   // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready.\r
   //\r
   InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, &SecCoreData, SecStartupPhase2);\r
+\r
+  //\r
+  // Should not come here.\r
+  //\r
+  UNREACHABLE ();\r
 }\r
 \r
 /**\r
@@ -226,22 +232,45 @@ SecStartupPhase2(
   EFI_PEI_PPI_DESCRIPTOR      *AllSecPpiList;\r
   EFI_PEI_CORE_ENTRY_POINT    PeiCoreEntryPoint;\r
 \r
+  PeiCoreEntryPoint = NULL;\r
   SecCoreData   = (EFI_SEC_PEI_HAND_OFF *) Context;\r
   AllSecPpiList = (EFI_PEI_PPI_DESCRIPTOR *) SecCoreData->PeiTemporaryRamBase;\r
+\r
+  //\r
+  // Perform platform specific initialization before entering PeiCore.\r
+  //\r
+  PpiList = SecPlatformMain (SecCoreData);\r
   //\r
   // Find Pei Core entry point. It will report SEC and Pei Core debug information if remote debug\r
   // is enabled.\r
   //\r
-  FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint);\r
-  if (PeiCoreEntryPoint == NULL)\r
-  {\r
-    CpuDeadLoop ();\r
+  if (PpiList != NULL) {\r
+    for (Index = 0;\r
+      (PpiList[Index].Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) != EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
+      Index++) {\r
+      if (CompareGuid (PpiList[Index].Guid, &gEfiPeiCoreFvLocationPpiGuid) && (((EFI_PEI_CORE_FV_LOCATION_PPI *) PpiList[Index].Ppi)->PeiCoreFvLocation != 0)) {\r
+        FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) ((EFI_PEI_CORE_FV_LOCATION_PPI *) PpiList[Index].Ppi)->PeiCoreFvLocation, &PeiCoreEntryPoint);\r
+        if (PeiCoreEntryPoint != NULL) {\r
+          break;\r
+        } else {\r
+          //\r
+          // PeiCore not found\r
+          //\r
+          CpuDeadLoop ();\r
+        }\r
+      }\r
+    }\r
   }\r
-\r
   //\r
-  // Perform platform specific initialization before entering PeiCore.\r
+  // If EFI_PEI_CORE_FV_LOCATION_PPI not found, try to locate PeiCore from BFV.\r
   //\r
-  PpiList = SecPlatformMain (SecCoreData);\r
+  if (PeiCoreEntryPoint == NULL) {\r
+    FindAndReportEntryPoints ((EFI_FIRMWARE_VOLUME_HEADER *) SecCoreData->BootFirmwareVolumeBase, &PeiCoreEntryPoint);\r
+    if (PeiCoreEntryPoint == NULL) {\r
+      CpuDeadLoop ();\r
+    }\r
+  }\r
+\r
   if (PpiList != NULL) {\r
     //\r
     // Remove the terminal flag from the terminal PPI\r