public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [PATCH v5 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Date: Tue,  6 Feb 2018 18:56:44 +0800	[thread overview]
Message-ID: <1517914607-9636-6-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1517914607-9636-1-git-send-email-dandan.bi@intel.com>

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>
---
 .../FirmwarePerformancePei.c                       | 59 +++++++++++++++++++++-
 .../FirmwarePerformancePei.inf                     |  5 +-
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
index e4800b7..9639fbc 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
@@ -3,11 +3,11 @@
   Data Table in S3 resume boot mode.
 
   This module register report status code listener to collect performance data
   for S3 Resume Performance Record on S3 resume boot path.
 
-  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -17,20 +17,24 @@
 **/
 
 #include <PiPei.h>
 
 #include <Ppi/ReportStatusCodeHandler.h>
+#include <Ppi/ReadOnlyVariable2.h>
 
 #include <Guid/FirmwarePerformance.h>
+#include <Guid/Performance.h>
+#include <Guid/ExtendedFirmwarePerformance.h>
 
 #include <Library/PeiServicesLib.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/TimerLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/LockBoxLib.h>
 #include <Library/PcdLib.h>
+#include <Library/HobLib.h>
 
 /**
   Report status code listener for PEI. This is used to record the performance
   data for S3 FullResume in FPDT.
 
@@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei (
   S3_PERFORMANCE_TABLE                 *AcpiS3PerformanceTable;
   EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD   *AcpiS3ResumeRecord;
   UINT64                               S3ResumeTotal;
   EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD  S3SuspendRecord;
   EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD  *AcpiS3SuspendRecord;
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI      *VariableServices;
+  UINT8                                *BootPerformanceTable;
+  FIRMWARE_PERFORMANCE_VARIABLE        PerformanceVariable;
+  EFI_HOB_GUID_TYPE                    *GuidHob;
+  FPDT_PEI_EXT_PERF_HEADER             *PeiPerformanceLogHeader;
+  UINT8                                *FirmwarePerformanceData;
+  UINT8                                *FirmwarePerformanceTablePtr;
 
   //
   // Check whether status code is what we are interested in.
   //
   if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) ||
@@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei (
   AcpiS3SuspendRecord->SuspendEnd   = S3SuspendRecord.SuspendEnd;
 
   DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart));
   DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd   = %ld\n", AcpiS3SuspendRecord->SuspendEnd));
 
+  Status = PeiServicesLocatePpi (
+             &gEfiPeiReadOnlyVariable2PpiGuid,
+             0,
+             NULL,
+             (VOID **) &VariableServices
+             );
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Update S3 boot records into the basic boot performance table.
+  //
+  VarSize = sizeof (PerformanceVariable);
+  Status = VariableServices->GetVariable (
+                               VariableServices,
+                               EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
+                               &gEfiFirmwarePerformanceGuid,
+                               NULL,
+                               &VarSize,
+                               &PerformanceVariable
+                               );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer;
+
+  //
+  // Dump PEI boot records
+  //
+  FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE));
+  GuidHob   = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
+  while (GuidHob != NULL) {
+    FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob);
+    PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *) FirmwarePerformanceData;
+
+    CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries));
+
+    GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
+
+    FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries);
+  }
+
+  //
+  // Update Table length.
+  //
+  ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable);
+
   return EFI_SUCCESS;
 }
 
 /**
   Main entry for Firmware Performance Data Table PEIM.
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
index 53b45a2..a6ce5e6 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
@@ -4,11 +4,11 @@
 #  In S3 resume boot mode, it updates S3 Resume Performance Record in ACPI Firmware Performance Data Table.
 #
 #  This module register report status code listener to collect performance data
 #  for S3 Resume Performance Record on S3 resume boot path.
 #
-#  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
 #  
@@ -46,18 +46,21 @@
   DebugLib
   TimerLib
   BaseMemoryLib
   LockBoxLib
   PcdLib
+  HobLib
 
 [Ppis]
   gEfiPeiRscHandlerPpiGuid                      ## CONSUMES
+  gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES
 
 [Guids]
   ## SOMETIMES_CONSUMES   ## UNDEFINED # RestoreLockBox
   gEfiFirmwarePerformanceGuid
   gFirmwarePerformanceS3PointerGuid             ## SOMETIMES_CONSUMES ## UNDEFINED # RestoreLockBox
+  gEdkiiFpdtExtendedFirmwarePerformanceGuid     ## SOMETIMES_CONSUMES ## HOB
 
 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support   ## CONSUMES
 
 [Depex]
-- 
1.9.5.msysgit.1



  parent reply	other threads:[~2018-02-06 10:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 10:56 [PATCH v5 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table Dandan Bi
2018-02-06 10:56 ` [PATCH v5 1/8] MdeModulePkg:Add definitions for new Performance infrastructure Dandan Bi
2018-02-06 10:56 ` [PATCH v5 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase Dandan Bi
2018-02-06 10:56 ` [PATCH v5 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase Dandan Bi
2018-02-06 10:56 ` [PATCH v5 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase Dandan Bi
2018-02-06 10:56 ` Dandan Bi [this message]
2018-02-06 10:56 ` [PATCH v5 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure Dandan Bi
2018-02-06 10:56 ` [PATCH v5 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance " Dandan Bi
2018-02-06 10:56 ` [PATCH v5 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table Dandan Bi
2018-02-07  3:26 ` [PATCH v5 0/8] Update EDKII Performance infrastructure based on ACPI " Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517914607-9636-6-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox