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 SPDX-License-Identifier: BSD-2-Clause-Patent
20 #include "DxeCorePerformanceLibInternal.h"
23 // Data for FPDT performance records.
25 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
26 #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
27 #define FIRMWARE_RECORD_BUFFER 0x10000
28 #define CACHE_HANDLE_GUID_COUNT 0x800
30 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
31 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
33 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
34 sizeof (BOOT_PERFORMANCE_TABLE
)
38 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
39 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
40 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
44 // These values will be updated at runtime.
47 0, // OsLoaderLoadImageStart
48 0, // OsLoaderStartImageStart
49 0, // ExitBootServicesEntry
50 0 // ExitBootServicesExit
56 CHAR8 NameString
[FPDT_STRING_EVENT_RECORD_NAME_LENGTH
];
60 HANDLE_GUID_MAP mCacheHandleGuidTable
[CACHE_HANDLE_GUID_COUNT
];
61 UINTN mCachePairCount
= 0;
63 UINT32 mLoadImageCount
= 0;
64 UINT32 mPerformanceLength
= 0;
65 UINT32 mMaxPerformanceLength
= 0;
66 UINT32 mBootRecordSize
= 0;
67 UINT32 mBootRecordMaxSize
= 0;
68 UINT32 mCachedLength
= 0;
70 BOOLEAN mFpdtBufferIsReported
= FALSE
;
71 BOOLEAN mLackSpaceIsReported
= FALSE
;
72 CHAR8
*mPlatformLanguage
= NULL
;
73 UINT8
*mPerformancePointer
= NULL
;
74 UINT8
*mBootRecordBuffer
= NULL
;
75 BOOLEAN mLockInsertRecord
= FALSE
;
76 CHAR8
*mDevicePathString
= NULL
;
78 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*mDevicePathToText
= NULL
;
81 // Interfaces for PerformanceMeasurement Protocol.
83 EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
= {
84 CreatePerformanceMeasurement
,
87 PERFORMANCE_PROPERTY mPerformanceProperty
;
90 Return the pointer to the FPDT record in the allocated memory.
92 @param RecordSize The size of FPDT record.
93 @param FpdtRecordPtr Pointer the FPDT record in the allocated memory.
95 @retval EFI_SUCCESS Successfully get the pointer to the FPDT record.
96 @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records.
101 IN OUT FPDT_RECORD_PTR
*FpdtRecordPtr
104 if (mFpdtBufferIsReported
) {
106 // Append Boot records to the boot performance table.
108 if (mBootRecordSize
+ RecordSize
> mBootRecordMaxSize
) {
109 if (!mLackSpaceIsReported
) {
110 DEBUG ((DEBUG_INFO
, "DxeCorePerformanceLib: No enough space to save boot records\n"));
111 mLackSpaceIsReported
= TRUE
;
113 return EFI_OUT_OF_RESOURCES
;
116 // Save boot record into BootPerformance table
118 FpdtRecordPtr
->RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mBootRecordSize
);
122 // Check if pre-allocated buffer is full
124 if (mPerformanceLength
+ RecordSize
> mMaxPerformanceLength
) {
125 mPerformancePointer
= ReallocatePool (
127 mPerformanceLength
+ RecordSize
+ FIRMWARE_RECORD_BUFFER
,
130 if (mPerformancePointer
== NULL
) {
131 return EFI_OUT_OF_RESOURCES
;
133 mMaxPerformanceLength
= mPerformanceLength
+ RecordSize
+ FIRMWARE_RECORD_BUFFER
;
136 // Covert buffer to FPDT Ptr Union type.
138 FpdtRecordPtr
->RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mPerformanceLength
);
144 Check whether the Token is a known one which is uesed by core.
146 @param Token Pointer to a Null-terminated ASCII string
148 @retval TRUE Is a known one used by core.
149 @retval FALSE Not a known one.
154 IN CONST CHAR8
*Token
161 if (AsciiStrCmp (Token
, SEC_TOK
) == 0 ||
162 AsciiStrCmp (Token
, PEI_TOK
) == 0 ||
163 AsciiStrCmp (Token
, DXE_TOK
) == 0 ||
164 AsciiStrCmp (Token
, BDS_TOK
) == 0 ||
165 AsciiStrCmp (Token
, DRIVERBINDING_START_TOK
) == 0 ||
166 AsciiStrCmp (Token
, DRIVERBINDING_SUPPORT_TOK
) == 0 ||
167 AsciiStrCmp (Token
, DRIVERBINDING_STOP_TOK
) == 0 ||
168 AsciiStrCmp (Token
, LOAD_IMAGE_TOK
) == 0 ||
169 AsciiStrCmp (Token
, START_IMAGE_TOK
) == 0 ||
170 AsciiStrCmp (Token
, PEIM_TOK
) == 0) {
178 Check whether the ID is a known one which map to the known Token.
180 @param Identifier 32-bit identifier.
182 @retval TRUE Is a known one used by core.
183 @retval FALSE Not a known one.
191 if (Identifier
== MODULE_START_ID
||
192 Identifier
== MODULE_END_ID
||
193 Identifier
== MODULE_LOADIMAGE_START_ID
||
194 Identifier
== MODULE_LOADIMAGE_END_ID
||
195 Identifier
== MODULE_DB_START_ID
||
196 Identifier
== MODULE_DB_END_ID
||
197 Identifier
== MODULE_DB_SUPPORT_START_ID
||
198 Identifier
== MODULE_DB_SUPPORT_END_ID
||
199 Identifier
== MODULE_DB_STOP_START_ID
||
200 Identifier
== MODULE_DB_STOP_END_ID
) {
208 Allocate buffer for Boot Performance table.
214 AllocateBootPerformanceTable (
219 UINT8
*SmmBootRecordCommBuffer
;
220 EFI_SMM_COMMUNICATE_HEADER
*SmmCommBufferHeader
;
221 SMM_BOOT_RECORD_COMMUNICATE
*SmmCommData
;
223 UINTN BootPerformanceDataSize
;
224 UINT8
*BootPerformanceData
;
225 EFI_SMM_COMMUNICATION_PROTOCOL
*Communication
;
226 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
227 EDKII_PI_SMM_COMMUNICATION_REGION_TABLE
*SmmCommRegionTable
;
228 EFI_MEMORY_DESCRIPTOR
*SmmCommMemRegion
;
230 VOID
*SmmBootRecordData
;
231 UINTN SmmBootRecordDataSize
;
232 UINTN ReservedMemSize
;
235 // Collect boot records from SMM drivers.
237 SmmBootRecordCommBuffer
= NULL
;
239 SmmBootRecordData
= NULL
;
240 SmmBootRecordDataSize
= 0;
242 Status
= gBS
->LocateProtocol (&gEfiSmmCommunicationProtocolGuid
, NULL
, (VOID
**) &Communication
);
243 if (!EFI_ERROR (Status
)) {
245 // Initialize communicate buffer
246 // Get the prepared Reserved Memory Range
248 Status
= EfiGetSystemConfigurationTable (
249 &gEdkiiPiSmmCommunicationRegionTableGuid
,
250 (VOID
**) &SmmCommRegionTable
252 if (!EFI_ERROR (Status
)) {
253 ASSERT (SmmCommRegionTable
!= NULL
);
254 SmmCommMemRegion
= (EFI_MEMORY_DESCRIPTOR
*) (SmmCommRegionTable
+ 1);
255 for (Index
= 0; Index
< SmmCommRegionTable
->NumberOfEntries
; Index
++) {
256 if (SmmCommMemRegion
->Type
== EfiConventionalMemory
) {
259 SmmCommMemRegion
= (EFI_MEMORY_DESCRIPTOR
*) ((UINT8
*) SmmCommMemRegion
+ SmmCommRegionTable
->DescriptorSize
);
261 ASSERT (Index
< SmmCommRegionTable
->NumberOfEntries
);
262 ASSERT (SmmCommMemRegion
->PhysicalStart
> 0);
263 ASSERT (SmmCommMemRegion
->NumberOfPages
> 0);
264 ReservedMemSize
= (UINTN
) SmmCommMemRegion
->NumberOfPages
* EFI_PAGE_SIZE
;
267 // Check enough reserved memory space
269 if (ReservedMemSize
> SMM_BOOT_RECORD_COMM_SIZE
) {
270 SmmBootRecordCommBuffer
= (VOID
*) (UINTN
) SmmCommMemRegion
->PhysicalStart
;
271 SmmCommBufferHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)SmmBootRecordCommBuffer
;
272 SmmCommData
= (SMM_BOOT_RECORD_COMMUNICATE
*)SmmCommBufferHeader
->Data
;
273 ZeroMem((UINT8
*)SmmCommData
, sizeof(SMM_BOOT_RECORD_COMMUNICATE
));
275 CopyGuid (&SmmCommBufferHeader
->HeaderGuid
, &gEfiFirmwarePerformanceGuid
);
276 SmmCommBufferHeader
->MessageLength
= sizeof(SMM_BOOT_RECORD_COMMUNICATE
);
277 CommSize
= SMM_BOOT_RECORD_COMM_SIZE
;
280 // Get the size of boot records.
282 SmmCommData
->Function
= SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE
;
283 SmmCommData
->BootRecordData
= NULL
;
284 Status
= Communication
->Communicate (Communication
, SmmBootRecordCommBuffer
, &CommSize
);
286 if (!EFI_ERROR (Status
) && !EFI_ERROR (SmmCommData
->ReturnStatus
) && SmmCommData
->BootRecordSize
!= 0) {
288 // Get all boot records
290 SmmCommData
->Function
= SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET
;
291 SmmBootRecordDataSize
= SmmCommData
->BootRecordSize
;
292 SmmBootRecordData
= AllocateZeroPool(SmmBootRecordDataSize
);
293 ASSERT (SmmBootRecordData
!= NULL
);
294 SmmCommData
->BootRecordOffset
= 0;
295 SmmCommData
->BootRecordData
= (VOID
*) ((UINTN
) SmmCommMemRegion
->PhysicalStart
+ SMM_BOOT_RECORD_COMM_SIZE
);
296 SmmCommData
->BootRecordSize
= ReservedMemSize
- SMM_BOOT_RECORD_COMM_SIZE
;
297 while (SmmCommData
->BootRecordOffset
< SmmBootRecordDataSize
) {
298 Status
= Communication
->Communicate (Communication
, SmmBootRecordCommBuffer
, &CommSize
);
299 ASSERT_EFI_ERROR (Status
);
300 ASSERT_EFI_ERROR(SmmCommData
->ReturnStatus
);
301 if (SmmCommData
->BootRecordOffset
+ SmmCommData
->BootRecordSize
> SmmBootRecordDataSize
) {
302 CopyMem ((UINT8
*) SmmBootRecordData
+ SmmCommData
->BootRecordOffset
, SmmCommData
->BootRecordData
, SmmBootRecordDataSize
- SmmCommData
->BootRecordOffset
);
304 CopyMem ((UINT8
*) SmmBootRecordData
+ SmmCommData
->BootRecordOffset
, SmmCommData
->BootRecordData
, SmmCommData
->BootRecordSize
);
306 SmmCommData
->BootRecordOffset
= SmmCommData
->BootRecordOffset
+ SmmCommData
->BootRecordSize
;
314 // Prepare memory for Boot Performance table.
315 // Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
317 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
) + mPerformanceLength
+ PcdGet32 (PcdExtFpdtBootRecordPadSize
);
318 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
319 BootPerformanceDataSize
+= SmmBootRecordDataSize
;
323 // Try to allocate the same runtime buffer as last time boot.
325 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
326 Size
= sizeof (PerformanceVariable
);
327 Status
= gRT
->GetVariable (
328 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
329 &gEfiFirmwarePerformanceGuid
,
334 if (!EFI_ERROR (Status
)) {
335 Status
= gBS
->AllocatePages (
337 EfiReservedMemoryType
,
338 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
339 &PerformanceVariable
.BootPerformanceTablePointer
341 if (!EFI_ERROR (Status
)) {
342 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
346 if (mAcpiBootPerformanceTable
== NULL
) {
348 // Fail to allocate at specified address, continue to allocate at any address.
350 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
351 EfiReservedMemoryType
,
352 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
354 if (mAcpiBootPerformanceTable
!= NULL
) {
355 ZeroMem (mAcpiBootPerformanceTable
, BootPerformanceDataSize
);
358 DEBUG ((DEBUG_INFO
, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
360 if (mAcpiBootPerformanceTable
== NULL
) {
361 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
362 FreePool (SmmBootRecordData
);
364 return EFI_OUT_OF_RESOURCES
;
368 // Prepare Boot Performance Table.
370 BootPerformanceData
= (UINT8
*) mAcpiBootPerformanceTable
;
372 // Fill Basic Boot record to Boot Performance Table.
374 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
375 BootPerformanceData
= BootPerformanceData
+ mAcpiBootPerformanceTable
->Header
.Length
;
377 // Fill Boot records from boot drivers.
379 if (mPerformancePointer
!= NULL
) {
380 CopyMem (BootPerformanceData
, mPerformancePointer
, mPerformanceLength
);
381 mAcpiBootPerformanceTable
->Header
.Length
+= mPerformanceLength
;
382 BootPerformanceData
= BootPerformanceData
+ mPerformanceLength
;
383 FreePool (mPerformancePointer
);
384 mPerformancePointer
= NULL
;
385 mPerformanceLength
= 0;
386 mMaxPerformanceLength
= 0;
388 if (SmmCommData
!= NULL
&& SmmBootRecordData
!= NULL
) {
390 // Fill Boot records from SMM drivers.
392 CopyMem (BootPerformanceData
, SmmBootRecordData
, SmmBootRecordDataSize
);
393 FreePool (SmmBootRecordData
);
394 mAcpiBootPerformanceTable
->Header
.Length
= (UINT32
) (mAcpiBootPerformanceTable
->Header
.Length
+ SmmBootRecordDataSize
);
395 BootPerformanceData
= BootPerformanceData
+ SmmBootRecordDataSize
;
398 mBootRecordBuffer
= (UINT8
*) mAcpiBootPerformanceTable
;
399 mBootRecordSize
= mAcpiBootPerformanceTable
->Header
.Length
;
400 mBootRecordMaxSize
= mBootRecordSize
+ PcdGet32 (PcdExtFpdtBootRecordPadSize
);
406 Get a human readable module name and module guid for the given image handle.
407 If module name can't be found, "" string will return.
408 If module guid can't be found, Zero Guid will return.
410 @param Handle Image handle or Controller handle.
411 @param NameString The ascii string will be filled into it. If not found, null string will return.
412 @param BufferSize Size of the input NameString buffer.
413 @param ModuleGuid Point to the guid buffer to store the got module guid value.
415 @retval EFI_SUCCESS Successfully get module name and guid.
416 @retval EFI_INVALID_PARAMETER The input parameter NameString is NULL.
417 @retval other value Module Name can't be got.
420 GetModuleInfoFromHandle (
421 IN EFI_HANDLE Handle
,
422 OUT CHAR8
*NameString
,
424 OUT EFI_GUID
*ModuleGuid OPTIONAL
428 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
429 EFI_DRIVER_BINDING_PROTOCOL
*DriverBinding
;
435 BOOLEAN ModuleGuidIsGet
;
438 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
439 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
441 if (NameString
== NULL
|| BufferSize
== 0) {
442 return EFI_INVALID_PARAMETER
;
445 // Try to get the ModuleGuid and name string form the caached array.
447 if (mCachePairCount
> 0) {
448 for (Count
= mCachePairCount
-1; Count
>= 0; Count
--) {
449 if (Handle
== mCacheHandleGuidTable
[Count
].Handle
) {
450 CopyGuid (ModuleGuid
, &mCacheHandleGuidTable
[Count
].ModuleGuid
);
451 AsciiStrCpyS (NameString
, FPDT_STRING_EVENT_RECORD_NAME_LENGTH
, mCacheHandleGuidTable
[Count
].NameString
);
457 Status
= EFI_INVALID_PARAMETER
;
459 ModuleGuidIsGet
= FALSE
;
462 // Initialize GUID as zero value.
464 TempGuid
= &gZeroGuid
;
466 // Initialize it as "" string.
470 if (Handle
!= NULL
) {
472 // Try Handle as ImageHandle.
474 Status
= gBS
->HandleProtocol (
476 &gEfiLoadedImageProtocolGuid
,
477 (VOID
**) &LoadedImage
480 if (EFI_ERROR (Status
)) {
482 // Try Handle as Controller Handle
484 Status
= gBS
->OpenProtocol (
486 &gEfiDriverBindingProtocolGuid
,
487 (VOID
**) &DriverBinding
,
490 EFI_OPEN_PROTOCOL_GET_PROTOCOL
492 if (!EFI_ERROR (Status
)) {
494 // Get Image protocol from ImageHandle
496 Status
= gBS
->HandleProtocol (
497 DriverBinding
->ImageHandle
,
498 &gEfiLoadedImageProtocolGuid
,
499 (VOID
**) &LoadedImage
505 if (!EFI_ERROR (Status
) && LoadedImage
!= NULL
) {
507 // Get Module Guid from DevicePath.
509 if (LoadedImage
->FilePath
!= NULL
&&
510 LoadedImage
->FilePath
->Type
== MEDIA_DEVICE_PATH
&&
511 LoadedImage
->FilePath
->SubType
== MEDIA_PIWG_FW_FILE_DP
514 // Determine GUID associated with module logging performance
516 ModuleGuidIsGet
= TRUE
;
517 FvFilePath
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) LoadedImage
->FilePath
;
518 TempGuid
= &FvFilePath
->FvFileName
;
522 // Method 1 Get Module Name from PDB string.
524 PdbFileName
= PeCoffLoaderGetPdbPointer (LoadedImage
->ImageBase
);
525 if (PdbFileName
!= NULL
&& BufferSize
> 0) {
527 for (Index
= 0; PdbFileName
[Index
] != 0; Index
++) {
528 if ((PdbFileName
[Index
] == '\\') || (PdbFileName
[Index
] == '/')) {
529 StartIndex
= Index
+ 1;
533 // Copy the PDB file name to our temporary string.
534 // If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
536 for (Index
= 0; Index
< BufferSize
- 1; Index
++) {
537 NameString
[Index
] = PdbFileName
[Index
+ StartIndex
];
538 if (NameString
[Index
] == 0 || NameString
[Index
] == '.') {
539 NameString
[Index
] = 0;
544 if (Index
== BufferSize
- 1) {
545 NameString
[Index
] = 0;
548 // Module Name is got.
555 // Method 2: Get the name string from ComponentName2 protocol
557 Status
= gBS
->HandleProtocol (
559 &gEfiComponentName2ProtocolGuid
,
560 (VOID
**) &ComponentName2
562 if (!EFI_ERROR (Status
)) {
564 // Get the current platform language setting
566 if (mPlatformLanguage
== NULL
) {
567 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**) &mPlatformLanguage
, NULL
);
569 if (mPlatformLanguage
!= NULL
) {
570 Status
= ComponentName2
->GetDriverName (
572 mPlatformLanguage
!= NULL
? mPlatformLanguage
: "en-US",
575 if (!EFI_ERROR (Status
)) {
576 for (Index
= 0; Index
< BufferSize
- 1 && StringPtr
[Index
] != 0; Index
++) {
577 NameString
[Index
] = (CHAR8
) StringPtr
[Index
];
579 NameString
[Index
] = 0;
581 // Module Name is got.
588 if (ModuleGuidIsGet
) {
590 // Method 3 Try to get the image's FFS UI section by image GUID
594 Status
= GetSectionFromAnyFv (
596 EFI_SECTION_USER_INTERFACE
,
598 (VOID
**) &StringPtr
,
602 if (!EFI_ERROR (Status
)) {
604 // Method 3. Get the name string from FFS UI section
606 for (Index
= 0; Index
< BufferSize
- 1 && StringPtr
[Index
] != 0; Index
++) {
607 NameString
[Index
] = (CHAR8
) StringPtr
[Index
];
609 NameString
[Index
] = 0;
610 FreePool (StringPtr
);
618 if (ModuleGuid
!= NULL
) {
619 CopyGuid (ModuleGuid
, TempGuid
);
620 if (IsZeroGuid(TempGuid
) && (Handle
!= NULL
) && !ModuleGuidIsGet
) {
622 CopyGuid (ModuleGuid
, (EFI_GUID
*) Handle
);
627 // Cache the Handle and Guid pairs.
629 if (mCachePairCount
< CACHE_HANDLE_GUID_COUNT
) {
630 mCacheHandleGuidTable
[mCachePairCount
].Handle
= Handle
;
631 CopyGuid (&mCacheHandleGuidTable
[mCachePairCount
].ModuleGuid
, ModuleGuid
);
632 AsciiStrCpyS (mCacheHandleGuidTable
[mCachePairCount
].NameString
, FPDT_STRING_EVENT_RECORD_NAME_LENGTH
, NameString
);
640 Get the FPDT record identifier.
642 @param Attribute The attribute of the Record.
643 PerfStartEntry: Start Record.
644 PerfEndEntry: End Record.
645 @param Handle Pointer to environment specific context used to identify the component being measured.
646 @param String Pointer to a Null-terminated ASCII string that identifies the component being measured.
647 @param ProgressID On return, pointer to the ProgressID.
649 @retval EFI_SUCCESS Get record info successfully.
650 @retval EFI_INVALID_PARAMETER No matched FPDT record.
655 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
,
656 IN CONST VOID
*Handle
,
657 IN CONST CHAR8
*String
,
658 OUT UINT16
*ProgressID
664 if (String
!= NULL
) {
665 if (AsciiStrCmp (String
, START_IMAGE_TOK
) == 0) { // "StartImage:"
666 if (Attribute
== PerfStartEntry
) {
667 *ProgressID
= MODULE_START_ID
;
669 *ProgressID
= MODULE_END_ID
;
671 } else if (AsciiStrCmp (String
, LOAD_IMAGE_TOK
) == 0) { // "LoadImage:"
672 if (Attribute
== PerfStartEntry
) {
673 *ProgressID
= MODULE_LOADIMAGE_START_ID
;
675 *ProgressID
= MODULE_LOADIMAGE_END_ID
;
677 } else if (AsciiStrCmp (String
, DRIVERBINDING_START_TOK
) == 0) { // "DB:Start:"
678 if (Attribute
== PerfStartEntry
) {
679 *ProgressID
= MODULE_DB_START_ID
;
681 *ProgressID
= MODULE_DB_END_ID
;
683 } else if (AsciiStrCmp (String
, DRIVERBINDING_SUPPORT_TOK
) == 0) { // "DB:Support:"
684 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
685 return RETURN_UNSUPPORTED
;
687 if (Attribute
== PerfStartEntry
) {
688 *ProgressID
= MODULE_DB_SUPPORT_START_ID
;
690 *ProgressID
= MODULE_DB_SUPPORT_END_ID
;
692 } else if (AsciiStrCmp (String
, DRIVERBINDING_STOP_TOK
) == 0) { // "DB:Stop:"
693 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
694 return RETURN_UNSUPPORTED
;
696 if (Attribute
== PerfStartEntry
) {
697 *ProgressID
= MODULE_DB_STOP_START_ID
;
699 *ProgressID
= MODULE_DB_STOP_END_ID
;
701 } else if (AsciiStrCmp (String
, PEI_TOK
) == 0 || // "PEI"
702 AsciiStrCmp (String
, DXE_TOK
) == 0 || // "DXE"
703 AsciiStrCmp (String
, BDS_TOK
) == 0) { // "BDS"
704 if (Attribute
== PerfStartEntry
) {
705 *ProgressID
= PERF_CROSSMODULE_START_ID
;
707 *ProgressID
= PERF_CROSSMODULE_END_ID
;
709 } else { // Pref used in Modules.
710 if (Attribute
== PerfStartEntry
) {
711 *ProgressID
= PERF_INMODULE_START_ID
;
713 *ProgressID
= PERF_INMODULE_END_ID
;
716 } else if (Handle
!= NULL
) { // Pref used in Modules.
717 if (Attribute
== PerfStartEntry
) {
718 *ProgressID
= PERF_INMODULE_START_ID
;
720 *ProgressID
= PERF_INMODULE_END_ID
;
723 return EFI_INVALID_PARAMETER
;
729 Copies the string from Source into Destination and updates Length with the
732 @param Destination - destination of the string copy
733 @param Source - pointer to the source string which will get copied
734 @param Length - pointer to a length variable to be updated
738 CopyStringIntoPerfRecordAndUpdateLength (
739 IN OUT CHAR8
*Destination
,
740 IN CONST CHAR8
*Source
,
747 ASSERT (Source
!= NULL
);
749 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
750 DestMax
= STRING_SIZE
;
752 DestMax
= AsciiStrSize (Source
);
753 if (DestMax
> STRING_SIZE
) {
754 DestMax
= STRING_SIZE
;
757 StringLen
= AsciiStrLen (Source
);
758 if (StringLen
>= DestMax
) {
759 StringLen
= DestMax
-1;
762 AsciiStrnCpyS(Destination
, DestMax
, Source
, StringLen
);
763 *Length
+= (UINT8
)DestMax
;
769 Get a string description for device for the given controller handle and update record
770 length. If ComponentName2 GetControllerName is supported, the value is included in the string,
771 followed by device path, otherwise just device path.
773 @param Handle - Image handle
774 @param ControllerHandle - Controller handle.
775 @param ComponentNameString - Pointer to a location where the string will be saved
776 @param Length - Pointer to record length to be updated
778 @retval EFI_SUCCESS - Successfully got string description for device
779 @retval EFI_UNSUPPORTED - Neither ComponentName2 ControllerName nor DevicePath were found
783 GetDeviceInfoFromHandleAndUpdateLength (
784 IN CONST VOID
*Handle
,
785 IN EFI_HANDLE ControllerHandle
,
786 OUT CHAR8
*ComponentNameString
,
790 EFI_DEVICE_PATH_PROTOCOL
*DevicePathProtocol
;
791 EFI_COMPONENT_NAME2_PROTOCOL
*ComponentName2
;
794 CHAR8
*AsciiStringPtr
;
795 UINTN ControllerNameStringSize
;
796 UINTN DevicePathStringSize
;
798 ControllerNameStringSize
= 0;
800 Status
= gBS
->HandleProtocol (
802 &gEfiComponentName2ProtocolGuid
,
803 (VOID
**) &ComponentName2
806 if (!EFI_ERROR(Status
)) {
808 // Get the current platform language setting
810 if (mPlatformLanguage
== NULL
) {
811 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**)&mPlatformLanguage
, NULL
);
814 Status
= ComponentName2
->GetControllerName (
818 mPlatformLanguage
!= NULL
? mPlatformLanguage
: "en-US",
823 if (!EFI_ERROR (Status
)) {
825 // This will produce the size of the unicode string, which is twice as large as the ASCII one
826 // This must be an even number, so ok to divide by 2
828 ControllerNameStringSize
= StrSize(StringPtr
) / 2;
831 // The + 1 is because we want to add a space between the ControllerName and the device path
833 if ((ControllerNameStringSize
+ (*Length
) + 1) > FPDT_MAX_PERF_RECORD_SIZE
) {
835 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
837 ControllerNameStringSize
= FPDT_MAX_PERF_RECORD_SIZE
- (*Length
) - 1;
840 UnicodeStrToAsciiStrS(StringPtr
, ComponentNameString
, ControllerNameStringSize
);
843 // Add a space in the end of the ControllerName
845 AsciiStringPtr
= ComponentNameString
+ ControllerNameStringSize
- 1;
846 *AsciiStringPtr
= 0x20;
849 ControllerNameStringSize
++;
851 *Length
+= (UINT8
)ControllerNameStringSize
;
855 // This function returns the device path protocol from the handle specified by Handle. If Handle is
856 // NULL or Handle does not contain a device path protocol, then NULL is returned.
858 DevicePathProtocol
= DevicePathFromHandle(ControllerHandle
);
860 if (DevicePathProtocol
!= NULL
) {
861 StringPtr
= ConvertDevicePathToText (DevicePathProtocol
, TRUE
, FALSE
);
862 if (StringPtr
!= NULL
) {
864 // This will produce the size of the unicode string, which is twice as large as the ASCII one
865 // This must be an even number, so ok to divide by 2
867 DevicePathStringSize
= StrSize(StringPtr
) / 2;
869 if ((DevicePathStringSize
+ (*Length
)) > FPDT_MAX_PERF_RECORD_SIZE
) {
871 // Only copy enough to fill FPDT_MAX_PERF_RECORD_SIZE worth of the record
873 DevicePathStringSize
= FPDT_MAX_PERF_RECORD_SIZE
- (*Length
);
876 if (ControllerNameStringSize
!= 0) {
877 AsciiStringPtr
= ComponentNameString
+ ControllerNameStringSize
- 1;
879 AsciiStringPtr
= ComponentNameString
;
882 UnicodeStrToAsciiStrS(StringPtr
, AsciiStringPtr
, DevicePathStringSize
);
883 *Length
+= (UINT8
)DevicePathStringSize
;
888 return EFI_UNSUPPORTED
;
892 Create performance record with event description and a timestamp.
894 @param CallerIdentifier - Image handle or pointer to caller ID GUID.
895 @param Guid - Pointer to a GUID.
896 @param String - Pointer to a string describing the measurement.
897 @param Ticker - 64-bit time stamp.
898 @param Address - Pointer to a location in memory relevant to the measurement.
899 @param PerfId - Performance identifier describing the type of measurement.
900 @param Attribute - The attribute of the measurement. According to attribute can create a start
901 record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
902 or a general record for other Perf macros.
904 @retval EFI_SUCCESS - Successfully created performance record.
905 @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.
906 @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
907 pointer or invalid PerfId.
909 @retval EFI_SUCCESS - Successfully created performance record
910 @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records
911 @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
912 pointer or invalid PerfId
917 IN CONST VOID
*CallerIdentifier
, OPTIONAL
918 IN CONST VOID
*Guid
, OPTIONAL
919 IN CONST CHAR8
*String
, OPTIONAL
921 IN UINT64 Address
, OPTIONAL
923 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
927 CHAR8 ModuleName
[FPDT_STRING_EVENT_RECORD_NAME_LENGTH
];
928 FPDT_RECORD_PTR FpdtRecordPtr
;
929 FPDT_RECORD_PTR CachedFpdtRecordPtr
;
931 CONST CHAR8
*StringPtr
;
939 ZeroMem (ModuleName
, sizeof (ModuleName
));
942 // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_EX/PERF_END_EX.
943 // notes: For other Perf macros (Attribute == PerfEntry), their Id is known.
945 if (Attribute
!= PerfEntry
) {
947 // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it has high priority.
948 // !!! Note: If the Perf is not the known Token used in the core but have same
949 // ID with the core Token, this case will not be supported.
950 // And in currtnt usage mode, for the unkown ID, there is a general rule:
951 // If it is start pref: the lower 4 bits of the ID should be 0.
952 // If it is end pref: the lower 4 bits of the ID should not be 0.
953 // If input ID doesn't follow the rule, we will adjust it.
955 if ((PerfId
!= 0) && (IsKnownID (PerfId
)) && (!IsKnownTokens (String
))) {
956 return EFI_INVALID_PARAMETER
;
957 } else if ((PerfId
!= 0) && (!IsKnownID (PerfId
)) && (!IsKnownTokens (String
))) {
958 if ((Attribute
== PerfStartEntry
) && ((PerfId
& 0x000F) != 0)) {
960 } else if ((Attribute
== PerfEndEntry
) && ((PerfId
& 0x000F) == 0)) {
963 } else if (PerfId
== 0) {
965 // Get ProgressID form the String Token.
967 Status
= GetFpdtRecordId (Attribute
, CallerIdentifier
, String
, &ProgressId
);
968 if (EFI_ERROR (Status
)) {
976 // 2. Get the buffer to store the FPDT record.
978 Status
= GetFpdtRecordPtr (FPDT_MAX_PERF_RECORD_SIZE
, &FpdtRecordPtr
);
979 if (EFI_ERROR (Status
)) {
984 //3. Get the TimeStamp.
987 Ticker
= GetPerformanceCounter ();
988 TimeStamp
= GetTimeInNanoSecond (Ticker
);
989 } else if (Ticker
== 1) {
992 TimeStamp
= GetTimeInNanoSecond (Ticker
);
996 // 4. Fill in the FPDT record according to different Performance Identifier.
999 case MODULE_START_ID
:
1001 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1002 StringPtr
= ModuleName
;
1004 // Cache the offset of start image start record and use to update the start image end record if needed.
1006 if (Attribute
== PerfEntry
&& PerfId
== MODULE_START_ID
) {
1007 if (mFpdtBufferIsReported
) {
1008 mCachedLength
= mBootRecordSize
;
1010 mCachedLength
= mPerformanceLength
;
1013 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1014 FpdtRecordPtr
.GuidEvent
->Header
.Type
= FPDT_GUID_EVENT_TYPE
;
1015 FpdtRecordPtr
.GuidEvent
->Header
.Length
= sizeof (FPDT_GUID_EVENT_RECORD
);
1016 FpdtRecordPtr
.GuidEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1017 FpdtRecordPtr
.GuidEvent
->ProgressID
= PerfId
;
1018 FpdtRecordPtr
.GuidEvent
->Timestamp
= TimeStamp
;
1019 CopyMem (&FpdtRecordPtr
.GuidEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidEvent
->Guid
));
1020 if (CallerIdentifier
== NULL
&& PerfId
== MODULE_END_ID
&& mCachedLength
!= 0) {
1021 if (mFpdtBufferIsReported
) {
1022 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mCachedLength
);
1024 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mCachedLength
);
1026 CopyMem (&FpdtRecordPtr
.GuidEvent
->Guid
, &CachedFpdtRecordPtr
.GuidEvent
->Guid
, sizeof (FpdtRecordPtr
.GuidEvent
->Guid
));
1032 case MODULE_LOADIMAGE_START_ID
:
1033 case MODULE_LOADIMAGE_END_ID
:
1034 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1035 StringPtr
= ModuleName
;
1036 if (PerfId
== MODULE_LOADIMAGE_START_ID
) {
1039 // Cache the offset of load image start record and use to be updated by the load image end record if needed.
1041 if (CallerIdentifier
== NULL
&& Attribute
== PerfEntry
) {
1042 if (mFpdtBufferIsReported
) {
1043 mCachedLength
= mBootRecordSize
;
1045 mCachedLength
= mPerformanceLength
;
1049 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1050 FpdtRecordPtr
.GuidQwordEvent
->Header
.Type
= FPDT_GUID_QWORD_EVENT_TYPE
;
1051 FpdtRecordPtr
.GuidQwordEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_EVENT_RECORD
);
1052 FpdtRecordPtr
.GuidQwordEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1053 FpdtRecordPtr
.GuidQwordEvent
->ProgressID
= PerfId
;
1054 FpdtRecordPtr
.GuidQwordEvent
->Timestamp
= TimeStamp
;
1055 FpdtRecordPtr
.GuidQwordEvent
->Qword
= mLoadImageCount
;
1056 CopyMem (&FpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordEvent
->Guid
));
1057 if (PerfId
== MODULE_LOADIMAGE_END_ID
&& mCachedLength
!= 0) {
1058 if (mFpdtBufferIsReported
) {
1059 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mBootRecordBuffer
+ mCachedLength
);
1061 CachedFpdtRecordPtr
.RecordHeader
= (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER
*)(mPerformancePointer
+ mCachedLength
);
1063 CopyMem (&CachedFpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (CachedFpdtRecordPtr
.GuidQwordEvent
->Guid
));
1069 case MODULE_DB_START_ID
:
1070 case MODULE_DB_SUPPORT_START_ID
:
1071 case MODULE_DB_SUPPORT_END_ID
:
1072 case MODULE_DB_STOP_START_ID
:
1073 case MODULE_DB_STOP_END_ID
:
1074 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1075 StringPtr
= ModuleName
;
1076 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1077 FpdtRecordPtr
.GuidQwordEvent
->Header
.Type
= FPDT_GUID_QWORD_EVENT_TYPE
;
1078 FpdtRecordPtr
.GuidQwordEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_EVENT_RECORD
);
1079 FpdtRecordPtr
.GuidQwordEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1080 FpdtRecordPtr
.GuidQwordEvent
->ProgressID
= PerfId
;
1081 FpdtRecordPtr
.GuidQwordEvent
->Timestamp
= TimeStamp
;
1082 FpdtRecordPtr
.GuidQwordEvent
->Qword
= Address
;
1083 CopyMem (&FpdtRecordPtr
.GuidQwordEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordEvent
->Guid
));
1087 case MODULE_DB_END_ID
:
1088 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1089 StringPtr
= ModuleName
;
1090 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1091 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Type
= FPDT_GUID_QWORD_STRING_EVENT_TYPE
;
1092 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Length
= sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD
);;
1093 FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1094 FpdtRecordPtr
.GuidQwordStringEvent
->ProgressID
= PerfId
;
1095 FpdtRecordPtr
.GuidQwordStringEvent
->Timestamp
= TimeStamp
;
1096 FpdtRecordPtr
.GuidQwordStringEvent
->Qword
= Address
;
1097 CopyMem (&FpdtRecordPtr
.GuidQwordStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.GuidQwordStringEvent
->Guid
));
1099 GetDeviceInfoFromHandleAndUpdateLength(CallerIdentifier
, (EFI_HANDLE
)(UINTN
)Address
, FpdtRecordPtr
.GuidQwordStringEvent
->String
, &FpdtRecordPtr
.GuidQwordStringEvent
->Header
.Length
);
1104 case PERF_EVENTSIGNAL_START_ID
:
1105 case PERF_EVENTSIGNAL_END_ID
:
1106 case PERF_CALLBACK_START_ID
:
1107 case PERF_CALLBACK_END_ID
:
1108 if (String
== NULL
|| Guid
== NULL
) {
1109 return EFI_INVALID_PARAMETER
;
1112 if (AsciiStrLen (String
) == 0) {
1113 StringPtr
= "unknown name";
1115 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1116 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Type
= FPDT_DUAL_GUID_STRING_EVENT_TYPE
;
1117 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Length
= sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD
);
1118 FpdtRecordPtr
.DualGuidStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1119 FpdtRecordPtr
.DualGuidStringEvent
->ProgressID
= PerfId
;
1120 FpdtRecordPtr
.DualGuidStringEvent
->Timestamp
= TimeStamp
;
1121 CopyMem (&FpdtRecordPtr
.DualGuidStringEvent
->Guid1
, CallerIdentifier
, sizeof (FpdtRecordPtr
.DualGuidStringEvent
->Guid1
));
1122 CopyMem (&FpdtRecordPtr
.DualGuidStringEvent
->Guid2
, Guid
, sizeof (FpdtRecordPtr
.DualGuidStringEvent
->Guid2
));
1123 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DualGuidStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DualGuidStringEvent
->Header
.Length
);
1128 case PERF_FUNCTION_START_ID
:
1129 case PERF_FUNCTION_END_ID
:
1130 case PERF_INMODULE_START_ID
:
1131 case PERF_INMODULE_END_ID
:
1132 case PERF_CROSSMODULE_START_ID
:
1133 case PERF_CROSSMODULE_END_ID
:
1134 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1135 if (String
!= NULL
) {
1138 StringPtr
= ModuleName
;
1140 if (AsciiStrLen (StringPtr
) == 0) {
1141 StringPtr
= "unknown name";
1143 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1144 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1145 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1146 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1147 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1148 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1149 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1150 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DynamicStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
);
1155 if (Attribute
!= PerfEntry
) {
1156 GetModuleInfoFromHandle ((EFI_HANDLE
*)CallerIdentifier
, ModuleName
, sizeof (ModuleName
), &ModuleGuid
);
1157 if (String
!= NULL
) {
1160 StringPtr
= ModuleName
;
1162 if (AsciiStrLen (StringPtr
) == 0) {
1163 StringPtr
= "unknown name";
1165 if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1166 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1167 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1168 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1169 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1170 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1171 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, &ModuleGuid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1172 CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr
.DynamicStringEvent
->String
, StringPtr
, &FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
);
1175 return EFI_INVALID_PARAMETER
;
1181 // 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
1183 if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly
)) {
1184 if (StringPtr
== NULL
||PerfId
== MODULE_DB_SUPPORT_START_ID
|| PerfId
== MODULE_DB_SUPPORT_END_ID
) {
1185 return EFI_INVALID_PARAMETER
;
1187 FpdtRecordPtr
.DynamicStringEvent
->Header
.Type
= FPDT_DYNAMIC_STRING_EVENT_TYPE
;
1188 FpdtRecordPtr
.DynamicStringEvent
->Header
.Length
= sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD
);
1189 FpdtRecordPtr
.DynamicStringEvent
->Header
.Revision
= FPDT_RECORD_REVISION_1
;
1190 FpdtRecordPtr
.DynamicStringEvent
->ProgressID
= PerfId
;
1191 FpdtRecordPtr
.DynamicStringEvent
->Timestamp
= TimeStamp
;
1194 // Cache the event guid in string event record.
1196 CopyMem (&FpdtRecordPtr
.DynamicStringEvent
->Guid
, Guid
, sizeof (FpdtRecordPtr
.DynamicStringEvent
->Guid
));
1198 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) {