TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmCorePerformanceLib.c File Reference

Go to the source code of this file.

Data Structures

struct  HANDLE_GUID_MAP
 

Macros

#define STRING_SIZE   (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
 
#define FIRMWARE_RECORD_BUFFER   0x1000
 
#define CACHE_HANDLE_GUID_COUNT   0x100
 

Functions

EFI_STATUS GetFpdtRecordPtr (IN UINT8 RecordSize, IN OUT FPDT_RECORD_PTR *FpdtRecordPtr)
 
BOOLEAN IsKnownTokens (IN CONST CHAR8 *Token)
 
BOOLEAN IsKnownID (IN UINT32 Identifier)
 
EFI_STATUS GetFpdtRecordId (IN PERF_MEASUREMENT_ATTRIBUTE Attribute, IN CONST VOID *Handle, IN CONST CHAR8 *String, OUT UINT16 *ProgressID)
 
EFI_STATUS EFIAPI GetModuleInfoFromHandle (IN EFI_HANDLE Handle, OUT CHAR8 *NameString, IN UINTN BufferSize, OUT EFI_GUID *ModuleGuid OPTIONAL)
 
VOID CopyStringIntoPerfRecordAndUpdateLength (IN OUT CHAR8 *Destination, IN CONST CHAR8 *Source, IN OUT UINT8 *Length)
 
EFI_STATUS InsertFpdtRecord (IN CONST VOID *CallerIdentifier OPTIONAL, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Ticker, IN UINT64 Address OPTIONAL, IN UINT16 PerfId, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)
 
EFI_STATUS EFIAPI FpdtSmiHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *RegisterContext, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
 
