2 Performance library instance mainly used by DxeCore.
4 This library provides the performance measurement interfaces and initializes performance
5 logging for DXE phase. It first initializes its private global data structure for
6 performance logging and saves the performance GUIDed HOB passed from PEI phase.
7 It initializes DXE phase performance logging by publishing the Performance and PerformanceEx Protocol,
8 which are consumed by DxePerformanceLib to logging performance data in DXE phase.
10 This library is mainly used by DxeCore to start performance logging to ensure that
11 Performance Protocol is installed at the very beginning of DXE phase.
13 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
14 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
15 This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #include "DxeCorePerformanceLibInternal.h"
29 // Data for FPDT performance records.
31 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
32 #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
33 #define FIRMWARE_RECORD_BUFFER 0x10000
34 #define CACHE_HANDLE_GUID_COUNT 0x800
36 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
37 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
39 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
40 sizeof (BOOT_PERFORMANCE_TABLE
)
44 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
45 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
46 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
50 // These values will be updated at runtime.
53 0, // OsLoaderLoadImageStart
54 0, // OsLoaderStartImageStart
55 0, // ExitBootServicesEntry
56 0 // ExitBootServicesExit
62 CHAR8 NameString
[FPDT_STRING_EVENT_RECORD_NAME_LENGTH
];
66 HANDLE_GUID_MAP mCacheHandleGuidTable
[CACHE_HANDLE_GUID_COUNT
];
67 UINTN mCachePairCount
= 0;
69 UINT32 mLoadImageCount
= 0;
70 UINT32 mPerformanceLength
= 0;
71 UINT32 mMaxPerformanceLength
= 0;
72 UINT32 mBootRecordSize
= 0;
73 UINT32 mBootRecordMaxSize
= 0;
74 UINT32 mCachedLength
= 0;
76 BOOLEAN mFpdtBufferIsReported
= FALSE
;
77 BOOLEAN mLackSpaceIsReported
= FALSE
;
78 CHAR8
*mPlatformLanguage
= NULL
;
79 UINT8
*mPerformancePointer
= NULL
;
80 UINT8
*mBootRecordBuffer
= NULL
;
81 BOOLEAN mLockInsertRecord
= FALSE
;
82 CHAR8
*mDevicePathString
= NULL
;
84 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*mDevicePathToText
= NULL
;
87 // Interfaces for PerformanceMeasurement Protocol.
89 EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
= {
90 CreatePerformanceMeasurement
,
93 PERFORMANCE_PROPERTY mPerformanceProperty
;
96 Return the pointer to the FPDT record in the allocated memory.
98 @param RecordSize The size of FPDT record.
99 @param FpdtRecordPtr Pointer the FPDT record in the allocated memory.
101 @retval EFI_SUCCESS Successfully get the pointer to the FPDT record.
102 @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records.
107 IN OUT FPDT_RECORD_PTR
*FpdtRecordPtr
110 if (mFpdtBufferIsReported
) {
112 // Append Boot records to the boot performance table.
114 if (mBootRecordSize
+ RecordSize
> mBootRecordMaxSize
) {
115 if (!mLackSpaceIsReported
) {
116 DEBUG ((DEBUG_INFO
, "DxeCorePerformanceLib: No enough space to save boot records\n"));
117 mLackSpaceIsReported
= TRUE
;
119 return EFI_OUT_OF_RESOURCES
;
122 // Save boot record into BootPerformance table
124 FpdtRecordPtr
->RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mBootRecordSize
);
128 // Check if pre-allocated buffer is full
130 if (mPerformanceLength
+ RecordSize
> mMaxPerformanceLength
) {
131 mPerformancePointer
= ReallocatePool (
133 mPerformanceLength
+ RecordSize
+ FIRMWARE_RECORD_BUFFER
,
136 if (mPerformancePointer
== NULL
) {
137 return EFI_OUT_OF_RESOURCES
;
139 mMaxPerformanceLength
= mPerformanceLength
+ RecordSize
+ FIRMWARE_RECORD_BUFFER
;
142 // Covert buffer to FPDT Ptr Union type.
144 FpdtRecordPtr
->RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mPerformanceLength
);
150 Check whether the Token is a known one which is uesed by core.
152 @param Token Pointer to a Null-terminated ASCII string
154 @retval TRUE Is a known one used by core.
155 @retval FALSE Not a known one.
160 IN CONST CHAR8
*Token
167 if (AsciiStrCmp (Token
, SEC_TOK
) == 0 ||
168 AsciiStrCmp (Token
, PEI_TOK
) == 0 ||
169 AsciiStrCmp (Token
, DXE_TOK
) == 0 ||
170 AsciiStrCmp (Token
, BDS_TOK
) == 0 ||
171 AsciiStrCmp (Token
, DRIVERBINDING_START_TOK
) == 0 ||
172 AsciiStrCmp (Token
, DRIVERBINDING_SUPPORT_TOK
) == 0 ||
173 AsciiStrCmp (Token
, DRIVERBINDING_STOP_TOK
) == 0 ||
174 AsciiStrCmp (Token
, LOAD_IMAGE_TOK
) == 0 ||
175 AsciiStrCmp (Token
, START_IMAGE_TOK
) == 0 ||
176 AsciiStrCmp (Token
, PEIM_TOK
) == 0) {
184 Check whether the ID is a known one which map to the known Token.
186 @param Identifier 32-bit identifier.
188 @retval TRUE Is a known one used by core.
189 @retval FALSE Not a known one.
197 if (Identifier
== MODULE_START_ID
||
198 Identifier
== MODULE_END_ID
||
199 Identifier
== MODULE_LOADIMAGE_START_ID
||
200 Identifier
== MODULE_LOADIMAGE_END_ID
||
201 Identifier
== MODULE_DB_START_ID
||
202 Identifier
== MODULE_DB_END_ID
||
203 Identifier
== MODULE_DB_SUPPORT_START_ID
||
204 Identifier
== MODULE_DB_SUPPORT_END_ID
||
205 Identifier
== MODULE_DB_STOP_START_ID
||
206 Identifier
== MODULE_DB_STOP_END_ID
) {
214 Allocate buffer for Boot Performance table.
220 AllocateBootPerformanceTable (
225 UINT8
*SmmBootRecordCommBuffer
;
226 EFI_SMM_COMMUNICATE_HEADER
*SmmCommBufferHeader
;
227 SMM_BOOT_RECORD_COMMUNICATE
*SmmCommData
;
229 UINTN BootPerformanceDataSize
;
230 UINT8
*BootPerformanceData
;
231 EFI_SMM_COMMUNICATION_PROTOCOL
*Communication
;
232 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
233 EDKII_PI_SMM_COMMUNICATION_REGION_TABLE
*SmmCommRegionTable
;
234 EFI_MEMORY_DESCRIPTOR
*SmmCommMemRegion
;
236 VOID
*SmmBootRecordData
;
237 UINTN SmmBootRecordDataSize
;
238 UINTN ReservedMemSize
;
241 // Collect boot records from SMM drivers.
243 SmmBootRecordCommBuffer
= NULL
;
245 SmmBootRecordData
= NULL
;
246 SmmBootRecordDataSize
= 0;
248 Status
= gBS
->LocateProtocol (&gEfiSmmCommunicationProtocolGuid
, NULL
, (VOID
**) &Communication
);
249 if (!EFI_ERROR (Status
)) {
251 // Initialize communicate buffer
252 // Get the prepared Reserved Memory Range
254 Status
= EfiGetSystemConfigurationTable (
255 &gEdkiiPiSmmCommunicationRegionTableGuid
,
256 (VOID
**) &SmmCommRegionTable
258 if (!EFI_ERROR (Status
)) {
259 ASSERT (SmmCommRegionTable
!= NULL
);
260 SmmCommMemRegion
= (EFI_MEMORY_DESCRIPTOR
*) (SmmCommRegionTable
+ 1);
261 for (Index
= 0; Index
< SmmCommRegionTable
->NumberOfEntries
; Index
++) {
262 if (SmmCommMemRegion
->Type
== EfiConventionalMemory
) {
265 SmmCommMemRegion
= (EFI_MEMORY_DESCRIPTOR
*) ((UINT8
*) SmmCommMemRegion
+ SmmCommRegionTable
->DescriptorSize
);
267 ASSERT (Index
< SmmCommRegionTable
->NumberOfEntries
);
268 ASSERT (SmmCommMemRegion
->PhysicalStart
> 0);
269 ASSERT (SmmCommMemRegion
->NumberOfPages
> 0);
270 ReservedMemSize
= (UINTN
) SmmCommMemRegion
->NumberOfPages
* EFI_PAGE_SIZE
;
273 // Check enough reserved memory space
275 if (ReservedMemSize
> SMM_BOOT_RECORD_COMM_SIZE
) {
276 SmmBootRecordCommBuffer
= (VOID
*) (UINTN
) SmmCommMemRegion
->PhysicalStart
;
277 SmmCommBufferHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)SmmBootRecordCommBuffer
;
278 SmmCommData
= (SMM_BOOT_RECORD_COMMUNICATE
*)SmmCommBufferHeader
->Data
;
279 ZeroMem((UINT8
*)SmmCommData
, sizeof(SMM_BOOT_RECORD_COMMUNICATE
));
281 CopyGuid (&SmmCommBufferHeader
->HeaderGuid
, &gEfiFirmwarePerformanceGuid
);
282 SmmCommBufferHeader
->MessageLength
= sizeof(SMM_BOOT_RECORD_COMMUNICATE
);
283 CommSize
= SMM_BOOT_RECORD_COMM_SIZE
;
286 // Get the size of boot records.
288 SmmCommData
->Function
= SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE
;
289 SmmCommData
->BootRecordData
= NULL
;
290 Status
= Communication
->Communicate (Communication
, SmmBootRecordCommBuffer
, &CommSize
);
292 if (!EFI_ERROR (Status
) && !EFI_ERROR (SmmCommData
->ReturnStatus
) && SmmCommData
->BootRecordSize
!= 0) {
294 // Get all boot records
296 SmmCommData
->Function
= SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET
;
297 SmmBootRecordDataSize
= SmmCommData
->BootRecordSize
;
298 SmmBootRecordData
= AllocateZeroPool(SmmBootRecordDataSize
);
299 ASSERT (SmmBootRecordData
!= NULL
);
300 SmmCommData
->BootRecordOffset
= 0;
301 SmmCommData
->BootRecordData
= (VOID
*) ((UINTN
) SmmCommMemRegion
->PhysicalStart
+ SMM_BOOT_RECORD_COMM_SIZE
);
302 SmmCommData
->BootRecordSize
= ReservedMemSize
- SMM_BOOT_RECORD_COMM_SIZE
;
303 while (SmmCommData
->BootRecordOffset
< SmmBootRecordDataSize
) {
304 Status
= Communication
->Communicate (Communication
, SmmBootRecordCommBuffer
, &CommSize
);
305 ASSERT_EFI_ERROR (Status
);
306 ASSERT_EFI_ERROR(SmmCommData
->ReturnStatus
);
307 if (SmmCommData
->BootRecordOffset
+ SmmCommData
->BootRecordSize
> SmmBootRecordDataSize
) {
308 CopyMem ((UINT8
*) SmmBootRecordData
+ SmmCommData
->BootRecordOffset
, SmmCommData
->BootRecordData
, SmmBootRecordDataSize
- SmmCommData
->BootRecordOffset
);
310 CopyMem ((UINT8
*) SmmBootRecordData
+ SmmCommData
->BootRecordOffset
, SmmCommData
->BootRecordData
, SmmCommData
->BootRecordSize
);
312 SmmCommData
->BootRecordOffset
= SmmCommData
->BootRecordOffset
+ SmmCommData
->BootRecordSize
;
320 // Prepare memory for Boot Performance table.
321 // Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
323 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
) + mPerformanceLength
+ PcdGet32 (PcdExtFpdtBootRecordPadSize
);
324 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
325 BootPerformanceDataSize
+= SmmBootRecordDataSize
;
329 // Try to allocate the same runtime buffer as last time boot.
331 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
332 Size
= sizeof (PerformanceVariable
);
333 Status
= gRT
->GetVariable (
334 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
335 &gEfiFirmwarePerformanceGuid
,
340 if (!EFI_ERROR (Status
)) {
341 Status
= gBS
->AllocatePages (
343 EfiReservedMemoryType
,
344 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
345 &PerformanceVariable
.BootPerformanceTablePointer
347 if (!EFI_ERROR (Status
)) {
348 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
352 if (mAcpiBootPerformanceTable
== NULL
) {
354 // Fail to allocate at specified address, continue to allocate at any address.
356 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
357 EfiReservedMemoryType
,
358 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
360 if (mAcpiBootPerformanceTable
!= NULL
) {
361 ZeroMem (mAcpiBootPerformanceTable
, BootPerformanceDataSize
);
364 DEBUG ((DEBUG_INFO
, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
366 if (mAcpiBootPerformanceTable
== NULL
) {
367 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
368 FreePool (SmmBootRecordData
);
370 return EFI_OUT_OF_RESOURCES
;
374 // Prepare Boot Performance Table.
376 BootPerformanceData
= (UINT8
*) mAcpiBootPerformanceTable
;
378 // Fill Basic Boot record to Boot Performance Table.
380 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
381 BootPerformanceData
= BootPerformanceData
+ mAcpiBootPerformanceTable
->Header
.Length
;
383 // Fill Boot records from boot drivers.
385 if (mPerformancePointer
!= NULL
) {
386 CopyMem (BootPerformanceData
, mPerformancePointer
, mPerformanceLength
);
387 mAcpiBootPerformanceTable
->Header
.Length
+= mPerformanceLength
;
388 BootPerformanceData
= BootPerformanceData
+ mPerformanceLength
;
389 FreePool (mPerformancePointer
);
390 mPerformancePointer
= NULL
;
391 mPerformanceLength
= 0;
392 mMaxPerformanceLength
= 0;
394 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
396 // Fill Boot records from SMM drivers.
398 CopyMem (BootPerformanceData
, SmmBootRecordData
, SmmBootRecordDataSize
);
399 FreePool (SmmBootRecordData
);
400 mAcpiBootPerformanceTable
->Header
.Length
= (UINT32
) (mAcpiBootPerformanceTable
->Header
.Length
+ SmmBootRecordDataSize
);
401 BootPerformanceData
= BootPerformanceData
+ SmmBootRecordDataSize
;
404 mBootRecordBuffer
= (UINT8
*) mAcpiBootPerformanceTable
;
405 mBootRecordSize
= mAcpiBootPerformanceTable
->Header
.Length
;
406 mBootRecordMaxSize
= mBootRecordSize
+ PcdGet32 (PcdExtFpdtBootRecordPadSize
);
412 Get a human readable module name and module guid for the given image handle.
413 If module name can't be found, "" string will return.
414 If module guid can't be found, Zero Guid will return.
416 @param Handle Image handle or Controller handle.
417 @param NameString The ascii string will be filled into it. If not found, null string will return.
418 @param BufferSize Size of the input NameString buffer.
419 @param ModuleGuid Point to the guid buffer to store the got module guid value.
421 @retval EFI_SUCCESS Successfully get module name and guid.
422 @retval EFI_INVALID_PARAMETER The input parameter NameString is NULL.
423 @retval other value Module Name can't be got.
426 GetModuleInfoFromHandle (
427 IN EFI_HANDLE Handle
,
428 OUT CHAR8
*NameString
,
430 OUT EFI_GUID
*ModuleGuid OPTIONAL
434 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
435 EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
;
441 BOOLEAN ModuleGuidIsGet
;
444 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
445 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
447 if (NameString
== NULL
|| BufferSize
== 0) {
448 return EFI_INVALID_PARAMETER
;
451 // Try to get the ModuleGuid and name string form the caached array.
453 if (mCachePairCount
> 0) {
454 for (Count
= mCachePairCount
-1; Count
>= 0; Count
--) {
455 if (Handle
== mCacheHandleGuidTable
[Count
].Handle
) {
456 CopyGuid (ModuleGuid
, &mCacheHandleGuidTable
[Count
].ModuleGuid
);
457 AsciiStrCpyS (NameString
, FPDT_STRING_EVENT_RECORD_NAME_LENGTH
, mCacheHandleGuidTable
[Count
].NameString
);
463 Status
= EFI_INVALID_PARAMETER
;
465 ModuleGuidIsGet
= FALSE
;
468 // Initialize GUID as zero value.
470 TempGuid
= &gZeroGuid
;
472 // Initialize it as "" string.
476 if (Handle
!= NULL
) {
478 // Try Handle as ImageHandle.
480 Status
= gBS
->HandleProtocol (
482 &gEfiLoadedImageProtocolGuid
,
483 (VOID
**) &LoadedImage
486 if (EFI_ERROR (Status
)) {
488 // Try Handle as Controller Handle
490 Status
= gBS
->OpenProtocol (
492 &gEfiDriverBindingProtocolGuid
,
493 (VOID
**) &DriverBinding
,
496 EFI_OPEN_PROTOCOL_GET_PROTOCOL
498 if (!EFI_ERROR (Status
)) {
500 // Get Image protocol from ImageHandle
502 Status
= gBS
->HandleProtocol (
503 DriverBinding
->ImageHandle
,
504 &gEfiLoadedImageProtocolGuid
,
505 (VOID
**) &LoadedImage
511 if (!EFI_ERROR (Status
) && LoadedImage
!= NULL
) {
513 // Get Module Guid from DevicePath.
515 if (LoadedImage
->FilePath
!= NULL
&&
516 LoadedImage
->FilePath
->Type
== MEDIA_DEVICE_PATH
&&
517 LoadedImage
->FilePath
->SubType
== MEDIA_PIWG_FW_FILE_DP
520 // Determine GUID associated with module logging performance
522 ModuleGuidIsGet
= TRUE
;
523 FvFilePath
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) LoadedImage
->FilePath
;
524 TempGuid
= &FvFilePath
->FvFileName
;
528 // Method 1 Get Module Name from PDB string.
530 PdbFileName
= PeCoffLoaderGetPdbPointer (LoadedImage
->ImageBase
);
531 if (PdbFileName
!= NULL
&& BufferSize
> 0) {
533 for (Index
= 0; PdbFileName
[Index
] != 0; Index
++) {
534 if ((PdbFileName
[Index
] == '\\') || (PdbFileName
[Index
] == '/')) {
535 StartIndex
= Index
+ 1;
539 // Copy the PDB file name to our temporary string.
540 // If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
542 for (Index
= 0; Index
< BufferSize
- 1; Index
++) {
543 NameString
[Index
] = PdbFileName
[Index
+ StartIndex
];
544 if (NameString
[Index
] == 0 || NameString
[Index
] == '.') {
545 NameString
[Index
] = 0;
550 if (Index
== BufferSize
- 1) {
551 NameString
[Index
] = 0;
554 // Module Name is got.
561 // Method 2: Get the name string from ComponentName2 protocol
563 Status
= gBS
->HandleProtocol (
565 &gEfiComponentName2ProtocolGuid
,
566 (VOID
**) &ComponentName2
568 if (!EFI_ERROR (Status
)) {
570 // Get the current platform language setting
572 if (mPlatformLanguage
== NULL
) {
573 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**) &mPlatformLanguage
, NULL
);
575 if (mPlatformLanguage
!= NULL
) {
576 Status
= ComponentName2
->GetDriverName (
578 mPlatformLanguage
!= NULL
? mPlatformLanguage
: "en-US",
581 if (!EFI_ERROR (Status
)) {
582 for (Index
= 0; Index
< BufferSize
- 1 && StringPtr
[Index
] != 0; Index
++) {
583 NameString
[Index
] = (CHAR8
) StringPtr
[Index
];
585 NameString
[Index
] = 0;
587 // Module Name is got.
594 if (ModuleGuidIsGet
) {
596 // Method 3 Try to get the image's FFS UI section by image GUID
600 Status
= GetSectionFromAnyFv (
602 EFI_SECTION_USER_INTERFACE
,
604 (VOID
**) &StringPtr
,
608 if (!EFI_ERROR (Status
)) {
610 // Method 3. Get the name string from FFS UI section
612 for (Index
= 0; Index
< BufferSize
- 1 && StringPtr
[Index
] != 0; Index
++) {
613 NameString
[Index
] = (CHAR8
) StringPtr
[Index
];
615 NameString
[Index
] = 0;
616 FreePool (StringPtr
);
624 if (ModuleGuid
!= NULL
) {
625 CopyGuid (ModuleGuid
, TempGuid
);
626 if (IsZeroGuid(TempGuid
) && (Handle
!= NULL
) && !ModuleGuidIsGet
) {
628 CopyGuid (ModuleGuid
, (EFI_GUID
*) Handle
);
633 // Cache the Handle and Guid pairs.
635 if (mCachePairCount
< CACHE_HANDLE_GUID_COUNT
) {
636 mCacheHandleGuidTable
[mCachePairCount
].Handle
= Handle
;
637 CopyGuid (&mCacheHandleGuidTable
[mCachePairCount
].ModuleGuid
, ModuleGuid
);
638 AsciiStrCpyS (mCacheHandleGuidTable
[mCachePairCount
].NameString
, FPDT_STRING_EVENT_RECORD_NAME_LENGTH
, NameString
);
646 Get the FPDT record identifier.
648 @param Attribute The attribute of the Record.
649 PerfStartEntry: Start Record.
650 PerfEndEntry: End Record.
651 @param Handle Pointer to environment specific context used to identify the component being measured.
652 @param String Pointer to a Null-terminated ASCII string that identifies the component being measured.
653 @param ProgressID On return, pointer to the ProgressID.
655 @retval EFI_SUCCESS Get record info successfully.
656 @retval EFI_INVALID_PARAMETER No matched FPDT record.
661 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
,
662 IN CONST VOID
*Handle
,
663 IN CONST CHAR8
*String
,
664 OUT UINT16
*ProgressID
670 if (String
!= NULL
) {
671 if (AsciiStrCmp (String
, START_IMAGE_TOK
) == 0) { // "StartImage:"
672 if (Attribute
== PerfStartEntry
) {
673 *ProgressID
= MODULE_START_ID
;
675 *ProgressID
= MODULE_END_ID
;
677 } else if (AsciiStrCmp (String
, LOAD_IMAGE_TOK
) == 0) { // "LoadImage:"
678 if (Attribute
== PerfStartEntry
) {
679 *ProgressID
= MODULE_LOADIMAGE_START_ID
;
681 *ProgressID
= MODULE_LOADIMAGE_END_ID
;
683 } else if (AsciiStrCmp (String
, DRIVERBINDING_START_TOK
) == 0) { // "DB:Start:"
684 if (Attribute
== PerfStartEntry
) {
685 *ProgressID
= MODULE_DB_START_ID
;
687 *ProgressID
= MODULE_DB_END_ID
;
689 } else if (AsciiStrCmp (String
, DRIVERBINDING_SUPPORT_TOK
) == 0) { // "DB:Support:"
690 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
691 return RETURN_UNSUPPORTED
;
693 if (Attribute
== PerfStartEntry
) {
694 *ProgressID
= MODULE_DB_SUPPORT_START_ID
;
696 *ProgressID
= MODULE_DB_SUPPORT_END_ID
;
698 } else if (AsciiStrCmp (String
, DRIVERBINDING_STOP_TOK
) == 0) { // "DB:Stop:"
699 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
700 return RETURN_UNSUPPORTED
;
702 if (Attribute
== PerfStartEntry
) {
703 *ProgressID
= MODULE_DB_STOP_START_ID
;
705 *ProgressID
= MODULE_DB_STOP_END_ID
;
707 } else if (AsciiStrCmp (String
, PEI_TOK
) == 0 || // "PEI"
708 AsciiStrCmp (String
, DXE_TOK
) == 0 || // "DXE"
709 AsciiStrCmp (String
, BDS_TOK
) == 0) { // "BDS"
710 if (Attribute
== PerfStartEntry
) {
711 *ProgressID
= PERF_CROSSMODULE_START_ID
;
713 *ProgressID
= PERF_CROSSMODULE_END_ID
;
715 } else { // Pref used in Modules.
716 if (Attribute
== PerfStartEntry
) {
717 *ProgressID
= PERF_INMODULE_START_ID
;
719 *ProgressID
= PERF_INMODULE_END_ID
;
722 } else if (Handle
!= NULL
) { // Pref used in Modules.
723 if (Attribute
== PerfStartEntry
) {
724 *ProgressID
= PERF_INMODULE_START_ID
;
726 *ProgressID
= PERF_INMODULE_END_ID
;
729 return EFI_INVALID_PARAMETER
;
735 Copies the string from Source into Destination and updates Length with the
738 @param Destination - destination of the string copy
739 @param Source - pointer to the source string which will get copied
740 @param Length - pointer to a length variable to be updated
744 CopyStringIntoPerfRecordAndUpdateLength (
745 IN OUT CHAR8
*Destination
,
746 IN CONST CHAR8
*Source
,
753 ASSERT (Source
!= NULL
);
755 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
756 DestMax
= STRING_SIZE
;
758 DestMax
= AsciiStrSize (Source
);
759 if (DestMax
> STRING_SIZE
) {
760 DestMax
= STRING_SIZE
;
763 StringLen
= AsciiStrLen (Source
);
764 if (StringLen
>= DestMax
) {
765 StringLen
= DestMax
-1;
768 AsciiStrnCpyS(Destination
, DestMax
, Source
, StringLen
);
769 *Length
+= (UINT8
)DestMax
;
775 Get a string description for device for the given controller handle and update record
776 length. If ComponentName2 GetControllerName is supported, the value is included in the string,
777 followed by device path, otherwise just device path.
779 @param Handle - Image handle
780 @param ControllerHandle - Controller handle.
781 @param ComponentNameString - Pointer to a location where the string will be saved
782 @param Length - Pointer to record length to be updated
784 @retval EFI_SUCCESS - Successfully got string description for device
785 @retval EFI_UNSUPPORTED - Neither ComponentName2 ControllerName nor DevicePath were found
789 GetDeviceInfoFromHandleAndUpdateLength (
790 IN CONST VOID
*Handle
,
791 IN EFI_HANDLE ControllerHandle
,
792 OUT CHAR8
*ComponentNameString
,
796 EFI_DEVICE_PATH_PROTOCOL
*DevicePathProtocol
;
797 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
800 CHAR8
*AsciiStringPtr
;
801 UINTN ControllerNameStringSize
;
802 UINTN DevicePathStringSize
;
804 ControllerNameStringSize
= 0;
806 Status
= gBS
->HandleProtocol (
808 &gEfiComponentName2ProtocolGuid
,
809 (VOID
**) &ComponentName2
812 if (!EFI_ERROR(Status
)) {
814 // Get the current platform language setting
816 if (mPlatformLanguage
== NULL
) {
817 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**)&mPlatformLanguage
, NULL
);
820 Status
= ComponentName2
->GetControllerName (
824 mPlatformLanguage
!= NULL
? mPlatformLanguage
: "en-US",
829 if (!EFI_ERROR (Status
)) {
831 // This will produce the size of the unicode string, which is twice as large as the ASCII one
832 // This must be an even number, so ok to divide by 2
834 ControllerNameStringSize
= StrSize(StringPtr
) / 2;
837 // The + 1 is because we want to add a space between the ControllerName and the device path
839 if ((ControllerNameStringSize
+ (*Length
) + 1) > FPDT_MAX_PERF_RECORD_SIZE
) {
841 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
843 ControllerNameStringSize
= FPDT_MAX_PERF_RECORD_SIZE
- (*Length
) - 1;
846 UnicodeStrToAsciiStrS(StringPtr
, ComponentNameString
, ControllerNameStringSize
);
849 // Add a space in the end of the ControllerName
851 AsciiStringPtr
= ComponentNameString
+ ControllerNameStringSize
- 1;
852 *AsciiStringPtr
= 0x20;
855 ControllerNameStringSize
++;
857 *Length
+= (UINT8
)ControllerNameStringSize
;
861 // This function returns the device path protocol from the handle specified by Handle. If Handle is
862 // NULL or Handle does not contain a device path protocol, then NULL is returned.
864 DevicePathProtocol
= DevicePathFromHandle(ControllerHandle
);
866 if (DevicePathProtocol
!= NULL
) {
867 StringPtr
= ConvertDevicePathToText (DevicePathProtocol
, TRUE
, FALSE
);
868 if (StringPtr
!= NULL
) {
870 // This will produce the size of the unicode string, which is twice as large as the ASCII one
871 // This must be an even number, so ok to divide by 2
873 DevicePathStringSize
= StrSize(StringPtr
) / 2;
875 if ((DevicePathStringSize
+ (*Length
)) > FPDT_MAX_PERF_RECORD_SIZE
) {
877 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
879 DevicePathStringSize
= FPDT_MAX_PERF_RECORD_SIZE
- (*Length
);
882 if (ControllerNameStringSize
!= 0) {
883 AsciiStringPtr
= ComponentNameString
+ ControllerNameStringSize
- 1;
885 AsciiStringPtr
= ComponentNameString
;
888 UnicodeStrToAsciiStrS(StringPtr
, AsciiStringPtr
, DevicePathStringSize
);
889 *Length
+= (UINT8
)DevicePathStringSize
;
894 return EFI_UNSUPPORTED
;
898 Create performance record with event description and a timestamp.
900 @param CallerIdentifier - Image handle or pointer to caller ID GUID.
901 @param Guid - Pointer to a GUID.
902 @param String - Pointer to a string describing the measurement.
903 @param Ticker - 64-bit time stamp.
904 @param Address - Pointer to a location in memory relevant to the measurement.
905 @param PerfId - Performance identifier describing the type of measurement.
906 @param Attribute - The attribute of the measurement. According to attribute can create a start
907 record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
908 or a general record for other Perf macros.
910 @retval EFI_SUCCESS - Successfully created performance record.
911 @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.
912 @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
913 pointer or invalid PerfId.
915 @retval EFI_SUCCESS - Successfully created performance record
916 @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records
917 @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
918 pointer or invalid PerfId
923 IN CONST VOID
*CallerIdentifier
, OPTIONAL
924 IN CONST VOID
*Guid
, OPTIONAL
925 IN CONST CHAR8
*String
, OPTIONAL
927 IN UINT64 Address
, OPTIONAL
929 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
933 CHAR8 ModuleName
[FPDT_STRING_EVENT_RECORD_NAME_LENGTH
];
934 FPDT_RECORD_PTR FpdtRecordPtr
;
935 FPDT_RECORD_PTR CachedFpdtRecordPtr
;
937 CONST CHAR8
*StringPtr
;
945 ZeroMem (ModuleName
, sizeof (ModuleName
));
948 // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_EX/PERF_END_EX.
949 // notes: For other Perf macros (Attribute == PerfEntry), their Id is known.
951 if (Attribute
!= PerfEntry
) {
953 // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it has high priority.
954 // !!! Note: If the Perf is not the known Token used in the core but have same
955 // ID with the core Token, this case will not be supported.
956 // And in currtnt usage mode, for the unkown ID, there is a general rule:
957 // If it is start pref: the lower 4 bits of the ID should be 0.
958 // If it is end pref: the lower 4 bits of the ID should not be 0.
959 // If input ID doesn't follow the rule, we will adjust it.
961 if ((PerfId
!= 0) && (IsKnownID (PerfId
)) && (!IsKnownTokens (String
))) {
962 return EFI_INVALID_PARAMETER
;
963 } else if ((PerfId
!= 0) && (!IsKnownID (PerfId
)) && (!IsKnownTokens (String
))) {
964 if ((Attribute
== PerfStartEntry
) && ((PerfId
& 0x000F) != 0)) {
966 } else if ((Attribute
== PerfEndEntry
) && ((PerfId
& 0x000F) == 0)) {
969 } else if (PerfId
== 0) {
971 // Get ProgressID form the String Token.
973 Status
= GetFpdtRecordId (Attribute
, CallerIdentifier
, String
, &ProgressId
);
974 if (EFI_ERROR (Status
)) {
982 // 2. Get the buffer to store the FPDT record.
984 Status
= GetFpdtRecordPtr (FPDT_MAX_PERF_RECORD_SIZE
, &FpdtRecordPtr
);
985 if (EFI_ERROR (Status
)) {
990 //3. Get the TimeStamp.
993 Ticker
= GetPerformanceCounter ();
994 TimeStamp
= GetTimeInNanoSecond (Ticker
);
995 } else if (Ticker
== 1) {
998 TimeStamp
= GetTimeInNanoSecond (Ticker
);
1002 // 4. Fill in the FPDT record according to different Performance Identifier.
1005 case MODULE_START_ID
:
1007 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1008 StringPtr
= ModuleName
;
1010 // Cache the offset of start image start record and use to update the start image end record if needed.
1012 if (Attribute
== PerfEntry
&& PerfId
== MODULE_START_ID
) {
1013 if (mFpdtBufferIsReported
) {
1014 mCachedLength
= mBootRecordSize
;
1016 mCachedLength
= mPerformanceLength
;
1019 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1020 FpdtRecordPtr
.GuidEvent
->Header
.Type
= FPDT_GUID_EVENT_TYPE
;
1021 FpdtRecordPtr
.GuidEvent
->Header
.Length
= sizeof (FPDT_GUID_EVENT_RECORD
);
1022 FpdtRecordPtr
.GuidEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1023 FpdtRecordPtr
.GuidEvent
->ProgressID
= PerfId
;
1024 FpdtRecordPtr
.GuidEvent
->Timestamp
= TimeStamp
;
1025 CopyMem (&FpdtRecordPtr
.GuidEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidEvent
->Guid
));
1026 if (CallerIdentifier
== NULL
&& PerfId
== MODULE_END_ID
&& mCachedLength
!= 0) {
1027 if (mFpdtBufferIsReported
) {
1028 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mCachedLength
);
1030 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mCachedLength
);
1032 CopyMem (&FpdtRecordPtr
.GuidEvent
->Guid
, &CachedFpdtRecordPtr
.GuidEvent
->Guid
, sizeof (FpdtRecordPtr
.GuidEvent
->Guid
));
1038 case MODULE_LOADIMAGE_START_ID
:
1039 case MODULE_LOADIMAGE_END_ID
:
1040 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1041 StringPtr
= ModuleName
;
1042 if (PerfId
== MODULE_LOADIMAGE_START_ID
) {
1045 // Cache the offset of load image start record and use to be updated by the load image end record if needed.
1047 if (CallerIdentifier
== NULL
&& Attribute
== PerfEntry
) {
1048 if (mFpdtBufferIsReported
) {
1049 mCachedLength
= mBootRecordSize
;
1051 mCachedLength
= mPerformanceLength
;
1055 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1056 FpdtRecordPtr
.GuidQwordEvent
->Header
.Type
= FPDT_GUID_QWORD_EVENT_TYPE
;
1057 FpdtRecordPtr
.GuidQwordEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_EVENT_RECORD
);
1058 FpdtRecordPtr
.GuidQwordEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1059 FpdtRecordPtr
.GuidQwordEvent
->ProgressID
= PerfId
;
1060 FpdtRecordPtr
.GuidQwordEvent
->Timestamp
= TimeStamp
;
1061 FpdtRecordPtr
.GuidQwordEvent
->Qword
= mLoadImageCount
;
1062 CopyMem (&FpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordEvent
->Guid
));
1063 if (PerfId
== MODULE_LOADIMAGE_END_ID
&& mCachedLength
!= 0) {
1064 if (mFpdtBufferIsReported
) {
1065 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mCachedLength
);
1067 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mCachedLength
);
1069 CopyMem (&CachedFpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (CachedFpdtRecordPtr
.GuidQwordEvent
->Guid
));
1075 case MODULE_DB_START_ID
:
1076 case MODULE_DB_SUPPORT_START_ID
:
1077 case MODULE_DB_SUPPORT_END_ID
:
1078 case MODULE_DB_STOP_START_ID
:
1079 case MODULE_DB_STOP_END_ID
:
1080 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1081 StringPtr
= ModuleName
;
1082 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1083 FpdtRecordPtr
.GuidQwordEvent
->Header
.Type
= FPDT_GUID_QWORD_EVENT_TYPE
;
1084 FpdtRecordPtr
.GuidQwordEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_EVENT_RECORD
);
1085 FpdtRecordPtr
.GuidQwordEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1086 FpdtRecordPtr
.GuidQwordEvent
->ProgressID
= PerfId
;
1087 FpdtRecordPtr
.GuidQwordEvent
->Timestamp
= TimeStamp
;
1088 FpdtRecordPtr
.GuidQwordEvent
->Qword
= Address
;
1089 CopyMem (&FpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordEvent
->Guid
));
1093 case MODULE_DB_END_ID
:
1094 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1095 StringPtr
= ModuleName
;
1096 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1097 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Type
= FPDT_GUID_QWORD_STRING_EVENT_TYPE
;
1098 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD
);;
1099 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1100 FpdtRecordPtr
.GuidQwordStringEvent
->ProgressID
= PerfId
;
1101 FpdtRecordPtr
.GuidQwordStringEvent
->Timestamp
= TimeStamp
;
1102 FpdtRecordPtr
.GuidQwordStringEvent
->Qword
= Address
;
1103 CopyMem (&FpdtRecordPtr
.GuidQwordStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordStringEvent
->Guid
));
1105 GetDeviceInfoFromHandleAndUpdateLength(CallerIdentifier
, (EFI_HANDLE
)(UINTN
)Address
, FpdtRecordPtr
.GuidQwordStringEvent
->String
, &FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Length
);
1110 case PERF_EVENTSIGNAL_START_ID
:
1111 case PERF_EVENTSIGNAL_END_ID
:
1112 case PERF_CALLBACK_START_ID
:
1113 case PERF_CALLBACK_END_ID
:
1114 if (String
== NULL
) {
1115 return EFI_INVALID_PARAMETER
;
1118 // Cache the event guid in string event record when PcdEdkiiFpdtStringRecordEnableOnly == TRUE
1120 CopyGuid (&ModuleGuid
, Guid
);
1122 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1123 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Type
= FPDT_DUAL_GUID_STRING_EVENT_TYPE
;
1124 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Length
= sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD
);
1125 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1126 FpdtRecordPtr
.DualGuidStringEvent
->ProgressID
= PerfId
;
1127 FpdtRecordPtr
.DualGuidStringEvent
->Timestamp
= TimeStamp
;
1128 CopyMem (&FpdtRecordPtr
.DualGuidStringEvent
->Guid1
, CallerIdentifier
, sizeof (FpdtRecordPtr
.DualGuidStringEvent
->Guid1
));
1129 CopyMem (&FpdtRecordPtr
.DualGuidStringEvent
->Guid2
, Guid
, sizeof (FpdtRecordPtr
.DualGuidStringEvent
->Guid2
));
1130 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DualGuidStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DualGuidStringEvent
->Header
.Length
);
1135 case PERF_FUNCTION_START_ID
:
1136 case PERF_FUNCTION_END_ID
:
1137 case PERF_INMODULE_START_ID
:
1138 case PERF_INMODULE_END_ID
:
1139 case PERF_CROSSMODULE_START_ID
:
1140 case PERF_CROSSMODULE_END_ID
:
1141 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1142 if (String
!= NULL
) {
1145 StringPtr
= ModuleName
;
1147 if (AsciiStrLen (StringPtr
) == 0) {
1148 StringPtr
= "unknown name";
1150 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1151 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1152 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1153 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1154 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1155 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1156 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1157 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DynamicStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
);
1162 if (Attribute
!= PerfEntry
) {
1163 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1164 if (String
!= NULL
) {
1167 StringPtr
= ModuleName
;
1169 if (AsciiStrLen (StringPtr
) == 0) {
1170 StringPtr
= "unknown name";
1172 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1173 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1174 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1175 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1176 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1177 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1178 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1179 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DynamicStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
);
1182 return EFI_INVALID_PARAMETER
;
1188 // 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
1190 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1191 if (StringPtr
== NULL
||PerfId
== MODULE_DB_SUPPORT_START_ID
|| PerfId
== MODULE_DB_SUPPORT_END_ID
) {
1192 return EFI_INVALID_PARAMETER
;
1194 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1195 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1196 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1197 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1198 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1199 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1200 if (AsciiStrLen (StringPtr
) == 0) {
1201 StringPtr
= "unknown name";
1203 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DynamicStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
);
1205 if ((PerfId
== MODULE_LOADIMAGE_START_ID
) || (PerfId
== MODULE_END_ID
)) {
1206 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= (UINT8
)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
)+ STRING_SIZE
);
1208 if ((PerfId
== MODULE_LOADIMAGE_END_ID
|| PerfId
== MODULE_END_ID
) && mCachedLength
!= 0) {
1209 if (mFpdtBufferIsReported
) {
1210 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mCachedLength
);
1212 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mCachedLength
);
1214 if (PerfId
== MODULE_LOADIMAGE_END_ID
) {
1215 DestMax
= CachedFpdtRecordPtr
.DynamicStringEvent
->Header
.Length
- sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1216 StringLen
= AsciiStrLen (StringPtr
);
1217 if (StringLen
>= DestMax
) {
1218 StringLen
= DestMax
-1;
1220 CopyMem (&CachedFpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (CachedFpdtRecordPtr
.DynamicStringEvent
->Guid
));
1221 AsciiStrnCpyS (CachedFpdtRecordPtr
.DynamicStringEvent
->String
, DestMax
, StringPtr
, StringLen
);
1222 } else if (PerfId
== MODULE_END_ID
) {
1223 DestMax
= FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
- sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1224 StringLen
= AsciiStrLen (CachedFpdtRecordPtr
.DynamicStringEvent
->String
);
1225 if (StringLen
>= DestMax
) {
1226 StringLen
= DestMax
-1;
1228 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &CachedFpdtRecordPtr
.DynamicStringEvent
->Guid
, sizeof (CachedFpdtRecordPtr
.DynamicStringEvent
->Guid
));
1229 AsciiStrnCpyS (FpdtRecordPtr
.DynamicStringEvent
->String
, DestMax
, CachedFpdtRecordPtr
.DynamicStringEvent
->String
, StringLen
);
1236 // 5. Update the length of the used buffer after fill in the record.
1238 if (mFpdtBufferIsReported
) {
1239 mBootRecordSize
+= FpdtRecordPtr
.RecordHeader
->Length
;
1240 mAcpiBootPerformanceTable
->Header
.Length
+= FpdtRecordPtr
.RecordHeader
->Length
;
1242 mPerformanceLength
+= FpdtRecordPtr
.RecordHeader
->Length
;
1248 Dumps all the PEI performance.
1250 @param HobStart A pointer to a Guid.
1252 This internal function dumps all the PEI performance log to the DXE performance gauge array.
1253 It retrieves the optional GUID HOB for PEI performance and then saves the performance data
1254 to DXE performance data structures.
1258 InternalGetPeiPerformance (
1262 UINT8
*FirmwarePerformanceHob
;
1263 FPDT_PEI_EXT_PERF_HEADER
*PeiPerformanceLogHeader
;
1265 EFI_HOB_GUID_TYPE
*GuidHob
;
1267 GuidHob
= GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid
, HobStart
);
1268 while (GuidHob
!= NULL
) {
1269 FirmwarePerformanceHob
= GET_GUID_HOB_DATA (GuidHob
);
1270 PeiPerformanceLogHeader
= (FPDT_PEI_EXT_PERF_HEADER
*)FirmwarePerformanceHob
;
1272 if (mPerformanceLength
+ PeiPerformanceLogHeader
->SizeOfAllEntries
> mMaxPerformanceLength
) {
1273 mPerformancePointer
= ReallocatePool (
1275 mPerformanceLength
+
1276 (UINTN
)PeiPerformanceLogHeader
->SizeOfAllEntries
+
1277 FIRMWARE_RECORD_BUFFER
,
1280 ASSERT (mPerformancePointer
!= NULL
);
1281 mMaxPerformanceLength
= mPerformanceLength
+
1282 (UINTN
)(PeiPerformanceLogHeader
->SizeOfAllEntries
) +
1283 FIRMWARE_RECORD_BUFFER
;
1286 EventRec
= mPerformancePointer
+ mPerformanceLength
;
1287 CopyMem (EventRec
, FirmwarePerformanceHob
+ sizeof (FPDT_PEI_EXT_PERF_HEADER
), (UINTN
)(PeiPerformanceLogHeader
->SizeOfAllEntries
));
1289 // Update the used buffer size.
1291 mPerformanceLength
+= (UINTN
)(PeiPerformanceLogHeader
->SizeOfAllEntries
);
1292 mLoadImageCount
+= PeiPerformanceLogHeader
->LoadImageCount
;
1295 // Get next performance guid hob
1297 GuidHob
= GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid
, GET_NEXT_HOB (GuidHob
));
1302 Report Boot Perforamnce table address as report status code.
1304 @param Event The event of notify protocol.
1305 @param Context Notify event context.
1310 ReportFpdtRecordBuffer (
1318 if (!mFpdtBufferIsReported
) {
1319 Status
= AllocateBootPerformanceTable ();
1320 if (!EFI_ERROR(Status
)) {
1321 BPDTAddr
= (UINT64
)(UINTN
)mAcpiBootPerformanceTable
;
1322 REPORT_STATUS_CODE_EX (
1324 EFI_SOFTWARE_DXE_BS_DRIVER
,
1327 &gEdkiiFpdtExtendedFirmwarePerformanceGuid
,
1333 // Set FPDT report state to TRUE.
1335 mFpdtBufferIsReported
= TRUE
;
1340 The constructor function initializes Performance infrastructure for DXE phase.
1342 The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
1343 and merges PEI performance data to DXE performance log.
1344 It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
1346 @param ImageHandle The firmware allocated handle for the EFI image.
1347 @param SystemTable A pointer to the EFI System Table.
1349 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
1354 DxeCorePerformanceLibConstructor (
1355 IN EFI_HANDLE ImageHandle
,
1356 IN EFI_SYSTEM_TABLE
*SystemTable
1361 EFI_EVENT ReadyToBootEvent
;
1362 PERFORMANCE_PROPERTY
*PerformanceProperty
;
1364 if (!PerformanceMeasurementEnabled ()) {
1366 // Do not initialize performance infrastructure if not required.
1372 // Dump normal PEI performance records
1374 InternalGetPeiPerformance (GetHobList());
1377 // Install the protocol interfaces for DXE performance library instance.
1380 Status
= gBS
->InstallMultipleProtocolInterfaces (
1382 &gEdkiiPerformanceMeasurementProtocolGuid
,
1383 &mPerformanceMeasurementInterface
,
1386 ASSERT_EFI_ERROR (Status
);
1389 // Register ReadyToBoot event to report StatusCode data
1391 Status
= gBS
->CreateEventEx (
1394 ReportFpdtRecordBuffer
,
1396 &gEfiEventReadyToBootGuid
,
1400 ASSERT_EFI_ERROR (Status
);
1402 Status
= EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid
, (VOID
**) &PerformanceProperty
);
1403 if (EFI_ERROR (Status
)) {
1405 // Install configuration table for performance property.
1407 mPerformanceProperty
.Revision
= PERFORMANCE_PROPERTY_REVISION
;
1408 mPerformanceProperty
.Reserved
= 0;
1409 mPerformanceProperty
.Frequency
= GetPerformanceCounterProperties (
1410 &mPerformanceProperty
.TimerStartValue
,
1411 &mPerformanceProperty
.TimerEndValue
1413 Status
= gBS
->InstallConfigurationTable (&gPerformanceProtocolGuid
, &mPerformanceProperty
);
1414 ASSERT_EFI_ERROR (Status
);
1421 Create performance record with event description and a timestamp.
1423 @param CallerIdentifier - Image handle or pointer to caller ID GUID.
1424 @param Guid - Pointer to a GUID.
1425 @param String - Pointer to a string describing the measurement.
1426 @param TimeStamp - 64-bit time stamp.
1427 @param Address - Pointer to a location in memory relevant to the measurement.
1428 @param Identifier - Performance identifier describing the type of measurement.
1429 @param Attribute - The attribute of the measurement. According to attribute can create a start
1430 record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
1431 or a general record for other Perf macros.
1433 @retval EFI_SUCCESS - Successfully created performance record.
1434 @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.
1435 @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
1436 pointer or invalid PerfId.
1440 CreatePerformanceMeasurement (
1441 IN CONST VOID
*CallerIdentifier
,
1442 IN CONST VOID
*Guid
, OPTIONAL
1443 IN CONST CHAR8
*String
, OPTIONAL
1444 IN UINT64 TimeStamp
,
1445 IN UINT64 Address
, OPTIONAL
1446 IN UINT32 Identifier
,
1447 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
1452 Status
= EFI_SUCCESS
;
1454 if (mLockInsertRecord
) {
1455 return EFI_INVALID_PARAMETER
;
1457 mLockInsertRecord
= TRUE
;
1459 Status
= InsertFpdtRecord (CallerIdentifier
, Guid
, String
, TimeStamp
, Address
, (UINT16
)Identifier
, Attribute
);
1461 mLockInsertRecord
= FALSE
;
1467 Adds a record at the end of the performance measurement log
1468 that records the start time of a performance measurement.
1470 Adds a record to the end of the performance measurement log
1471 that contains the Handle, Token, Module and Identifier.
1472 The end time of the new record must be set to zero.
1473 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
1474 If TimeStamp is zero, the start time in the record is filled in with the value
1475 read from the current time stamp.
1477 @param Handle Pointer to environment specific context used
1478 to identify the component being measured.
1479 @param Token Pointer to a Null-terminated ASCII string
1480 that identifies the component being measured.
1481 @param Module Pointer to a Null-terminated ASCII string
1482 that identifies the module being measured.
1483 @param TimeStamp 64-bit time stamp.
1484 @param Identifier 32-bit identifier. If the value is 0, the created record
1485 is same as the one created by StartPerformanceMeasurement.
1487 @retval RETURN_SUCCESS The start of the measurement was recorded.
1488 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
1493 StartPerformanceMeasurementEx (
1494 IN CONST VOID
*Handle
, OPTIONAL
1495 IN CONST CHAR8
*Token
, OPTIONAL
1496 IN CONST CHAR8
*Module
, OPTIONAL
1497 IN UINT64 TimeStamp
,
1498 IN UINT32 Identifier
1501 CONST CHAR8
*String
;
1503 if (Token
!= NULL
) {
1505 } else if (Module
!= NULL
) {
1511 return (RETURN_STATUS
)CreatePerformanceMeasurement (Handle
, NULL
, String
, TimeStamp
, 0, Identifier
, PerfStartEntry
);
1515 Searches the performance measurement log from the beginning of the log
1516 for the first matching record that contains a zero end time and fills in a valid end time.
1518 Searches the performance measurement log from the beginning of the log
1519 for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
1520 If the record can not be found then return RETURN_NOT_FOUND.
1521 If the record is found and TimeStamp is not zero,
1522 then the end time in the record is filled in with the value specified by TimeStamp.
1523 If the record is found and TimeStamp is zero, then the end time in the matching record
1524 is filled in with the current time stamp value.
1526 @param Handle Pointer to environment specific context used
1527 to identify the component being measured.
1528 @param Token Pointer to a Null-terminated ASCII string
1529 that identifies the component being measured.
1530 @param Module Pointer to a Null-terminated ASCII string
1531 that identifies the module being measured.
1532 @param TimeStamp 64-bit time stamp.
1533 @param Identifier 32-bit identifier. If the value is 0, the found record
1534 is same as the one found by EndPerformanceMeasurement.
1536 @retval RETURN_SUCCESS The end of the measurement was recorded.
1537 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
1542 EndPerformanceMeasurementEx (
1543 IN CONST VOID
*Handle
, OPTIONAL
1544 IN CONST CHAR8
*Token
, OPTIONAL
1545 IN CONST CHAR8
*Module
, OPTIONAL
1546 IN UINT64 TimeStamp
,
1547 IN UINT32 Identifier
1550 CONST CHAR8
*String
;
1552 if (Token
!= NULL
) {
1554 } else if (Module
!= NULL
) {
1560 return (RETURN_STATUS
)CreatePerformanceMeasurement (Handle
, NULL
, String
, TimeStamp
, 0, Identifier
, PerfEndEntry
);
1564 Attempts to retrieve a performance measurement log entry from the performance measurement log.
1565 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
1566 and then assign the Identifier with 0.
1570 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
1571 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
1572 and the key for the second entry in the log is returned. If the performance log is empty,
1573 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
1574 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
1575 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
1576 retrieved and an implementation specific non-zero key value that specifies the end of the performance
1577 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
1578 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
1579 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
1580 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
1581 If Handle is NULL, then ASSERT().
1582 If Token is NULL, then ASSERT().
1583 If Module is NULL, then ASSERT().
1584 If StartTimeStamp is NULL, then ASSERT().
1585 If EndTimeStamp is NULL, then ASSERT().
1586 If Identifier is NULL, then ASSERT().
1588 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
1589 0, then the first performance measurement log entry is retrieved.
1590 On exit, the key of the next performance log entry.
1591 @param Handle Pointer to environment specific context used to identify the component
1593 @param Token Pointer to a Null-terminated ASCII string that identifies the component
1595 @param Module Pointer to a Null-terminated ASCII string that identifies the module
1597 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
1599 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
1601 @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement
1604 @return The key for the next performance log entry (in general case).
1609 GetPerformanceMeasurementEx (
1610 IN UINTN LogEntryKey
,
1611 OUT CONST VOID
**Handle
,
1612 OUT CONST CHAR8
**Token
,
1613 OUT CONST CHAR8
**Module
,
1614 OUT UINT64
*StartTimeStamp
,
1615 OUT UINT64
*EndTimeStamp
,
1616 OUT UINT32
*Identifier
1623 Adds a record at the end of the performance measurement log
1624 that records the start time of a performance measurement.
1626 Adds a record to the end of the performance measurement log
1627 that contains the Handle, Token, and Module.
1628 The end time of the new record must be set to zero.
1629 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
1630 If TimeStamp is zero, the start time in the record is filled in with the value
1631 read from the current time stamp.
1633 @param Handle Pointer to environment specific context used
1634 to identify the component being measured.
1635 @param Token Pointer to a Null-terminated ASCII string
1636 that identifies the component being measured.
1637 @param Module Pointer to a Null-terminated ASCII string
1638 that identifies the module being measured.
1639 @param TimeStamp 64-bit time stamp.
1641 @retval RETURN_SUCCESS The start of the measurement was recorded.
1642 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
1647 StartPerformanceMeasurement (
1648 IN CONST VOID
*Handle
, OPTIONAL
1649 IN CONST CHAR8
*Token
, OPTIONAL
1650 IN CONST CHAR8
*Module
, OPTIONAL
1654 return StartPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
1658 Searches the performance measurement log from the beginning of the log
1659 for the first matching record that contains a zero end time and fills in a valid end time.
1661 Searches the performance measurement log from the beginning of the log
1662 for the first record that matches Handle, Token, and Module and has an end time value of zero.
1663 If the record can not be found then return RETURN_NOT_FOUND.
1664 If the record is found and TimeStamp is not zero,
1665 then the end time in the record is filled in with the value specified by TimeStamp.
1666 If the record is found and TimeStamp is zero, then the end time in the matching record
1667 is filled in with the current time stamp value.
1669 @param Handle Pointer to environment specific context used
1670 to identify the component being measured.
1671 @param Token Pointer to a Null-terminated ASCII string
1672 that identifies the component being measured.
1673 @param Module Pointer to a Null-terminated ASCII string
1674 that identifies the module being measured.
1675 @param TimeStamp 64-bit time stamp.
1677 @retval RETURN_SUCCESS The end of the measurement was recorded.
1678 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
1683 EndPerformanceMeasurement (
1684 IN CONST VOID
*Handle
, OPTIONAL
1685 IN CONST CHAR8
*Token
, OPTIONAL
1686 IN CONST CHAR8
*Module
, OPTIONAL
1690 return EndPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
1694 Attempts to retrieve a performance measurement log entry from the performance measurement log.
1695 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
1696 and then eliminate the Identifier.
1700 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
1701 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
1702 and the key for the second entry in the log is returned. If the performance log is empty,
1703 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
1704 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
1705 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
1706 retrieved and an implementation specific non-zero key value that specifies the end of the performance
1707 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
1708 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
1709 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
1710 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
1711 If Handle is NULL, then ASSERT().
1712 If Token is NULL, then ASSERT().
1713 If Module is NULL, then ASSERT().
1714 If StartTimeStamp is NULL, then ASSERT().
1715 If EndTimeStamp is NULL, then ASSERT().
1717 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
1718 0, then the first performance measurement log entry is retrieved.
1719 On exit, the key of the next performance log entry.
1720 @param Handle Pointer to environment specific context used to identify the component
1722 @param Token Pointer to a Null-terminated ASCII string that identifies the component
1724 @param Module Pointer to a Null-terminated ASCII string that identifies the module
1726 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
1728 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
1731 @return The key for the next performance log entry (in general case).
1736 GetPerformanceMeasurement (
1737 IN UINTN LogEntryKey
,
1738 OUT CONST VOID
**Handle
,
1739 OUT CONST CHAR8
**Token
,
1740 OUT CONST CHAR8
**Module
,
1741 OUT UINT64
*StartTimeStamp
,
1742 OUT UINT64
*EndTimeStamp
1749 Returns TRUE if the performance measurement macros are enabled.
1751 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
1752 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
1754 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
1755 PcdPerformanceLibraryPropertyMask is set.
1756 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
1757 PcdPerformanceLibraryPropertyMask is clear.
1762 PerformanceMeasurementEnabled (
1766 return (BOOLEAN
) ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0);
1770 Create performance record with event description and a timestamp.
1772 @param CallerIdentifier - Image handle or pointer to caller ID GUID
1773 @param Guid - Pointer to a GUID
1774 @param String - Pointer to a string describing the measurement
1775 @param Address - Pointer to a location in memory relevant to the measurement
1776 @param Identifier - Performance identifier describing the type of measurement
1778 @retval RETURN_SUCCESS - Successfully created performance record
1779 @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records
1780 @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL
1781 pointer or invalid PerfId
1786 LogPerformanceMeasurement (
1787 IN CONST VOID
*CallerIdentifier
,
1788 IN CONST VOID
*Guid
, OPTIONAL
1789 IN CONST CHAR8
*String
, OPTIONAL
1790 IN UINT64 Address
, OPTIONAL
1791 IN UINT32 Identifier
1794 return (RETURN_STATUS
)CreatePerformanceMeasurement (CallerIdentifier
, Guid
, String
, 0, Address
, Identifier
, PerfEntry
);
1798 Check whether the specified performance measurement can be logged.
1800 This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set
1801 and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
1803 @param Type - Type of the performance measurement entry.
1805 @retval TRUE The performance measurement can be logged.
1806 @retval FALSE The performance measurement can NOT be logged.
1811 LogPerformanceMeasurementEnabled (
1816 // When Performance measurement is enabled and the type is not filtered, the performance can be logged.
1818 if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask
) & Type
) == 0) {