summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c8
-rw-r--r--EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c45
-rw-r--r--EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa3
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.
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
- <Extern>
- <Constructor>PerformanceLibConstructor</Constructor>
- </Extern>
</Externs>
<PcdCoded>
<PcdEntry PcdItemType="FIXED_AT_BUILD">