]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.
[mirror_edk2.git] / IntelFsp2WrapperPkg / FspsWrapperPeim / FspsWrapperPeim.c
index b20f0805a021925df092b13b0fddd637055b9ddb..9d4f279e817264adb7ac8f48d542c9307d4cef5b 100644 (file)
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi\r
   notify to call FspSiliconInit API.\r
 \r
-  Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include <Library/TimerLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/FspWrapperApiLib.h>\r
+#include <Library/FspMeasurementLib.h>\r
 \r
 #include <Ppi/FspSiliconInitDone.h>\r
 #include <Ppi/EndOfPeiPhase.h>\r
 #include <Ppi/MemoryDiscovered.h>\r
 #include <Ppi/TemporaryRamDone.h>\r
 #include <Ppi/SecPlatformInformation.h>\r
+#include <Ppi/Tcg.h>\r
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>\r
 #include <Library/FspWrapperApiTestLib.h>\r
 #include <FspEas.h>\r
 #include <FspStatusCode.h>\r
@@ -379,7 +382,25 @@ FspsWrapperInitDispatchMode (
   VOID\r
   )\r
 {\r
-  EFI_STATUS           Status;\r
+  EFI_STATUS                                            Status;\r
+  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;\r
+  EFI_PEI_PPI_DESCRIPTOR                                *MeasurementExcludedPpiList;\r
+\r
+  MeasurementExcludedFvPpi = AllocatePool (sizeof(*MeasurementExcludedFvPpi));\r
+  ASSERT(MeasurementExcludedFvPpi != NULL);\r
+  MeasurementExcludedFvPpi->Count = 1;\r
+  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddress);\r
+  MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength;\r
+\r
+  MeasurementExcludedPpiList = AllocatePool (sizeof(*MeasurementExcludedPpiList));\r
+  ASSERT(MeasurementExcludedPpiList != NULL);\r
+  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
+  MeasurementExcludedPpiList->Guid  = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;\r
+  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;\r
+\r
+  Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
   // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.\r
   //\r
@@ -398,6 +419,62 @@ FspsWrapperInitDispatchMode (
   return Status;\r
 }\r
 \r
+/**\r
+  This function is called after TCG installed PPI.\r
+\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TcgPpiNotify (\r
+  IN EFI_PEI_SERVICES          **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
+  IN VOID                      *Ppi\r
+  );\r
+\r
+EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEdkiiTcgPpiGuid,\r
+  TcgPpiNotify\r
+};\r
+\r
+/**\r
+  This function is called after TCG installed PPI.\r
+\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
+\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TcgPpiNotify (\r
+  IN EFI_PEI_SERVICES          **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
+  IN VOID                      *Ppi\r
+  )\r
+{\r
+  UINT32                    FspMeasureMask;\r
+\r
+  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));\r
+\r
+  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);\r
+\r
+  if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {\r
+    MeasureFspFirmwareBlob (0, "FSPS", PcdGet32(PcdFspsBaseAddress),\r
+                            (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspsBaseAddress))->FvLength);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   This is the entrypoint of PEIM.\r
 \r
@@ -413,8 +490,13 @@ FspsWrapperPeimEntryPoint (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
+  EFI_STATUS  Status;\r
+\r
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
 \r
+  Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   if (PcdGet8 (PcdFspModeSelection) == 1) {\r
     FspsWrapperInitApiMode ();\r
   } else {\r