]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
1. build.py's changes : include XXXEntryPointLib.h into the corresponding autogen...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
index 056165e689931cbc1469ba281d767615ba787c46..32f875b688dbc946fbcea9557bc9dc96b830d3fe 100644 (file)
@@ -20,10 +20,9 @@ STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
   NULL\r
 };\r
 \r
-//\r
-// Pei Core Module Variables\r
-//\r
-//\r
+///\r
+/// Pei service instance\r
+///\r
 STATIC EFI_PEI_SERVICES  gPs = {\r
   {\r
     PEI_SERVICES_SIGNATURE,\r
@@ -67,11 +66,10 @@ STATIC EFI_PEI_SERVICES  gPs = {
 \r
 /**\r
 \r
-  The entry routine to Pei Core, invoked by PeiMain during transition\r
+  This routine is invoked by main entry of PeiMain module during transition\r
   from SEC to PEI. After switching stack in the PEI core, it will restart\r
   with the old core data.\r
 \r
-\r
   @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
                          environment, such as the size and location of temporary RAM, the stack location and\r
                          the BFV location.\r
@@ -83,11 +81,12 @@ STATIC EFI_PEI_SERVICES  gPs = {
                          calls and/or code in these early PPIs\r
   @param Data            Pointer to old core data that is used to initialize the\r
                          core's data areas.\r
+                         If NULL, it is first PeiCore entering.\r
 \r
   @retval EFI_NOT_FOUND  Never reach\r
 \r
 **/\r
-EFI_STATUS\r
+VOID\r
 EFIAPI\r
 PeiCore (\r
   IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
@@ -98,23 +97,32 @@ PeiCore (
   PEI_CORE_INSTANCE                                     PrivateData;\r
   EFI_STATUS                                            Status;\r
   PEI_CORE_TEMP_POINTERS                                TempPtr;\r
-  UINT64                                                mTick;\r
+  UINT64                                                Tick;\r
   PEI_CORE_INSTANCE                                     *OldCoreData;\r
   EFI_PEI_CPU_IO_PPI                                    *CpuIo;\r
   EFI_PEI_PCI_CFG2_PPI                                  *PciCfg;\r
-  PEI_CORE_ENTRY_POINT                                  ShadowedPeiCore;\r
+  PEICORE_FUNCTION_POINTER                              ShadowedPeiCore;\r
 \r
-  mTick = 0;\r
+  Tick = 0;\r
   OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
 \r
+  //\r
+  // Record the system tick for first entering PeiCore.\r
+  // This tick is duration of executing platform seccore module.\r
+  // \r
   if (PerformanceMeasurementEnabled()) {\r
     if (OldCoreData == NULL) {\r
-      mTick = GetPerformanceCounter ();\r
+      Tick = GetPerformanceCounter ();\r
     }\r
   }\r
 \r
   if (OldCoreData != NULL) {\r
-    ShadowedPeiCore = (PEI_CORE_ENTRY_POINT) (UINTN) OldCoreData->ShadowedPeiCore;\r
+    ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) OldCoreData->ShadowedPeiCore;\r
+    \r
+    //\r
+    // PeiCore has been shadowed to memory for first entering, so\r
+    // just jump to PeiCore in memory here.\r
+    //\r
     if (ShadowedPeiCore != NULL) {\r
       OldCoreData->ShadowedPeiCore = NULL;\r
       ShadowedPeiCore (\r
@@ -134,6 +142,10 @@ PeiCore (
     PrivateData.ServiceTableShadow.CpuIo  = CpuIo;\r
     PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
   } else {\r
+    //\r
+    // If OldCoreData is NULL, means current is first Peicore's entering.\r
+    //\r
+    \r
     ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
     PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
     CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
@@ -143,9 +155,8 @@ PeiCore (
 \r
   //\r
   // Initialize libraries that the PeiCore is linked against\r
-  // BUGBUG: The FileHandle is passed in as NULL.  Do we look it up or remove it from the lib init?\r
   //\r
-  ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
+  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.PS);\r
 \r
   InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r
 \r
@@ -154,7 +165,7 @@ PeiCore (
   //\r
   // Save PeiServicePointer so that it can be retrieved anywhere.\r
   //\r
-  SetPeiServicesTablePointer(&PrivateData.PS);\r
+  SetPeiServicesTablePointer((CONST EFI_PEI_SERVICES **) &PrivateData.PS);\r
   \r
   if (OldCoreData != NULL) {\r
 \r
@@ -179,11 +190,11 @@ PeiCore (
       FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r
       );\r
 \r
-    PERF_START (NULL,"PEI", NULL, mTick);\r
+    PERF_START (NULL,"PEI", NULL, Tick);\r
     //\r
     // If first pass, start performance measurement.\r
     //\r
-    PERF_START (NULL,"PreMem", NULL, mTick);\r
+    PERF_START (NULL,"PreMem", NULL, Tick);\r
 \r
     //\r
     // If SEC provided any PPI services to PEI, install them.\r
@@ -213,6 +224,10 @@ PeiCore (
   //\r
   ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
 \r
+  //\r
+  // Till now, PEI phase will be finished, get performace count\r
+  // for computing duration of PEI phase\r
+  //\r
   PERF_END (NULL, "PostMem", NULL, 0);\r
 \r
   Status = PeiServicesLocatePpi (\r
@@ -223,16 +238,20 @@ PeiCore (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Enter DxeIpl to load Dxe core.\r
+  //\r
   DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
   Status = TempPtr.DxeIpl->Entry (\r
                              TempPtr.DxeIpl,\r
                              &PrivateData.PS,\r
                              PrivateData.HobList\r
                              );\r
-\r
+  //\r
+  // Should never reach here.\r
+  //\r
   ASSERT_EFI_ERROR (Status);\r
-\r
-  return EFI_NOT_FOUND;\r
+  CpuDeadLoop();\r
 }\r
 \r
 \r