]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Add comment for initialization value of CAR
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
index b2f7807479af44c2a49149197578f4f7cd287305..3b1d42e50922b1145240456d4f286a785641d098 100644 (file)
@@ -23,11 +23,6 @@ Revision History
 \r
 #include <PeiMain.h>\r
 \r
-//\r
-//CAR is filled with this initial value during SEC phase\r
-//\r
-#define INIT_CAR_VALUE 0x5AA55AA5\r
-\r
 static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gEfiPeiMemoryDiscoveredPpiGuid,\r
@@ -61,28 +56,30 @@ static EFI_PEI_SERVICES  mPS = {
   PeiFfsFindNextFile,\r
   PeiFfsFindSectionData,\r
 \r
-  PeiInstallPeiMemory,\r
+  PeiInstallPeiMemory,      \r
   PeiAllocatePages,\r
   PeiAllocatePool,\r
   (EFI_PEI_COPY_MEM)CopyMem,\r
   (EFI_PEI_SET_MEM)SetMem,\r
 \r
   PeiReportStatusCode,\r
-\r
   PeiResetSystem,\r
+\r
   NULL,\r
   NULL,\r
-  NULL,\r
-  NULL,\r
-  NULL,\r
+\r
+  PeiFfsFindFileByName,\r
+  PeiFfsGetFileInfo,\r
+  PeiFfsGetVolumeInfo,\r
   PeiRegisterForShadow\r
 };\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 PeiCore (\r
-  IN EFI_PEI_STARTUP_DESCRIPTOR  *PeiStartupDescriptor,\r
-  IN VOID                        *Data\r
+  IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR      *PpiList,\r
+  IN VOID                              *Data\r
   )\r
 /*++\r
 \r
@@ -94,8 +91,16 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  PeiStartupDescriptor - Information and services provided by SEC phase.\r
-  OldCoreData          - Pointer to old core data that is used to initialize the\r
+  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
+  PpiList              - Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+                         An empty PPI list consists of a single descriptor with the end-tag\r
+                         EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
+                         phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
+                         that both the PEI Foundation and any modules can leverage the associated service\r
+                         calls and/or code in these early PPIs\r
+  Data                 - Pointer to old core data that is used to initialize the\r
                          core's data areas.\r
 \r
 Returns:\r
@@ -108,9 +113,11 @@ Returns:
   PEI_CORE_INSTANCE                                     PrivateData;\r
   EFI_STATUS                                            Status;\r
   PEI_CORE_TEMP_POINTERS                                TempPtr;\r
-  PEI_CORE_DISPATCH_DATA                                *DispatchData;\r
   UINT64                                                mTick;\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
 \r
   mTick = 0;\r
   OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
@@ -121,68 +128,54 @@ Returns:
     }\r
   }\r
 \r
-  //\r
-  // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory()\r
-  //  the 63-bit of address is set to 1.\r
-  //\r
-  SWITCH_TO_CACHE_MODE (OldCoreData);\r
-\r
   if (OldCoreData != NULL) {\r
+    ShadowedPeiCore = (PEI_CORE_ENTRY_POINT) (UINTN) OldCoreData->ShadowedPeiCore;\r
+    if (ShadowedPeiCore != NULL) {\r
+      OldCoreData->ShadowedPeiCore = NULL;\r
+      ShadowedPeiCore (\r
+        SecCoreData,\r
+        PpiList,\r
+        OldCoreData\r
+        );\r
+    }\r
+\r
     CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));\r
+    \r
+    CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r
+    PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r
+    \r
+    CopyMem (&PrivateData.ServiceTableShadow, &mPS, sizeof (mPS));\r
+    \r
+    PrivateData.ServiceTableShadow.CpuIo  = CpuIo;\r
+    PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
   } else {\r
     ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
+    PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
+    CopyMem (&PrivateData.ServiceTableShadow, &mPS, sizeof (mPS));\r
   }\r
 \r
-  PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
-  PrivateData.PS = &mPS;\r
+  PrivateData.PS = &PrivateData.ServiceTableShadow;\r
 \r
   //\r
   // Initialize libraries that the PeiCore is linked against\r
-  // BUGBUG: The FfsHeader is passed in as NULL.  Do we look it up or remove it from the lib init?\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
 \r
-  InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);\r
-\r
-  InitializePpiServices (&PrivateData.PS, OldCoreData);\r
-\r
-  InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
+  InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r
 \r
-  InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);\r
+  InitializePpiServices (&PrivateData, OldCoreData);\r
 \r
+  //\r
+  // Save PeiServicePointer so that it can be retrieved anywhere.\r
+  //\r
+  SetPeiServicesTablePointer(&PrivateData.PS);\r
+  \r
   if (OldCoreData != NULL) {\r
 \r
     PERF_END (NULL,"PreMem", NULL, 0);\r
     PERF_START (NULL,"PostMem", NULL, 0);\r
 \r
-    //\r
-    // The following code dumps out interesting cache as RAM usage information\r
-    // so we can keep tabs on how the cache as RAM is being utilized.  The\r
-    // DEBUG_CODE_BEGIN macro is used to prevent this code from being compiled\r
-    // on a debug build.\r
-    //\r
-    DEBUG_CODE_BEGIN ();\r
-      UINTN  *StackPointer;\r
-      UINTN  StackValue;\r
-\r
-      StackValue = INIT_CAR_VALUE;\r
-      for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap;\r
-           ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam))\r
-           && StackValue == INIT_CAR_VALUE;\r
-           StackPointer++) {\r
-        StackValue = *StackPointer;\r
-      }\r
-\r
-      DEBUG ((EFI_D_INFO, "Total Cache as RAM:    %d bytes.\n", OldCoreData->SizeOfCacheAsRam));\r
-      DEBUG ((EFI_D_INFO, "  CAR stack ever used: %d bytes.\n",\r
-        ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer)\r
-        ));\r
-      DEBUG ((EFI_D_INFO, "  CAR heap used:       %d bytes.\n",\r
-        ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -\r
-        (UINTN) OldCoreData->HobList.Raw)\r
-        ));\r
-    DEBUG_CODE_END ();\r
-\r
     //\r
     // Alert any listeners that there is permanent memory available\r
     //\r
@@ -198,7 +191,7 @@ Returns:
     //\r
     REPORT_STATUS_CODE (\r
       EFI_PROGRESS_CODE,\r
-      EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT\r
+      FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r
       );\r
 \r
     PERF_START (NULL,"PEI", NULL, mTick);\r
@@ -210,18 +203,25 @@ Returns:
     //\r
     // If SEC provided any PPI services to PEI, install them.\r
     //\r
-    if (PeiStartupDescriptor->DispatchTable != NULL) {\r
-      Status = PeiServicesInstallPpi (PeiStartupDescriptor->DispatchTable);\r
+    if (PpiList != NULL) {\r
+      Status = PeiServicesInstallPpi (PpiList);\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
   }\r
 \r
-  DispatchData = &PrivateData.DispatchData;\r
+  InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r
+\r
+  InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r
+\r
+  //\r
+  // Install Pei Load File PPI. \r
+  //\r
+  InitializeImageServices (&PrivateData, OldCoreData);\r
 \r
   //\r
   // Call PEIM dispatcher\r
   //\r
-  PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);\r
+  PeiDispatcher (SecCoreData, &PrivateData);\r
 \r
   //\r
   // Check if InstallPeiMemory service was called.\r
@@ -250,3 +250,4 @@ Returns:
   return EFI_NOT_FOUND;\r
 }\r
 \r
+\r