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
- 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
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\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
#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
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
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