]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
Temporarily rollback the change from 5625 though 5628 for more investigation.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Dispatcher / Dispatcher.c
index 346398714947a8772f5884e2f16c079cece7451d..a4ed45af522bb353093c140e899d61df83a81d34 100644 (file)
@@ -100,7 +100,7 @@ DiscoverPeimsAndOrderWithApriori (
       Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r
       Private->AprioriCount /= sizeof (EFI_GUID);\r
 \r
-      ZeroMem (FileGuid, sizeof (FileGuid));\r
+      SetMem (FileGuid, sizeof (FileGuid), 0);\r
       for (Index = 0; Index < PeimCount; Index++) {\r
         //\r
         // Make an array of file name guids that matches the FileHandle array so we can convert\r
@@ -178,7 +178,6 @@ DiscoverPeimsAndOrderWithApriori (
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param PrivateInMem    PeiCore's private data structure\r
 \r
-  @return PeiCore function address after shadowing.\r
 **/\r
 VOID*\r
 ShadowPeiCore(\r
@@ -216,10 +215,6 @@ ShadowPeiCore(
               );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Compute the PeiCore's function address after shaowed PeiCore.\r
-  // _ModuleEntryPoint is PeiCore main function entry\r
-  //\r
   return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r
 }\r
 \r
@@ -252,6 +247,8 @@ PeiDispatcher (
   UINT32                              AuthenticationState;\r
   EFI_PHYSICAL_ADDRESS                EntryPoint;\r
   EFI_PEIM_ENTRY_POINT2               PeimEntryPoint;\r
+  BOOLEAN                             PeimNeedingDispatch;\r
+  BOOLEAN                             PeimDispatchOnThisPass;\r
   UINTN                               SaveCurrentPeimCount;\r
   UINTN                               SaveCurrentFvCount;\r
   EFI_PEI_FILE_HANDLE                 SaveCurrentFileHandle;\r
@@ -335,16 +332,9 @@ PeiDispatcher (
   // satisfied, this dipatcher should run only once.\r
   //\r
   do {\r
-    //\r
-    // In case that reenter PeiCore happens, the last pass record is still available.   \r
-    //\r
-    if (!Private->PeimDispatcherReenter) {\r
-      Private->PeimNeedingDispatch      = FALSE;\r
-      Private->PeimDispatchOnThisPass   = FALSE;\r
-    } else {\r
-      Private->PeimDispatcherReenter    = FALSE;\r
-    }\r
-    \r
+    PeimNeedingDispatch = FALSE;\r
+    PeimDispatchOnThisPass = FALSE;\r
+\r
     for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
       Private->CurrentPeimFvCount = FvCount;\r
       VolumeHandle = Private->Fv[FvCount].FvHeader;\r
@@ -369,7 +359,7 @@ PeiDispatcher (
 \r
         if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {\r
           if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r
-            Private->PeimNeedingDispatch = TRUE;\r
+            PeimNeedingDispatch = TRUE;\r
           } else {\r
             Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);\r
             ASSERT_EFI_ERROR (Status);\r
@@ -421,7 +411,7 @@ PeiDispatcher (
                   PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r
                 }\r
 \r
-                Private->PeimDispatchOnThisPass = TRUE;\r
+                PeimDispatchOnThisPass = TRUE;\r
               }\r
 \r
               REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
@@ -591,10 +581,10 @@ PeiDispatcher (
               PrivateInMem->PeiMemoryInstalled     = TRUE;\r
 \r
               //\r
-              // Indicate that PeiCore reenter\r
+              // Restart scan of all PEIMs on next pass\r
               //\r
-              Private->PeimDispatcherReenter  = TRUE;\r
-              \r
+              PrivateInMem->CurrentPeimCount = 0;\r
+\r
               //\r
               // Shadow PEI Core. When permanent memory is avaiable, shadow\r
               // PEI Core and PEIMs to get high performance.\r
@@ -678,7 +668,7 @@ PeiDispatcher (
     //  pass. If we did not dispatch a PEIM there is no point in trying again\r
     //  as it will fail the next time too (nothing has changed).\r
     //\r
-  } while (Private->PeimNeedingDispatch && Private->PeimDispatchOnThisPass);\r
+  } while (PeimNeedingDispatch && PeimDispatchOnThisPass);\r
 \r
 }\r
 \r
@@ -703,7 +693,6 @@ InitializeDispatcherData (
   )\r
 {\r
   if (OldCoreData == NULL) {\r
-    PrivateData->PeimDispatcherReenter = FALSE;\r
     PeiInitializeFv (PrivateData, SecCoreData);\r
   }\r
 \r
@@ -809,11 +798,9 @@ PeiRegisterForShadow (
   @param AuthenticationState  Pointer to attestation authentication state of image.\r
 \r
 \r
-  @retval EFI_NOT_FOUND         FV image can't be found.\r
-  @retval EFI_SUCCESS           Successfully to process it.\r
-  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
-  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
-  \r
+  @retval EFI_NOT_FOUND       FV image can't be found.\r
+  @retval EFI_SUCCESS         Successfully to process it.\r
+\r
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
@@ -827,7 +814,7 @@ ProcessFvFile (
   EFI_FV_INFO           FvImageInfo;\r
   UINT32                FvAlignment;\r
   VOID                  *FvBuffer;\r
-  EFI_PEI_HOB_POINTERS  HobPtr;\r
+  EFI_PEI_HOB_POINTERS  HobFv2;\r
 \r
   FvBuffer             = NULL;\r
   *AuthenticationState = 0;\r
@@ -836,15 +823,15 @@ ProcessFvFile (
   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r
   // been extracted.\r
   //\r
-  HobPtr.Raw = GetHobList ();\r
-  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) {\r
-    if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) {\r
+  HobFv2.Raw = GetHobList ();\r
+  while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {\r
+    if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {\r
       //\r
       // this FILE has been dispatched, it will not be dispatched again.\r
       //\r
       return EFI_SUCCESS;\r
     }\r
-    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
+    HobFv2.Raw = GET_NEXT_HOB (HobFv2);\r
   }\r
 \r
   //\r
@@ -860,13 +847,11 @@ ProcessFvFile (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
   //\r
   // Collect FvImage Info.\r
   //\r
   Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
   ASSERT_EFI_ERROR (Status);\r
-  \r
   //\r
   // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
   //\r
@@ -874,7 +859,6 @@ ProcessFvFile (
   if (FvAlignment < 8) {\r
     FvAlignment = 8;\r
   }\r
-  \r
   //\r
   // Check FvImage\r
   //\r
@@ -902,24 +886,12 @@ ProcessFvFile (
     );\r
 \r
   //\r
-  // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase\r
-  // based on its parent Fvimage is informed or not.\r
-  // If FvHob of its parent fvimage is built, the extracted FvImage will be built also. \r
-  // Or, the extracted FvImage will not be built.\r
+  // Inform HOB consumer phase, i.e. DXE core, the existance of this FV\r
   //\r
-  HobPtr.Raw = GetHobList ();\r
-  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV, HobPtr.Raw)) != NULL) {\r
-    if (((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle > HobPtr.FirmwareVolume->BaseAddress) && \r
-        ((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle < HobPtr.FirmwareVolume->BaseAddress + HobPtr.FirmwareVolume->Length)) {\r
-      BuildFvHob (\r
-        (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-        FvImageInfo.FvSize\r
-      );\r
-      break;\r
-    }\r
-    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
-  }\r
-\r
+  BuildFvHob (\r
+    (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
+    FvImageInfo.FvSize\r
+  );\r
   //\r
   // Makes the encapsulated volume show up in DXE phase to skip processing of\r
   // encapsulated file again.\r