Status = EFI_SUCCESS;\r
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
\r
- if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
- DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));\r
+ if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
+ DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, FixedPcdGet32 (PcdPeiCoreMaxFvSupported)));\r
DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));\r
ASSERT (FALSE);\r
}\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (CoreFvHandle->FvHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
+ if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
ErasePolarity = 1;\r
} else {\r
ErasePolarity = 0;\r
//\r
FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetFirstHob (EFI_HOB_TYPE_FV);\r
while (FvHob != NULL) {\r
+ //\r
+ // Search whether FvHob has been installed into PeiCore's FV database.\r
+ // If found, no need install new FvInfoPpi for it.\r
+ //\r
for (Index = 0, Match = FALSE; Index < Private->FvCount; Index++) {\r
if ((EFI_PEI_FV_HANDLE)(UINTN)FvHob->BaseAddress == Private->Fv[Index].FvHeader) {\r
Match = TRUE;\r
break;\r
}\r
}\r
+ \r
//\r
- // If Not Found, Install FvInfo Ppi for it.\r
+ // Search whether FvHob has been cached into PeiCore's Unknown FV database.\r
+ // If found, no need install new FvInfoPpi for it.\r
+ //\r
+ if (!Match) {\r
+ for (Index = 0; Index < Private->UnknownFvInfoCount; Index ++) {\r
+ if ((UINTN)FvHob->BaseAddress == (UINTN)Private->UnknownFvInfo[Index].FvInfo) {\r
+ Match = TRUE;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // If the Fv in FvHob has not been installed into PeiCore's FV database and has\r
+ // not been cached into PeiCore's Unknown FV database, install a new FvInfoPpi\r
+ // for it then PeiCore will dispatch it in callback of FvInfoPpi.\r
//\r
if (!Match) {\r
PeiServicesInstallFvInfoPpi (\r
NULL\r
);\r
}\r
+ \r
FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetNextHob (EFI_HOB_TYPE_FV, (VOID *)((UINTN)FvHob + FvHob->Header.HobLength)); \r
}\r
}\r
//\r
// Fixup all FvPpi pointers for the implementation in flash to permanent memory.\r
//\r
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
+ for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
if (PrivateData->Fv[Index].FvPpi == OldFfs2FvPpi) {\r
PrivateData->Fv[Index].FvPpi = &mPeiFfs2FvPpi;\r
}\r
{\r
PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;\r
\r
- if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxPeimPerFv)) {\r
+ if (PrivateData->UnknownFvInfoCount + 1 >= FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r