summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Acpi
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2018-01-17 09:42:42 +0800
committerLiming Gao <liming.gao@intel.com>2018-02-08 12:50:20 +0800
commit2040e6c556e0f39236fc9bc1cfca61afe9dad3bf (patch)
treef7d77391562add3fef08c47ededdd151735d4866 /MdeModulePkg/Universal/Acpi
parent2001f84e8c21ff0d8adc1670fcec787b5b12b036 (diff)
downloadedk2-2040e6c556e0f39236fc9bc1cfca61afe9dad3bf.tar.gz
edk2-2040e6c556e0f39236fc9bc1cfca61afe9dad3bf.tar.bz2
edk2-2040e6c556e0f39236fc9bc1cfca61afe9dad3bf.zip
MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
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>
Diffstat (limited to 'MdeModulePkg/Universal/Acpi')
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c59
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf5
2 files changed, 62 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
index e4800b7bdd..9639fbc902 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
@@ -5,7 +5,7 @@
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
@@ -19,8 +19,11 @@
#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>
@@ -29,6 +32,7 @@
#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
@@ -70,6 +74,13 @@ FpdtStatusCodeListenerPei (
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.
@@ -130,6 +141,52 @@ FpdtStatusCodeListenerPei (
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;
}
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
index 53b45a2017..a6ce5e6494 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
@@ -6,7 +6,7 @@
# 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
@@ -48,14 +48,17 @@
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