]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/FwVol/FwVol.c
Minor coding style fix.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / FwVol / FwVol.c
index 3c0046affc9536d35c011a61ec297ba7c29966c9..30485a836cc98c68b1ccb30fc8973b8f8fe81c4f 100644 (file)
@@ -368,8 +368,8 @@ FirmwareVolmeInfoPpiNotifyCallback (
   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
@@ -1156,7 +1156,7 @@ PeiFfs2FvPpiGetFileInfo (
     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
@@ -1348,14 +1348,34 @@ FindNextCoreFvHandle (
     //\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
@@ -1366,6 +1386,7 @@ FindNextCoreFvHandle (
           NULL\r
           );\r
       }\r
+      \r
       FvHob = (EFI_HOB_FIRMWARE_VOLUME *)GetNextHob (EFI_HOB_TYPE_FV, (VOID *)((UINTN)FvHob + FvHob->Header.HobLength)); \r
     }\r
   }\r
@@ -1417,7 +1438,7 @@ PeiReinitializeFv (
   //\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
@@ -1452,7 +1473,7 @@ AddUnknownFormatFvInfo (
 {\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