From b187ce9f15c2018d3ee837b873e38eacd331d5c7 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Mon, 28 Aug 2006 08:36:01 +0000 Subject: [PATCH] Modify the implementation of performance library so that: PcdPerformanceLibraryPropertyMask can turn on/off performance measurement. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1395 6f19259b-4bc3-4df7-8a09-765794883524 --- .../DxeCorePerformanceLib.c | 8 +++- .../DxePerformanceLib/DxePerformanceLib.c | 45 ++++++++++++++----- .../DxePerformanceLib/DxePerformanceLib.msa | 3 -- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 5874902e2e..64c7454c66 100644 --- a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -236,7 +236,7 @@ StartGauge ( // mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize); - gBS->FreePool (OldGaugeData); + FreePool (OldGaugeData); } GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1); @@ -421,6 +421,12 @@ DxeCorePerformanceLibConstructor ( { EFI_STATUS Status; + if (!PerformanceMeasurementEnabled ()) { + // + // Do not initialize performance infrastructure if not required. + // + return EFI_SUCCESS; + } // // Install the protocol interfaces. // diff --git a/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index 8a3ac4053f..74d71c54d9 100644 --- a/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -27,24 +27,30 @@ STATIC PERFORMANCE_PROTOCOL *mPerformance = NULL; The constructor function locates Performance protocol from protocol database. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + @retval EFI_SUCCESS Performance protocol is successfully located. + @retval Other Performance protocol is not located to log performance. **/ EFI_STATUS -EFIAPI -PerformanceLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +GetPerformanceProtocol ( + VOID ) { EFI_STATUS Status; + PERFORMANCE_PROTOCOL *Performance; + + if (mPerformance != NULL) { + return EFI_SUCCESS; + } - Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance); - ASSERT_EFI_ERROR (Status); - ASSERT (mPerformance != NULL); + Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance); + if (!EFI_ERROR (Status)) { + ASSERT (Performance != NULL); + // + // Cache performance protocol. + // + mPerformance = Performance; + } return Status; } @@ -79,9 +85,14 @@ StartPerformanceMeasurement ( ) { EFI_STATUS Status; + + Status = GetPerformanceProtocol (); + if (EFI_ERROR (Status)) { + return RETURN_OUT_OF_RESOURCES; + } Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp); - + return (RETURN_STATUS) Status; } @@ -119,6 +130,11 @@ EndPerformanceMeasurement ( { EFI_STATUS Status; + Status = GetPerformanceProtocol (); + if (EFI_ERROR (Status)) { + return RETURN_NOT_FOUND; + } + Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp); return (RETURN_STATUS) Status; @@ -181,6 +197,11 @@ GetPerformanceMeasurement ( ASSERT (StartTimeStamp != NULL); ASSERT (EndTimeStamp != NULL); + Status = GetPerformanceProtocol (); + if (EFI_ERROR (Status)) { + return 0; + } + Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData); // diff --git a/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa b/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa index 3ec7a0b6ef..3be18f90dd 100644 --- a/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa +++ b/EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa @@ -63,9 +63,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00020000 - - PerformanceLibConstructor - -- 2.39.2