mirror of https://github.com/acidanthera/audk.git
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:
parent
4f60c26f93
commit
b187ce9f15
|
@ -236,7 +236,7 @@ StartGauge (
|
||||||
//
|
//
|
||||||
mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);
|
mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);
|
||||||
|
|
||||||
gBS->FreePool (OldGaugeData);
|
FreePool (OldGaugeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
|
GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
|
||||||
|
@ -421,6 +421,12 @@ DxeCorePerformanceLibConstructor (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if (!PerformanceMeasurementEnabled ()) {
|
||||||
|
//
|
||||||
|
// Do not initialize performance infrastructure if not required.
|
||||||
|
//
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Install the protocol interfaces.
|
// Install the protocol interfaces.
|
||||||
//
|
//
|
||||||
|
|
|
@ -27,24 +27,30 @@ STATIC PERFORMANCE_PROTOCOL *mPerformance = NULL;
|
||||||
The constructor function locates Performance protocol from protocol database.
|
The constructor function locates Performance protocol from protocol database.
|
||||||
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
|
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
|
||||||
|
|
||||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
@retval EFI_SUCCESS Performance protocol is successfully located.
|
||||||
@param SystemTable A pointer to the EFI System Table.
|
@retval Other Performance protocol is not located to log performance.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
GetPerformanceProtocol (
|
||||||
PerformanceLibConstructor (
|
VOID
|
||||||
IN EFI_HANDLE ImageHandle,
|
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
PERFORMANCE_PROTOCOL *Performance;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance);
|
if (mPerformance != NULL) {
|
||||||
ASSERT_EFI_ERROR (Status);
|
return EFI_SUCCESS;
|
||||||
ASSERT (mPerformance != NULL);
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
ASSERT (Performance != NULL);
|
||||||
|
//
|
||||||
|
// Cache performance protocol.
|
||||||
|
//
|
||||||
|
mPerformance = Performance;
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -79,9 +85,14 @@ StartPerformanceMeasurement (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = GetPerformanceProtocol ();
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return RETURN_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
|
Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
|
||||||
|
|
||||||
return (RETURN_STATUS) Status;
|
return (RETURN_STATUS) Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +130,11 @@ EndPerformanceMeasurement (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = GetPerformanceProtocol ();
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return RETURN_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
|
Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
|
||||||
|
|
||||||
return (RETURN_STATUS) Status;
|
return (RETURN_STATUS) Status;
|
||||||
|
@ -181,6 +197,11 @@ GetPerformanceMeasurement (
|
||||||
ASSERT (StartTimeStamp != NULL);
|
ASSERT (StartTimeStamp != NULL);
|
||||||
ASSERT (EndTimeStamp != NULL);
|
ASSERT (EndTimeStamp != NULL);
|
||||||
|
|
||||||
|
Status = GetPerformanceProtocol ();
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);
|
Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -63,9 +63,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
<Externs>
|
<Externs>
|
||||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||||
<Extern>
|
|
||||||
<Constructor>PerformanceLibConstructor</Constructor>
|
|
||||||
</Extern>
|
|
||||||
</Externs>
|
</Externs>
|
||||||
<PcdCoded>
|
<PcdCoded>
|
||||||
<PcdEntry PcdItemType="FIXED_AT_BUILD">
|
<PcdEntry PcdItemType="FIXED_AT_BUILD">
|
||||||
|
|
Loading…
Reference in New Issue