]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Coding style fix and minor improvements.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
index d257eaee432db9bd8d41151dd50a58b9f2d63fe0..c5fe851abeac7302fcdd32cd50d2ecef1c90712b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
   \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2010, Intel Corporation\r
 All rights reserved. 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
@@ -12,19 +12,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PeiMain.h>\r
+#include "PeiMain.h"\r
 \r
-STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
+EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gEfiPeiMemoryDiscoveredPpiGuid,\r
   NULL\r
 };\r
 \r
 ///\r
-/// Pei Core Module Variables\r
+/// Pei service instance\r
 ///\r
-///\r
-STATIC EFI_PEI_SERVICES  gPs = {\r
+EFI_PEI_SERVICES  gPs = {\r
   {\r
     PEI_SERVICES_SIGNATURE,\r
     PEI_SERVICES_REVISION,\r
@@ -43,7 +42,7 @@ STATIC EFI_PEI_SERVICES  gPs = {
   PeiGetHobList,\r
   PeiCreateHob,\r
 \r
-  PeiFvFindNextVolume,\r
+  PeiFfsFindNextVolume,\r
   PeiFfsFindNextFile,\r
   PeiFfsFindSectionData,\r
 \r
@@ -56,8 +55,8 @@ STATIC EFI_PEI_SERVICES  gPs = {
   PeiReportStatusCode,\r
   PeiResetSystem,\r
 \r
-  NULL,\r
-  NULL,\r
+  &gPeiDefaultCpuIoPpi,\r
+  &gPeiDefaultPciCfg2Ppi,\r
 \r
   PeiFfsFindFileByName,\r
   PeiFfsGetFileInfo,\r
@@ -66,12 +65,10 @@ STATIC EFI_PEI_SERVICES  gPs = {
 };\r
 \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 +80,10 @@ 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
-\r
-  @retval EFI_NOT_FOUND  Never reach\r
+                         If NULL, it is first PeiCore entering.\r
 \r
 **/\r
-EFI_STATUS\r
+VOID\r
 EFIAPI\r
 PeiCore (\r
   IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
@@ -98,13 +94,13 @@ 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
   PEICORE_FUNCTION_POINTER                              ShadowedPeiCore;\r
 \r
-  mTick = 0;\r
+  Tick = 0;\r
   OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
 \r
   //\r
@@ -113,16 +109,17 @@ PeiCore (
   // \r
   if (PerformanceMeasurementEnabled()) {\r
     if (OldCoreData == NULL) {\r
-      mTick = GetPerformanceCounter ();\r
+      Tick = GetPerformanceCounter ();\r
     }\r
   }\r
 \r
-  //\r
-  // PeiCore has been shadowed to memory for first entering, so\r
-  // just jump to PeiCore in memory here.\r
-  //\r
   if (OldCoreData != NULL) {\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
@@ -142,17 +139,21 @@ 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
   }\r
 \r
-  PrivateData.PS = &PrivateData.ServiceTableShadow;\r
+  PrivateData.Ps = &PrivateData.ServiceTableShadow;\r
 \r
   //\r
   // Initialize libraries that the PeiCore is linked against\r
   //\r
-  ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r
+  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
 \r
   InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r
 \r
@@ -161,7 +162,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
@@ -183,14 +184,17 @@ PeiCore (
     //\r
     REPORT_STATUS_CODE (\r
       EFI_PROGRESS_CODE,\r
-      FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r
+      (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)\r
       );\r
+      \r
+    PERF_START (NULL, "SEC", NULL, 1);\r
+    PERF_END (NULL, "SEC", NULL, Tick);\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
@@ -201,7 +205,7 @@ PeiCore (
     }\r
   }\r
 \r
-  InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
+  InitializeSecurityServices (&PrivateData.Ps, OldCoreData);\r
 \r
   InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r
 \r
@@ -240,13 +244,14 @@ PeiCore (
   DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
   Status = TempPtr.DxeIpl->Entry (\r
                              TempPtr.DxeIpl,\r
-                             &PrivateData.PS,\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