EFI_STATUS EFIAPI SmmCorePerformanceLibExitBootServicesCallback (IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
 
VOID EFIAPI InitializeSmmCorePerformanceLib (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI SmmCorePerformanceLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI CreatePerformanceMeasurement (IN CONST VOID *CallerIdentifier OPTIONAL, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)
 
RETURN_STATUS EFIAPI StartPerformanceMeasurementEx (IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
 
RETURN_STATUS EFIAPI EndPerformanceMeasurementEx (IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
 
UINTN EFIAPI GetPerformanceMeasurementEx (IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier)
 
RETURN_STATUS EFIAPI StartPerformanceMeasurement (IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
 
RETURN_STATUS EFIAPI EndPerformanceMeasurement (IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
 
UINTN EFIAPI GetPerformanceMeasurement (IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp)
 
BOOLEAN EFIAPI PerformanceMeasurementEnabled (VOID)
 
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)
 
BOOLEAN EFIAPI LogPerformanceMeasurementEnabled (IN CONST UINTN Type)
 

Variables

SMM_BOOT_PERFORMANCE_TABLEmSmmBootPerformanceTable = NULL
 
HANDLE_GUID_MAP mCacheHandleGuidTable [CACHE_HANDLE_GUID_COUNT]
 
UINTN mCachePairCount = 0
 
UINT32 mPerformanceLength = sizeof (SMM_BOOT_PERFORMANCE_TABLE)
 
UINT32 mMaxPerformanceLength = 0
 
UINT32 mLoadImageCount = 0
 
BOOLEAN mFpdtDataIsReported = FALSE
 
BOOLEAN mLackSpaceIsReport = FALSE
 
CHAR8 * mPlatformLanguage = NULL
 
SPIN_LOCK mSmmFpdtLock
 
PERFORMANCE_PROPERTY mPerformanceProperty
 
UINT32 mCachedLength = 0
 
UINT32 mBootRecordSize = 0
 
BOOLEAN mPerformanceMeasurementEnabled
 
EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
 

Detailed Description

Performance library instance used by SMM Core.

This library provides the performance measurement interfaces and initializes performance logging for the SMM phase. It initializes SMM phase performance logging by publishing the SMM Performance and PerformanceEx Protocol, which is consumed by SmmPerformanceLib to logging performance data in SMM phase.

This library is mainly used by SMM Core to start performance logging to ensure that SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.

Caution: This module requires additional review when modified. This driver will have external input - performance data and communicate buffer in SMM mode. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.

SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.

Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SmmCorePerformanceLib.c.

Macro Definition Documentation

◆ CACHE_HANDLE_GUID_COUNT

#define CACHE_HANDLE_GUID_COUNT   0x100

Definition at line 28 of file SmmCorePerformanceLib.c.

◆ FIRMWARE_RECORD_BUFFER

#define FIRMWARE_RECORD_BUFFER   0x1000

Definition at line 27 of file SmmCorePerformanceLib.c.

◆ STRING_SIZE

#define STRING_SIZE   (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))

Definition at line 26 of file SmmCorePerformanceLib.c.

Function Documentation

◆ CopyStringIntoPerfRecordAndUpdateLength()

VOID CopyStringIntoPerfRecordAndUpdateLength ( IN OUT CHAR8 *  Destination,
IN CONST CHAR8 *  Source,
IN OUT UINT8 *  Length 
)

Copies the string from Source into Destination and updates Length with the size of the string.

Parameters
Destination- destination of the string copy
Source- pointer to the source string which will get copied
Length- pointer to a length variable to be updated

Definition at line 464 of file SmmCorePerformanceLib.c.

◆ CreatePerformanceMeasurement()

EFI_STATUS EFIAPI CreatePerformanceMeasurement ( IN CONST VOID *CallerIdentifier  OPTIONAL,
IN CONST VOID *Guid  OPTIONAL,
IN CONST CHAR8 *String  OPTIONAL,
IN UINT64 TimeStamp  OPTIONAL,
IN UINT64 Address  OPTIONAL,
IN UINT32  Identifier,
IN PERF_MEASUREMENT_ATTRIBUTE  Attribute 
)

Create performance record with event description and a timestamp.

Parameters
CallerIdentifier- Image handle or pointer to caller ID GUID.
Guid- Pointer to a GUID.
String- Pointer to a string describing the measurement.
TimeStamp- 64-bit time stamp.
Address- Pointer to a location in memory relevant to the measurement.
Identifier- Performance identifier describing the type of measurement.
Attribute- The attribute of the measurement. According to attribute can create a start record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX, or a general record for other Perf macros.
Return values
EFI_SUCCESS- Successfully created performance record.
EFI_OUT_OF_RESOURCES- Ran out of space to store the records.
EFI_INVALID_PARAMETER- Invalid parameter passed to function - NULL pointer or invalid PerfId.

Definition at line 1110 of file SmmCorePerformanceLib.c.

◆ EndPerformanceMeasurement()

RETURN_STATUS EFIAPI EndPerformanceMeasurement ( IN CONST VOID *Handle  OPTIONAL,
IN CONST CHAR8 *Token  OPTIONAL,
IN CONST CHAR8 *Module  OPTIONAL,
IN UINT64  TimeStamp 
)

Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in a valid end time.

Searches the performance measurement log from the beginning of the log for the first record that matches Handle, Token, and Module and has an end time value of zero. If the record can not be found then return RETURN_NOT_FOUND. If the record is found and TimeStamp is not zero, then the end time in the record is filled in with the value specified by TimeStamp. If the record is found and TimeStamp is zero, then the end time in the matching record is filled in with the current time stamp value.

Parameters
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
TimeStamp64-bit time stamp.
Return values
RETURN_SUCCESSThe end of the measurement was recorded.
RETURN_NOT_FOUNDThe specified measurement record could not be found.

Definition at line 1346 of file SmmCorePerformanceLib.c.

◆ EndPerformanceMeasurementEx()

RETURN_STATUS EFIAPI EndPerformanceMeasurementEx ( IN CONST VOID *Handle  OPTIONAL,
IN CONST CHAR8 *Token  OPTIONAL,
IN CONST CHAR8 *Module  OPTIONAL,
IN UINT64  TimeStamp,
IN UINT32  Identifier 
)

Searches the performance measurement log from the beginning of the log for the first matching record that contains a zero end time and fills in a valid end time.

Searches the performance measurement log from the beginning of the log for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero. If the record can not be found then return RETURN_NOT_FOUND. If the record is found and TimeStamp is not zero, then the end time in the record is filled in with the value specified by TimeStamp. If the record is found and TimeStamp is zero, then the end time in the matching record is filled in with the current time stamp value.

Parameters
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
TimeStamp64-bit time stamp.
Identifier32-bit identifier. If the value is 0, the found record is same as the one found by EndPerformanceMeasurement.
Return values
RETURN_SUCCESSThe end of the measurement was recorded.
RETURN_NOT_FOUNDThe specified measurement record could not be found.

Definition at line 1206 of file SmmCorePerformanceLib.c.

◆ FpdtSmiHandler()

EFI_STATUS EFIAPI FpdtSmiHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *  RegisterContext,
IN OUT VOID *  CommBuffer,
IN OUT UINTN CommBufferSize 
)

Communication service SMI Handler entry.

This SMI handler provides services for report MM boot records.

Caution: This function may receive untrusted input. Communicate buffer and buffer size are external input, so this function will do basic validation.

Parameters
[in]DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
[in]RegisterContextPoints to an optional handler context which was specified when the handler was registered.
[in,out]CommBufferA pointer to a collection of data in memory that will be conveyed from a non-MM environment into an MM environment.
[in,out]CommBufferSizeThe size of the CommBuffer.
Return values
EFI_SUCCESSThe interrupt was handled and quiesced. No other handlers should still be called.
EFI_WARN_INTERRUPT_SOURCE_QUIESCEDThe interrupt has been quiesced but other handlers should still be called.
EFI_WARN_INTERRUPT_SOURCE_PENDINGThe interrupt is still pending and other handlers should still be called.
EFI_INTERRUPT_PENDINGThe interrupt could not be quiesced.

Definition at line 842 of file SmmCorePerformanceLib.c.

◆ GetFpdtRecordId()

EFI_STATUS GetFpdtRecordId ( IN PERF_MEASUREMENT_ATTRIBUTE  Attribute,
IN CONST VOID *  Handle,
IN CONST CHAR8 *  String,
OUT UINT16 *  ProgressID 
)

Get the FPDT record identifier.

Parameters
AttributeThe attribute of the Record. PerfStartEntry: Start Record. PerfEndEntry: End Record.
HandlePointer to environment specific context used to identify the component being measured.
StringPointer to a Null-terminated ASCII string that identifies the component being measured.
ProgressIDOn return, pointer to the ProgressID.
Return values
EFI_SUCCESSGet record info successfully.
EFI_INVALID_PARAMETERNo matched FPDT record.

Definition at line 202 of file SmmCorePerformanceLib.c.

◆ GetFpdtRecordPtr()

EFI_STATUS GetFpdtRecordPtr ( IN UINT8  RecordSize,
IN OUT FPDT_RECORD_PTR FpdtRecordPtr 
)

Return the pointer to the FPDT record in the allocated memory.

Parameters
RecordSizeThe size of FPDT record.
FpdtRecordPtrPointer the FPDT record in the allocated memory.
Return values
EFI_SUCCESSSuccessfully get the pointer to the FPDT record.
EFI_OUT_OF_RESOURCESRan out of space to store the records.

Definition at line 70 of file SmmCorePerformanceLib.c.

◆ GetModuleInfoFromHandle()

EFI_STATUS EFIAPI GetModuleInfoFromHandle ( IN EFI_HANDLE  Handle,
OUT CHAR8 *  NameString,
IN UINTN  BufferSize,
OUT EFI_GUID *ModuleGuid  OPTIONAL 
)

Get a human readable module name and module guid for the given image handle. If module name can't be found, "" string will return. If module guid can't be found, Zero Guid will return.

Parameters
HandleImage handle or Controller handle.
NameStringThe ascii string will be filled into it. If not found, null string will return.
BufferSizeSize of the input NameString buffer.
ModuleGuidPoint to the guid buffer to store the got module guid value.
Return values
EFI_SUCCESSSuccessfully get module name and guid.
EFI_INVALID_PARAMETERThe input parameter NameString is NULL.
othervalue Module Name can't be got.

Definition at line 265 of file SmmCorePerformanceLib.c.

◆ GetPerformanceMeasurement()

UINTN EFIAPI GetPerformanceMeasurement ( IN UINTN  LogEntryKey,
OUT CONST VOID **  Handle,
OUT CONST CHAR8 **  Token,
OUT CONST CHAR8 **  Module,
OUT UINT64 *  StartTimeStamp,
OUT UINT64 *  EndTimeStamp 
)

Attempts to retrieve a performance measurement log entry from the performance measurement log. It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx, and then eliminate the Identifier.

!!! Not Support!!!

Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is zero on entry, then an attempt is made to retrieve the first entry from the performance log, and the key for the second entry in the log is returned. If the performance log is empty, then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is retrieved and an implementation specific non-zero key value that specifies the end of the performance log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry is retrieved and zero is returned. In the cases where a performance log entry can be returned, the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp. If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT(). If Handle is NULL, then ASSERT(). If Token is NULL, then ASSERT(). If Module is NULL, then ASSERT(). If StartTimeStamp is NULL, then ASSERT(). If EndTimeStamp is NULL, then ASSERT().

Parameters
LogEntryKeyOn entry, the key of the performance measurement log entry to retrieve. 0, then the first performance measurement log entry is retrieved. On exit, the key of the next performance log entry.
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
StartTimeStampPointer to the 64-bit time stamp that was recorded when the measurement was started.
EndTimeStampPointer to the 64-bit time stamp that was recorded when the measurement was ended.
Returns
The key for the next performance log entry (in general case).

Definition at line 1399 of file SmmCorePerformanceLib.c.

◆ GetPerformanceMeasurementEx()

UINTN EFIAPI GetPerformanceMeasurementEx ( IN UINTN  LogEntryKey,
OUT CONST VOID **  Handle,
OUT CONST CHAR8 **  Token,
OUT CONST CHAR8 **  Module,
OUT UINT64 *  StartTimeStamp,
OUT UINT64 *  EndTimeStamp,
OUT UINT32 *  Identifier 
)

Attempts to retrieve a performance measurement log entry from the performance measurement log. It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement, and then assign the Identifier with 0.

!!! Not Support!!!

Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is zero on entry, then an attempt is made to retrieve the first entry from the performance log, and the key for the second entry in the log is returned. If the performance log is empty, then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is retrieved and an implementation specific non-zero key value that specifies the end of the performance log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry is retrieved and zero is returned. In the cases where a performance log entry can be returned, the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier. If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT(). If Handle is NULL, then ASSERT(). If Token is NULL, then ASSERT(). If Module is NULL, then ASSERT(). If StartTimeStamp is NULL, then ASSERT(). If EndTimeStamp is NULL, then ASSERT(). If Identifier is NULL, then ASSERT().

Parameters
LogEntryKeyOn entry, the key of the performance measurement log entry to retrieve. 0, then the first performance measurement log entry is retrieved. On exit, the key of the next performance log entry.
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
StartTimeStampPointer to the 64-bit time stamp that was recorded when the measurement was started.
EndTimeStampPointer to the 64-bit time stamp that was recorded when the measurement was ended.
IdentifierPointer to the 32-bit identifier that was recorded.
Returns
The key for the next performance log entry (in general case).

Definition at line 1272 of file SmmCorePerformanceLib.c.

◆ InitializeSmmCorePerformanceLib()

VOID EFIAPI InitializeSmmCorePerformanceLib ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

SmmBase2 protocol notify callback function, when SMST and SMM memory service get initialized this function is callbacked to initialize the Smm Performance Lib

Parameters
EventThe event of notify protocol.
ContextNotify event context.

Definition at line 972 of file SmmCorePerformanceLib.c.

◆ InsertFpdtRecord()

EFI_STATUS InsertFpdtRecord ( IN CONST VOID *CallerIdentifier  OPTIONAL,
IN CONST VOID *Guid  OPTIONAL,
IN CONST CHAR8 *String  OPTIONAL,
IN UINT64  Ticker,
IN UINT64 Address  OPTIONAL,
IN UINT16  PerfId,
IN PERF_MEASUREMENT_ATTRIBUTE  Attribute 
)

Create performance record with event description and a timestamp.

Parameters
CallerIdentifier- Image handle or pointer to caller ID GUID.
Guid- Pointer to a GUID.
String- Pointer to a string describing the measurement.
Ticker- 64-bit time stamp.
Address- Pointer to a location in memory relevant to the measurement.
PerfId- Performance identifier describing the type of measurement.
Attribute- The attribute of the measurement. According to attribute can create a start record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX, or a general record for other Perf macros.
Return values
EFI_SUCCESS- Successfully created performance record.
EFI_OUT_OF_RESOURCES- Ran out of space to store the records.
EFI_INVALID_PARAMETER- Invalid parameter passed to function - NULL pointer or invalid PerfId.
EFI_SUCCESS- Successfully created performance record
EFI_OUT_OF_RESOURCES- Ran out of space to store the records
EFI_INVALID_PARAMETER- Invalid parameter passed to function - NULL pointer or invalid PerfId

Definition at line 520 of file SmmCorePerformanceLib.c.

◆ IsKnownID()

BOOLEAN IsKnownID ( IN UINT32  Identifier)

Check whether the ID is a known one which map to the known Token.

Parameters
Identifier32-bit identifier.
Return values
TRUEIs a known one used by core.
FALSENot a known one.

Definition at line 166 of file SmmCorePerformanceLib.c.

◆ IsKnownTokens()

BOOLEAN IsKnownTokens ( IN CONST CHAR8 *  Token)

Check whether the Token is a known one which is uesed by core.

Parameters
TokenPointer to a Null-terminated ASCII string
Return values
TRUEIs a known one used by core.
FALSENot a known one.

Definition at line 131 of file SmmCorePerformanceLib.c.

◆ LogPerformanceMeasurement()

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 
)

Create performance record with event description and a timestamp.

Parameters
CallerIdentifier- Image handle or pointer to caller ID GUID
Guid- Pointer to a GUID
String- Pointer to a string describing the measurement
Address- Pointer to a location in memory relevant to the measurement
Identifier- Performance identifier describing the type of measurement
Return values
RETURN_SUCCESS- Successfully created performance record
RETURN_OUT_OF_RESOURCES- Ran out of space to store the records
RETURN_INVALID_PARAMETER- Invalid parameter passed to function - NULL pointer or invalid PerfId

Definition at line 1449 of file SmmCorePerformanceLib.c.

◆ LogPerformanceMeasurementEnabled()

BOOLEAN EFIAPI LogPerformanceMeasurementEnabled ( IN CONST UINTN  Type)

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.

Parameters
Type- Type of the performance measurement entry.
Return values
TRUEThe performance measurement can be logged.
FALSEThe performance measurement can NOT be logged.

Definition at line 1474 of file SmmCorePerformanceLib.c.

◆ PerformanceMeasurementEnabled()

BOOLEAN EFIAPI PerformanceMeasurementEnabled ( VOID  )

Returns TRUE if the performance measurement macros are enabled.

This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.

Return values
TRUEThe PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set.
FALSEThe PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is clear.

Definition at line 1425 of file SmmCorePerformanceLib.c.

◆ SmmCorePerformanceLibConstructor()

EFI_STATUS EFIAPI SmmCorePerformanceLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The constructor function initializes the Performance Measurement Enable flag and registers SmmBase2 protocol notify callback. It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe constructor always returns EFI_SUCCESS.

Definition at line 1046 of file SmmCorePerformanceLib.c.

◆ SmmCorePerformanceLibExitBootServicesCallback()

EFI_STATUS EFIAPI SmmCorePerformanceLibExitBootServicesCallback ( IN CONST EFI_GUID Protocol,
IN VOID *  Interface,
IN EFI_HANDLE  Handle 
)

This is the Event call back function is triggered in SMM to notify the Library the system is entering runtime phase.

Parameters
[in]ProtocolPoints to the protocol's unique identifier
[in]InterfacePoints to the interface instance
[in]HandleThe handle on which the interface was installed
Return values
EFI_SUCCESSSmmAtRuntimeCallBack runs successfully

Definition at line 945 of file SmmCorePerformanceLib.c.

◆ StartPerformanceMeasurement()

RETURN_STATUS EFIAPI StartPerformanceMeasurement ( IN CONST VOID *Handle  OPTIONAL,
IN CONST CHAR8 *Token  OPTIONAL,
IN CONST CHAR8 *Module  OPTIONAL,
IN UINT64  TimeStamp 
)

Adds a record at the end of the performance measurement log that records the start time of a performance measurement.

Adds a record to the end of the performance measurement log that contains the Handle, Token, and Module. The end time of the new record must be set to zero. If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record. If TimeStamp is zero, the start time in the record is filled in with the value read from the current time stamp.

Parameters
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
TimeStamp64-bit time stamp.
Return values
RETURN_SUCCESSThe start of the measurement was recorded.
RETURN_OUT_OF_RESOURCESThere are not enough resources to record the measurement.

Definition at line 1310 of file SmmCorePerformanceLib.c.

◆ StartPerformanceMeasurementEx()

RETURN_STATUS EFIAPI StartPerformanceMeasurementEx ( IN CONST VOID *Handle  OPTIONAL,
IN CONST CHAR8 *Token  OPTIONAL,
IN CONST CHAR8 *Module  OPTIONAL,
IN UINT64  TimeStamp,
IN UINT32  Identifier 
)

Adds a record at the end of the performance measurement log that records the start time of a performance measurement.

Adds a record to the end of the performance measurement log that contains the Handle, Token, Module and Identifier. The end time of the new record must be set to zero. If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record. If TimeStamp is zero, the start time in the record is filled in with the value read from the current time stamp.

Parameters
HandlePointer to environment specific context used to identify the component being measured.
TokenPointer to a Null-terminated ASCII string that identifies the component being measured.
ModulePointer to a Null-terminated ASCII string that identifies the module being measured.
TimeStamp64-bit time stamp.
Identifier32-bit identifier. If the value is 0, the created record is same as the one created by StartPerformanceMeasurement.
Return values
RETURN_SUCCESSThe start of the measurement was recorded.
RETURN_OUT_OF_RESOURCESThere are not enough resources to record the measurement.

Definition at line 1157 of file SmmCorePerformanceLib.c.

Variable Documentation

◆ mBootRecordSize

UINT32 mBootRecordSize = 0

Definition at line 50 of file SmmCorePerformanceLib.c.

◆ mCachedLength

UINT32 mCachedLength = 0

Definition at line 49 of file SmmCorePerformanceLib.c.

◆ mCacheHandleGuidTable

HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]

Definition at line 38 of file SmmCorePerformanceLib.c.

◆ mCachePairCount

UINTN mCachePairCount = 0

Definition at line 39 of file SmmCorePerformanceLib.c.

◆ mFpdtDataIsReported

BOOLEAN mFpdtDataIsReported = FALSE

Definition at line 44 of file SmmCorePerformanceLib.c.

◆ mLackSpaceIsReport

BOOLEAN mLackSpaceIsReport = FALSE

Definition at line 45 of file SmmCorePerformanceLib.c.

◆ mLoadImageCount

UINT32 mLoadImageCount = 0

Definition at line 43 of file SmmCorePerformanceLib.c.

◆ mMaxPerformanceLength

UINT32 mMaxPerformanceLength = 0

Definition at line 42 of file SmmCorePerformanceLib.c.

◆ mPerformanceLength

UINT32 mPerformanceLength = sizeof (SMM_BOOT_PERFORMANCE_TABLE)

Definition at line 41 of file SmmCorePerformanceLib.c.

◆ mPerformanceMeasurementEnabled

BOOLEAN mPerformanceMeasurementEnabled

Definition at line 51 of file SmmCorePerformanceLib.c.

◆ mPerformanceMeasurementInterface

EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
Initial value:
= {
}
EFI_STATUS EFIAPI CreatePerformanceMeasurement(IN CONST VOID *CallerIdentifier OPTIONAL, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)

Definition at line 56 of file SmmCorePerformanceLib.c.

◆ mPerformanceProperty

PERFORMANCE_PROPERTY mPerformanceProperty

Definition at line 48 of file SmmCorePerformanceLib.c.

◆ mPlatformLanguage

CHAR8* mPlatformLanguage = NULL

Definition at line 46 of file SmmCorePerformanceLib.c.

◆ mSmmBootPerformanceTable

SMM_BOOT_PERFORMANCE_TABLE* mSmmBootPerformanceTable = NULL

Definition at line 30 of file SmmCorePerformanceLib.c.

◆ mSmmFpdtLock

SPIN_LOCK mSmmFpdtLock

Definition at line 47 of file SmmCorePerformanceLib.c.