]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
authorDandan Bi <dandan.bi@intel.com>
Wed, 17 Jan 2018 01:42:42 +0000 (09:42 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 8 Feb 2018 04:50:20 +0000 (12:50 +0800)
Add FPDT records into boot performance table for S3 phase

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf

index e4800b7bdd8ab18f3d96b5ed9c33420bcc15821d..9639fbc902142a0bc6f2f4ca59e3cee8ed2b7dc1 100644 (file)
@@ -5,7 +5,7 @@
   This module register report status code listener to collect performance data\r
   for S3 Resume Performance Record on S3 resume boot path.\r
 \r
-  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <PiPei.h>\r
 \r
 #include <Ppi/ReportStatusCodeHandler.h>\r
+#include <Ppi/ReadOnlyVariable2.h>\r
 \r
 #include <Guid/FirmwarePerformance.h>\r
+#include <Guid/Performance.h>\r
+#include <Guid/ExtendedFirmwarePerformance.h>\r
 \r
 #include <Library/PeiServicesLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -29,6 +32,7 @@
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/LockBoxLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
 \r
 /**\r
   Report status code listener for PEI. This is used to record the performance\r
@@ -70,6 +74,13 @@ FpdtStatusCodeListenerPei (
   UINT64                               S3ResumeTotal;\r
   EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD  S3SuspendRecord;\r
   EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD  *AcpiS3SuspendRecord;\r
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI      *VariableServices;\r
+  UINT8                                *BootPerformanceTable;\r
+  FIRMWARE_PERFORMANCE_VARIABLE        PerformanceVariable;\r
+  EFI_HOB_GUID_TYPE                    *GuidHob;\r
+  FPDT_PEI_EXT_PERF_HEADER             *PeiPerformanceLogHeader;\r
+  UINT8                                *FirmwarePerformanceData;\r
+  UINT8                                *FirmwarePerformanceTablePtr;\r
 \r
   //\r
   // Check whether status code is what we are interested in.\r
@@ -130,6 +141,52 @@ FpdtStatusCodeListenerPei (
   DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart));\r
   DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd   = %ld\n", AcpiS3SuspendRecord->SuspendEnd));\r
 \r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiReadOnlyVariable2PpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **) &VariableServices\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Update S3 boot records into the basic boot performance table.\r
+  //\r
+  VarSize = sizeof (PerformanceVariable);\r
+  Status = VariableServices->GetVariable (\r
+                               VariableServices,\r
+                               EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,\r
+                               &gEfiFirmwarePerformanceGuid,\r
+                               NULL,\r
+                               &VarSize,\r
+                               &PerformanceVariable\r
+                               );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer;\r
+\r
+  //\r
+  // Dump PEI boot records\r
+  //\r
+  FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE));\r
+  GuidHob   = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);\r
+  while (GuidHob != NULL) {\r
+    FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob);\r
+    PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *) FirmwarePerformanceData;\r
+\r
+    CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries));\r
+\r
+    GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));\r
+\r
+    FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries);\r
+  }\r
+\r
+  //\r
+  // Update Table length.\r
+  //\r
+  ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 53b45a2017f3eb367b968c3c64ef4d51aece7515..a6ce5e64940075e9ad18c4a1f0b99eb21bdf7993 100644 (file)
@@ -6,7 +6,7 @@
 #  This module register report status code listener to collect performance data\r
 #  for S3 Resume Performance Record on S3 resume boot path.\r
 #\r
-#  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
   BaseMemoryLib\r
   LockBoxLib\r
   PcdLib\r
+  HobLib\r
 \r
 [Ppis]\r
   gEfiPeiRscHandlerPpiGuid                      ## CONSUMES\r
+  gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES\r
 \r
 [Guids]\r
   ## SOMETIMES_CONSUMES   ## UNDEFINED # RestoreLockBox\r
   gEfiFirmwarePerformanceGuid\r
   gFirmwarePerformanceS3PointerGuid             ## SOMETIMES_CONSUMES ## UNDEFINED # RestoreLockBox\r
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid     ## SOMETIMES_CONSUMES ## HOB\r
 \r
 [FeaturePcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support   ## CONSUMES\r