diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-28 08:36:01 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-28 08:36:01 +0000 |
commit | b187ce9f15c2018d3ee837b873e38eacd331d5c7 (patch) | |
tree | fd78a8c19fc2931f87847793a7ff687626f7f632 /EdkModulePkg | |
parent | 4f60c26f936d5e878e9fb941f896868c6f452f18 (diff) | |
download | edk2-b187ce9f15c2018d3ee837b873e38eacd331d5c7.tar.gz edk2-b187ce9f15c2018d3ee837b873e38eacd331d5c7.tar.bz2 edk2-b187ce9f15c2018d3ee837b873e38eacd331d5c7.zip |
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
Diffstat (limited to 'EdkModulePkg')
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">
|