From: Star Zeng Date: Sun, 12 Jun 2016 06:31:58 +0000 (-0700) Subject: MdeModulePkg: Add performance property configuration table X-Git-Tag: edk2-stable201903~4570 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=cfb0aba7934b5dc2c6495139e8e6b0b41f1d50b5 MdeModulePkg: Add performance property configuration table Define PERFORMANCE_PROPERTY, and install performance property configuration table in DxeCorePerformanceLib and SmmCorePerformanceLib. Cc: Andrew Fish Cc: Michael Kinney Cc: Liming Gao Cc: Jiewen Yao Cc: Cinnamon Shia Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Andrew Fish Reviewed-by: Jaben Carsey Reviewed-by: Jiewen Yao --- diff --git a/MdeModulePkg/Include/Guid/Performance.h b/MdeModulePkg/Include/Guid/Performance.h index c40046c878..df40c6ce5b 100644 --- a/MdeModulePkg/Include/Guid/Performance.h +++ b/MdeModulePkg/Include/Guid/Performance.h @@ -4,7 +4,7 @@ * performance protocol interfaces. * performance variables. -Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -18,6 +18,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __PERFORMANCE_DATA_H__ #define __PERFORMANCE_DATA_H__ +#define PERFORMANCE_PROPERTY_REVISION 0x1 + +typedef struct { + UINT32 Revision; + UINT32 Reserved; + UINT64 Frequency; + UINT64 TimerStartValue; + UINT64 TimerEndValue; +} PERFORMANCE_PROPERTY; + // // PEI_PERFORMANCE_STRING_SIZE must be a multiple of 8. // diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 4739bb8426..1564514518 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -10,7 +10,7 @@ This library is mainly used by DxeCore to start performance logging to ensure that Performance Protocol is installed at the very beginning of DXE phase. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -61,6 +61,8 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; +PERFORMANCE_PROPERTY mPerformanceProperty; + /** Searches in the gauge array with keyword Handle, Token, Module and Identifier. @@ -502,6 +504,8 @@ DxeCorePerformanceLibConstructor ( ) { EFI_STATUS Status; + PERFORMANCE_PROPERTY *PerformanceProperty; + if (!PerformanceMeasurementEnabled ()) { // @@ -531,7 +535,22 @@ DxeCorePerformanceLibConstructor ( InternalGetPeiPerformance (); - return Status; + Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, &PerformanceProperty); + if (EFI_ERROR (Status)) { + // + // Install configuration table for performance property. + // + mPerformanceProperty.Revision = PERFORMANCE_PROPERTY_REVISION; + mPerformanceProperty.Reserved = 0; + mPerformanceProperty.Frequency = GetPerformanceCounterProperties ( + &mPerformanceProperty.TimerStartValue, + &mPerformanceProperty.TimerEndValue + ); + Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; } /** diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf index e091c62714..5b89ce278d 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf @@ -56,11 +56,13 @@ BaseLib HobLib DebugLib + UefiLib [Guids] ## SOMETIMES_CONSUMES ## HOB ## PRODUCES ## UNDEFINED # Install protocol + ## PRODUCES ## SystemTable gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## HOB ## PRODUCES ## UNDEFINED # Install protocol diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h index 2b9ccd2fee..f1540d8c1c 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h @@ -4,7 +4,7 @@ This header file holds the prototypes of the Performance and PerformanceEx Protocol published by this library instance at its constructor. -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
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 @@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include // // Interface declarations for PerformanceEx Protocol. diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 6f8d2dd064..a03a8c8dcc 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -69,6 +69,8 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; +PERFORMANCE_PROPERTY mPerformanceProperty; + /** Searches in the gauge array with keyword Handle, Token, Module and Identfier. @@ -687,6 +689,7 @@ InitializeSmmCorePerformanceLib ( { EFI_STATUS Status; EFI_HANDLE Handle; + PERFORMANCE_PROPERTY *PerformanceProperty; // // Initialize spin lock @@ -725,6 +728,21 @@ InitializeSmmCorePerformanceLib ( ASSERT_EFI_ERROR (Status); Status = gSmst->SmiHandlerRegister (SmmPerformanceHandlerEx, &gSmmPerformanceExProtocolGuid, &Handle); ASSERT_EFI_ERROR (Status); + + Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, &PerformanceProperty); + if (EFI_ERROR (Status)) { + // + // Install configuration table for performance property. + // + mPerformanceProperty.Revision = PERFORMANCE_PROPERTY_REVISION; + mPerformanceProperty.Reserved = 0; + mPerformanceProperty.Frequency = GetPerformanceCounterProperties ( + &mPerformanceProperty.TimerStartValue, + &mPerformanceProperty.TimerEndValue + ); + Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty); + ASSERT_EFI_ERROR (Status); + } } /** diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf index 160a749390..1b2fbd3ea3 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf @@ -8,7 +8,7 @@ # This library is mainly used by SMM Core to start performance logging to ensure that # SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase. # -# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
# 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 @@ -57,6 +57,7 @@ SynchronizationLib SmmServicesTableLib SmmMemLib + UefiLib [Protocols] gEfiSmmBase2ProtocolGuid ## CONSUMES @@ -68,6 +69,8 @@ ## PRODUCES ## UNDEFINED # Install protocol ## CONSUMES ## UNDEFINED # SmiHandlerRegister gSmmPerformanceExProtocolGuid + ## PRODUCES ## SystemTable + gPerformanceProtocolGuid [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES