Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r
Private->AprioriCount /= sizeof (EFI_GUID);\r
\r
- SetMem (FileGuid, sizeof (FileGuid), 0);\r
+ ZeroMem (FileGuid, sizeof (FileGuid));\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
@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
);\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
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
// satisfied, this dipatcher should run only once.\r
//\r
do {\r
- PeimNeedingDispatch = FALSE;\r
- PeimDispatchOnThisPass = FALSE;\r
-\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
for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
Private->CurrentPeimFvCount = FvCount;\r
- VolumeHandle = Private->Fv[FvCount].FvHeader;\r
+ //\r
+ // Get this Fv Handle by PeiService FvFindNextVolume.\r
+ //\r
+ PeiFvFindNextVolume ((CONST EFI_PEI_SERVICES **) PeiServices, FvCount, &VolumeHandle);\r
\r
if (Private->CurrentPeimCount == 0) {\r
//\r
\r
if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {\r
if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r
- PeimNeedingDispatch = TRUE;\r
+ Private->PeimNeedingDispatch = TRUE;\r
} else {\r
Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);\r
ASSERT_EFI_ERROR (Status);\r
PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r
}\r
\r
- PeimDispatchOnThisPass = TRUE;\r
+ Private->PeimDispatchOnThisPass = TRUE;\r
}\r
\r
REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
PrivateInMem->PeiMemoryInstalled = TRUE;\r
\r
//\r
- // Restart scan of all PEIMs on next pass\r
+ // Indicate that PeiCore reenter\r
//\r
- PrivateInMem->CurrentPeimCount = 0;\r
-\r
+ PrivateInMem->PeimDispatcherReenter = TRUE;\r
+ \r
//\r
// Shadow PEI Core. When permanent memory is avaiable, shadow\r
// PEI Core and PEIMs to get high performance.\r
// 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 (PeimNeedingDispatch && PeimDispatchOnThisPass);\r
+ } while (Private->PeimNeedingDispatch && Private->PeimDispatchOnThisPass);\r
\r
}\r
\r
)\r
{\r
if (OldCoreData == NULL) {\r
+ PrivateData->PeimDispatcherReenter = FALSE;\r
PeiInitializeFv (PrivateData, SecCoreData);\r
}\r
\r
@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
-\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
**/\r
EFI_STATUS\r
ProcessFvFile (\r
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
if (FvAlignment < 8) {\r
FvAlignment = 8;\r
}\r
+ \r
//\r
// Check FvImage\r
//\r