MdeModulePkg: Update performance library instances

Update the performance library instances in MdeModulePkg
to implement the APIs used for new added Perf macros.

V2:
Share the common logics of creating FPDT record for
new added Perf macros and existing Perf macros.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Bi, Dandan
2018-06-22 16:56:19 +08:00
committed by Liming Gao
parent a08cbb95d6
commit 6b4d58a10c
8 changed files with 1604 additions and 759 deletions

View File

@ -378,3 +378,71 @@ PerformanceMeasurementEnabled (
{
return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
/**
Create performance record with event description and a timestamp.
@param CallerIdentifier - Image handle or pointer to caller ID GUID
@param Guid - Pointer to a GUID
@param String - Pointer to a string describing the measurement
@param Address - Pointer to a location in memory relevant to the measurement
@param Identifier - Performance identifier describing the type of measurement
@retval RETURN_SUCCESS - Successfully created performance record
@retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records
@retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL
pointer or invalid PerfId
**/
RETURN_STATUS
EFIAPI
LogPerformanceMeasurement (
IN CONST VOID *CallerIdentifier,
IN CONST VOID *Guid, OPTIONAL
IN CONST CHAR8 *String, OPTIONAL
IN UINT64 Address, OPTIONAL
IN UINT32 Identifier
)
{
EFI_STATUS Status;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
return RETURN_OUT_OF_RESOURCES;
}
if (mPerformanceMeasurement != NULL) {
Status = mPerformanceMeasurement->CreatePerformanceMeasurement (CallerIdentifier, Guid, String, 0, Address, Identifier, PerfEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS) Status;
}
/**
Check whether the specified performance measurement can be logged.
This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set
and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
@param Type - Type of the performance measurement entry.
@retval TRUE The performance measurement can be logged.
@retval FALSE The performance measurement can NOT be logged.
**/
BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
return TRUE;
}
return FALSE;
}