]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/SecCore/SecBist.c
UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI
[mirror_edk2.git] / UefiCpuPkg / SecCore / SecBist.c
index 10bebbca743559c538e39abbe1586b16253afbd5..dd5c5e5edacf7156c5a3d69b7a075b41cefb22a1 100644 (file)
 \r
 #include "SecMain.h"\r
 \r
+EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformation = {\r
+  SecPlatformInformationBist\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiSecPlatformInformationPpiGuid,\r
+  &mSecPlatformInformation\r
+};\r
+\r
+EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2 = {\r
+  SecPlatformInformation2Bist\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2 = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiSecPlatformInformation2PpiGuid,\r
+  &mSecPlatformInformation2\r
+};\r
+\r
 /**\r
   Worker function to parse CPU BIST information from Guided HOB.\r
 \r
@@ -179,3 +199,70 @@ GetBistInfoFromPpi (
 \r
   return EFI_DEVICE_ERROR;\r
 }\r
+\r
+/**\r
+  Get CPUs' BIST by calling SecPlatformInformationPpi/SecPlatformInformation2Ppi.\r
+\r
+**/\r
+VOID\r
+RepublishSecPlatformInformationPpi (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                            Status;\r
+  CONST EFI_PEI_SERVICES                **PeiServices;\r
+  UINT64                                BistInformationSize;\r
+  VOID                                  *BistInformationData;\r
+  EFI_PEI_PPI_DESCRIPTOR                *SecInformationDescriptor;\r
+\r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  Status = GetBistInfoFromPpi (\r
+             PeiServices,\r
+             &gEfiSecPlatformInformation2PpiGuid,\r
+             &SecInformationDescriptor,\r
+             &BistInformationData,\r
+             &BistInformationSize\r
+             );\r
+  if (Status == EFI_SUCCESS) {\r
+    BuildGuidDataHob (\r
+      &gEfiCallerIdGuid,\r
+      BistInformationData,\r
+      (UINTN) BistInformationSize\r
+      );\r
+    //\r
+    // The old SecPlatformInformation data is on CAR.\r
+    // After memory discovered, we should never get it from CAR, or the data will be crashed.\r
+    // So, we reinstall SecPlatformInformation PPI here.\r
+    //\r
+    Status = PeiServicesReInstallPpi (\r
+               SecInformationDescriptor,\r
+               &mPeiSecPlatformInformation2\r
+               );\r
+  } if (Status == EFI_NOT_FOUND) {\r
+    Status = GetBistInfoFromPpi (\r
+               PeiServices,\r
+               &gEfiSecPlatformInformationPpiGuid,\r
+               &SecInformationDescriptor,\r
+               &BistInformationData,\r
+               &BistInformationSize\r
+               );\r
+    if (Status == EFI_SUCCESS) {\r
+      BuildGuidDataHob (\r
+        &gEfiCallerIdGuid,\r
+        BistInformationData,\r
+        (UINTN) BistInformationSize\r
+        );\r
+      //\r
+      // The old SecPlatformInformation2 data is on CAR.\r
+      // After memory discovered, we should never get it from CAR, or the data will be crashed.\r
+      // So, we reinstall SecPlatformInformation2 PPI here.\r
+      //\r
+      Status = PeiServicesReInstallPpi (\r
+                 SecInformationDescriptor,\r
+                 &mPeiSecPlatformInformation\r
+                 );\r
+    }\r
+  }\r
+\r
+  ASSERT_EFI_ERROR(Status);\r
+}\r