]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
index 3220ffb8eecb9816ade75f92318fafc86140e50a..33f056ea8f5dc86d753bf73c57393c070c447e55 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Pei Core Main Entry Point\r
-  \r
-Copyright (c) 2006 - 2014, 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
-http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -46,7 +40,7 @@ EFI_PEI_SERVICES  gPs = {
   PeiFfsFindNextFile,\r
   PeiFfsFindSectionData,\r
 \r
-  PeiInstallPeiMemory,      \r
+  PeiInstallPeiMemory,\r
   PeiAllocatePages,\r
   PeiAllocatePool,\r
   (EFI_PEI_COPY_MEM)CopyMem,\r
@@ -63,12 +57,14 @@ EFI_PEI_SERVICES  gPs = {
   PeiFfsGetVolumeInfo,\r
   PeiRegisterForShadow,\r
   PeiFfsFindSectionData3,\r
-  PeiFfsGetFileInfo2\r
+  PeiFfsGetFileInfo2,\r
+  PeiResetSystem2,\r
+  PeiFreePages,\r
 };\r
 \r
 /**\r
   Shadow PeiCore module from flash to installed memory.\r
-  \r
+\r
   @param PrivateData    PeiCore's private data structure\r
 \r
   @return PeiCore function address after shadowing.\r
@@ -78,22 +74,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
-  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
+  // 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[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
@@ -102,7 +125,7 @@ ShadowPeiCore (
   Status = PeiLoadImage (\r
               GetPeiServicesTablePointer (),\r
               *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),\r
-              PEIM_STATE_REGISITER_FOR_SHADOW,\r
+              PEIM_STATE_REGISTER_FOR_SHADOW,\r
               &EntryPoint,\r
               &AuthenticationState\r
               );\r
@@ -153,7 +176,7 @@ PeiCore (
   EFI_HOB_HANDOFF_INFO_TABLE  *HandoffInformationTable;\r
   EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;\r
   UINTN                       Index;\r
-  \r
+\r
   //\r
   // Retrieve context passed into PEI Core\r
   //\r
@@ -182,42 +205,74 @@ PeiCore (
       OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;\r
       if (OldCoreData->HeapOffsetPositive) {\r
         OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);\r
-        OldCoreData->UnknownFvInfo        = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);\r
-        OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);\r
-        OldCoreData->PpiData.PpiListPtrs  = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);\r
+        if (OldCoreData->UnknownFvInfo != NULL) {\r
+          OldCoreData->UnknownFvInfo      = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->CurrentFvFileHandles != NULL) {\r
+          OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {\r
+          OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {\r
+          OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {\r
+          OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);\r
+        }\r
         OldCoreData->Fv                   = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);\r
-        for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
-          OldCoreData->Fv[Index].PeimState     = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;\r
-          OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);\r
+        for (Index = 0; Index < OldCoreData->FvCount; Index ++) {\r
+          if (OldCoreData->Fv[Index].PeimState != NULL) {\r
+            OldCoreData->Fv[Index].PeimState     = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;\r
+          }\r
+          if (OldCoreData->Fv[Index].FvFileHandles != NULL) {\r
+            OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);\r
+          }\r
         }\r
-        OldCoreData->FileGuid             = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid + OldCoreData->HeapOffset);\r
-        OldCoreData->FileHandles          = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles + OldCoreData->HeapOffset);\r
+        OldCoreData->TempFileGuid         = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid + OldCoreData->HeapOffset);\r
+        OldCoreData->TempFileHandles      = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);\r
       } else {\r
         OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);\r
-        OldCoreData->UnknownFvInfo        = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);\r
-        OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);\r
-        OldCoreData->PpiData.PpiListPtrs  = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);\r
+        if (OldCoreData->UnknownFvInfo != NULL) {\r
+          OldCoreData->UnknownFvInfo      = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->CurrentFvFileHandles != NULL) {\r
+          OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {\r
+          OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {\r
+          OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);\r
+        }\r
+        if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {\r
+          OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);\r
+        }\r
         OldCoreData->Fv                   = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);\r
-        for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
-          OldCoreData->Fv[Index].PeimState     = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;\r
-          OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);\r
+        for (Index = 0; Index < OldCoreData->FvCount; Index ++) {\r
+          if (OldCoreData->Fv[Index].PeimState != NULL) {\r
+            OldCoreData->Fv[Index].PeimState     = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;\r
+          }\r
+          if (OldCoreData->Fv[Index].FvFileHandles != NULL) {\r
+            OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);\r
+          }\r
         }\r
-        OldCoreData->FileGuid             = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid - OldCoreData->HeapOffset);\r
-        OldCoreData->FileHandles          = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles - OldCoreData->HeapOffset);\r
+        OldCoreData->TempFileGuid         = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid - OldCoreData->HeapOffset);\r
+        OldCoreData->TempFileHandles      = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles - OldCoreData->HeapOffset);\r
       }\r
 \r
-      //\r
-      // Initialize libraries that the PEI Core is linked against\r
-      //\r
-      ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r
-      \r
       //\r
       // Fixup for PeiService's address\r
       //\r
       SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r
 \r
       //\r
-      // Update HandOffHob for new installed permenent memory\r
+      // Initialize libraries that the PEI Core is linked against\r
+      //\r
+      ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r
+\r
+      //\r
+      // Update HandOffHob for new installed permanent memory\r
       //\r
       HandoffInformationTable = OldCoreData->HobList.HandoffInformationTable;\r
       if (OldCoreData->HeapOffsetPositive) {\r
@@ -230,6 +285,11 @@ PeiCore (
       HandoffInformationTable->EfiFreeMemoryTop    = OldCoreData->FreePhysicalMemoryTop;\r
       HandoffInformationTable->EfiFreeMemoryBottom = HandoffInformationTable->EfiEndOfHobList + sizeof (EFI_HOB_GENERIC_HEADER);\r
 \r
+      //\r
+      // We need convert MemoryBaseAddress in memory allocation HOBs\r
+      //\r
+      ConvertMemoryAllocationHobs (OldCoreData);\r
+\r
       //\r
       // We need convert the PPI descriptor's pointer\r
       //\r
@@ -237,7 +297,7 @@ PeiCore (
 \r
       //\r
       // After the whole temporary memory is migrated, then we can allocate page in\r
-      // permenent memory.\r
+      // permanent memory.\r
       //\r
       OldCoreData->PeiMemoryInstalled = TRUE;\r
 \r
@@ -245,7 +305,7 @@ PeiCore (
       // Indicate that PeiCore reenter\r
       //\r
       OldCoreData->PeimDispatcherReenter = TRUE;\r
-      \r
+\r
       if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (OldCoreData->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r
         //\r
         // if Loading Module at Fixed Address is enabled, allocate the PEI code memory range usage bit map array.\r
@@ -258,18 +318,24 @@ PeiCore (
       // Shadow PEI Core. When permanent memory is avaiable, shadow\r
       // PEI Core and PEIMs to get high performance.\r
       //\r
-      OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r
-      \r
+      OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) PeiCore;\r
+      if ((HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnS3Boot))\r
+          || (HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnBoot))) {\r
+        OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r
+      }\r
+\r
       //\r
       // PEI Core has now been shadowed to memory.  Restart PEI Core in memory.\r
       //\r
       OldCoreData->ShadowedPeiCore (SecCoreData, PpiList, OldCoreData);\r
-      \r
+\r
       //\r
       // Should never reach here.\r
       //\r
       ASSERT (FALSE);\r
       CpuDeadLoop();\r
+\r
+      UNREACHABLE ();\r
     }\r
 \r
     //\r
@@ -282,87 +348,60 @@ PeiCore (
 \r
     CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r
     PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r
-    \r
+\r
     CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
-    \r
+\r
     PrivateData.ServiceTableShadow.CpuIo  = CpuIo;\r
     PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
   }\r
-  \r
+\r
   //\r
   // Cache a pointer to the PEI Services Table that is either in temporary memory or permanent memory\r
   //\r
   PrivateData.Ps = &PrivateData.ServiceTableShadow;\r
 \r
   //\r
-  // Initialize libraries that the PEI Core is linked against\r
+  // Save PeiServicePointer so that it can be retrieved anywhere.\r
   //\r
-  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
+  SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
 \r
   //\r
-  // Save PeiServicePointer so that it can be retrieved anywhere.\r
+  // Initialize libraries that the PEI Core is linked against\r
   //\r
-  SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
+  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
 \r
   //\r
   // Initialize PEI Core Services\r
   //\r
-  InitializeMemoryServices   (&PrivateData,    SecCoreData, OldCoreData);\r
-  if (OldCoreData == NULL) {\r
-    //\r
-    // Initialize PEI Core Private Data Buffer\r
-    //\r
-    PrivateData.PpiData.PpiListPtrs  = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));\r
-    ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);\r
-    PrivateData.Fv                   = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    ASSERT (PrivateData.Fv != NULL);\r
-    PrivateData.Fv[0].PeimState      = AllocateZeroPool (sizeof (UINT8) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    ASSERT (PrivateData.Fv[0].PeimState != NULL);\r
-    PrivateData.Fv[0].FvFileHandles  = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);\r
-    for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
-      PrivateData.Fv[Index].PeimState     = PrivateData.Fv[Index - 1].PeimState + PcdGet32 (PcdPeiCoreMaxPeimPerFv);\r
-      PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index - 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);\r
-    }\r
-    PrivateData.UnknownFvInfo        = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r
-    ASSERT (PrivateData.UnknownFvInfo != NULL);\r
-    PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));\r
-    ASSERT (PrivateData.CurrentFvFileHandles != NULL);\r
-    PrivateData.FileGuid             = AllocatePool (sizeof (EFI_GUID) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));\r
-    ASSERT (PrivateData.FileGuid != NULL);\r
-    PrivateData.FileHandles          = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));\r
-    ASSERT (PrivateData.FileHandles != NULL);\r
-  }\r
-  InitializePpiServices      (&PrivateData,    OldCoreData);\r
-  \r
+  InitializeMemoryServices   (&PrivateData, SecCoreData, OldCoreData);\r
+\r
   //\r
-  // Update performance measurements \r
+  // Update performance measurements\r
   //\r
   if (OldCoreData == NULL) {\r
-    PERF_START (NULL, "SEC", NULL, 1);\r
-    PERF_END   (NULL, "SEC", NULL, 0);\r
+    PERF_EVENT ("SEC"); // Means the end of SEC phase.\r
 \r
     //\r
     // If first pass, start performance measurement.\r
     //\r
-    PERF_START (NULL,"PEI",    NULL, 0);\r
-    PERF_START (NULL,"PreMem", NULL, 0);\r
+    PERF_CROSSMODULE_BEGIN ("PEI");\r
+    PERF_INMODULE_BEGIN ("PreMem");\r
 \r
   } else {\r
-    PERF_END   (NULL,"PreMem",  NULL, 0);\r
-    PERF_START (NULL,"PostMem", NULL, 0);\r
+    PERF_INMODULE_END ("PreMem");\r
+    PERF_INMODULE_BEGIN ("PostMem");\r
   }\r
 \r
   //\r
   // Complete PEI Core Service initialization\r
-  //  \r
+  //\r
   InitializeSecurityServices (&PrivateData.Ps, OldCoreData);\r
   InitializeDispatcherData   (&PrivateData,    OldCoreData, SecCoreData);\r
   InitializeImageServices    (&PrivateData,    OldCoreData);\r
 \r
   //\r
   // Perform PEI Core Phase specific actions\r
-  //  \r
+  //\r
   if (OldCoreData == NULL) {\r
     //\r
     // Report Status Code EFI_SW_PC_INIT\r
@@ -371,13 +410,12 @@ PeiCore (
       EFI_PROGRESS_CODE,\r
       (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)\r
       );\r
-      \r
+\r
     //\r
-    // If SEC provided any PPI services to PEI, install them.\r
+    // If SEC provided the PpiList, process it.\r
     //\r
     if (PpiList != NULL) {\r
-      Status = PeiServicesInstallPpi (PpiList);\r
-      ASSERT_EFI_ERROR (Status);\r
+      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);\r
     }\r
   } else {\r
     //\r
@@ -399,15 +437,15 @@ PeiCore (
     //\r
     // Alert any listeners that there is permanent memory available\r
     //\r
-    PERF_START (NULL,"DisMem", NULL, 0);\r
+    PERF_INMODULE_BEGIN ("DisMem");\r
     Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r
 \r
     //\r
     // Process the Notify list and dispatch any notifies for the Memory Discovered PPI\r
     //\r
-    ProcessNotifyList (&PrivateData);\r
+    ProcessDispatchNotifyList (&PrivateData);\r
 \r
-    PERF_END (NULL,"DisMem", NULL, 0);\r
+    PERF_INMODULE_END ("DisMem");\r
   }\r
 \r
   //\r
@@ -415,15 +453,17 @@ PeiCore (
   //\r
   PeiDispatcher (SecCoreData, &PrivateData);\r
 \r
-  //\r
-  // Check if InstallPeiMemory service was called.\r
-  //\r
-  ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
+  if (PrivateData.HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) {\r
+    //\r
+    // Check if InstallPeiMemory service was called on non-S3 resume boot path.\r
+    //\r
+    ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
+  }\r
 \r
   //\r
   // Measure PEI Core execution time.\r
   //\r
-  PERF_END (NULL, "PostMem", NULL, 0);\r
+  PERF_INMODULE_END ("PostMem");\r
 \r
   //\r
   // Lookup DXE IPL PPI\r
@@ -436,6 +476,17 @@ PeiCore (
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Report status code to indicate DXE IPL PPI could not be found.\r
+    //\r
+    REPORT_STATUS_CODE (\r
+      EFI_ERROR_CODE | EFI_ERROR_MAJOR,\r
+      (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_DXEIPL_NOT_FOUND)\r
+      );\r
+    CpuDeadLoop ();\r
+  }\r
+\r
   //\r
   // Enter DxeIpl to load Dxe core.\r
   //\r
@@ -450,4 +501,6 @@ PeiCore (
   //\r
   ASSERT_EFI_ERROR (Status);\r
   CpuDeadLoop();\r
+\r
+  UNREACHABLE ();\r
 }\r