]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI
authorJeff Fan <jeff.fan@intel.com>
Fri, 9 Sep 2016 07:14:32 +0000 (15:14 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 14 Sep 2016 00:54:46 +0000 (08:54 +0800)
In SecTemporaryRamDone(), we will build one privated GUIDed-HOB to save CPU BIST
Data and re-install SEC platform information(2) PPI. Then other PEI drivers
could get CPU BIST data from the private GUIDed-HOB by new installed PPI.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@Intel.com>
UefiCpuPkg/SecCore/SecBist.c
UefiCpuPkg/SecCore/SecCore.inf
UefiCpuPkg/SecCore/SecMain.c
UefiCpuPkg/SecCore/SecMain.h

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
index e875cffd5cd26c111899549f4b95fcce30d4aeac..0d135e62ec33c48381c1c33a923069a8b5ad6e0c 100644 (file)
   HobLib\r
 \r
 [Ppis]\r
-  gEfiSecPlatformInformationPpiGuid                    ## PRODUCES\r
+  ## SOMETIMES_CONSUMES\r
+  ## PRODUCES\r
+  gEfiSecPlatformInformationPpiGuid\r
+  ## SOMETIMES_CONSUMES\r
+  ## SOMETIMES_PRODUCES\r
+  gEfiSecPlatformInformation2PpiGuid\r
   gEfiTemporaryRamDonePpiGuid                          ## PRODUCES\r
 \r
 [Pcd]\r
index 5e5d543e193425a4615eb257e49452742c6ffbc4..af1e661a307a9e871bdb6f56116ee6feeb11dbbc 100644 (file)
@@ -273,6 +273,11 @@ SecTemporaryRamDone (
 {\r
   BOOLEAN  State;\r
 \r
+  //\r
+  // Republish Sec Platform Information(2) PPI\r
+  //\r
+  RepublishSecPlatformInformationPpi ();\r
+\r
   //\r
   // Migrate DebugAgentContext.\r
   //\r
index 2484a0f05a71c24f3e9b0d15efa43cede90370cf..6e31a953f75720623dbae945aac54ed6e718a46e 100644 (file)
@@ -109,4 +109,52 @@ ProcessLibraryConstructorList (
   VOID\r
   );\r
 \r
+/**\r
+  Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI.\r
+\r
+  @param  PeiServices                Pointer to the PEI Services Table.\r
+  @param  StructureSize              Pointer to the variable describing size of the input buffer.\r
+  @param  PlatformInformationRecord  Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.\r
+\r
+  @retval EFI_SUCCESS                The data was successfully returned.\r
+  @retval EFI_BUFFER_TOO_SMALL       The buffer was too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecPlatformInformationBist (\r
+  IN CONST EFI_PEI_SERVICES                  **PeiServices,\r
+  IN OUT UINT64                              *StructureSize,\r
+     OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r
+  );\r
+\r
+/**\r
+  Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.\r
+\r
+  @param  PeiServices                The pointer to the PEI Services Table.\r
+  @param  StructureSize              The pointer to the variable describing size of the input buffer.\r
+  @param  PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.\r
+\r
+  @retval EFI_SUCCESS                The data was successfully returned.\r
+  @retval EFI_BUFFER_TOO_SMALL       The buffer was too small. The current buffer size needed to\r
+                                     hold the record is returned in StructureSize.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecPlatformInformation2Bist (\r
+  IN CONST EFI_PEI_SERVICES                   **PeiServices,\r
+  IN OUT UINT64                               *StructureSize,\r
+     OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r
+  );\r
+\r
+/**\r
+  Republish SecPlatformInformationPpi/SecPlatformInformation2Ppi.\r
+\r
+**/\r
+VOID\r
+RepublishSecPlatformInformationPpi (\r
+  VOID\r
+  );\r
+\r
 #endif\r