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
This commit is contained in:
qhuang8 2006-08-28 08:36:01 +00:00
parent 4f60c26f93
commit b187ce9f15
3 changed files with 40 additions and 16 deletions

View File

@ -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.
//

View File

@ -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;
Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance);
ASSERT_EFI_ERROR (Status);
ASSERT (mPerformance != NULL);
if (mPerformance != NULL) {
return EFI_SUCCESS;
}
Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance);
if (!EFI_ERROR (Status)) {
ASSERT (Performance != NULL);
//
// Cache performance protocol.
//
mPerformance = Performance;
}
return Status;
}
@ -80,6 +86,11 @@ 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);
//

View File

@ -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">