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 - 2012, Intel Corporation. All rights reserved.<BR>
14 This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #include "DxeCorePerformanceLibInternal.h"
29 // The data structure to hold global performance data.
31 GAUGE_DATA_HEADER
*mGaugeData
;
34 // The current maximum number of logging entries. If current number of
35 // entries exceeds this value, it will re-allocate a larger array and
36 // migration the old data to the larger array.
38 UINT32 mMaxGaugeRecords
;
41 // The handle to install Performance Protocol instance.
43 EFI_HANDLE mHandle
= NULL
;
46 // Interfaces for Performance Protocol.
48 PERFORMANCE_PROTOCOL mPerformanceInterface
= {
55 // Interfaces for PerformanceEx Protocol.
57 PERFORMANCE_EX_PROTOCOL mPerformanceExInterface
= {
64 Searches in the gauge array with keyword Handle, Token, Module and Identifier.
66 This internal function searches for the gauge entry in the gauge array.
67 If there is an entry that exactly matches the given keywords
68 and its end time stamp is zero, then the index of that gauge entry is returned;
69 otherwise, the the number of gauge entries in the array is returned.
71 @param Handle Pointer to environment specific context used
72 to identify the component being measured.
73 @param Token Pointer to a Null-terminated ASCII string
74 that identifies the component being measured.
75 @param Module Pointer to a Null-terminated ASCII string
76 that identifies the module being measured.
77 @param Identifier 32-bit identifier.
79 @retval The index of gauge entry in the array.
83 InternalSearchForGaugeEntry (
84 IN CONST VOID
*Handle
, OPTIONAL
85 IN CONST CHAR8
*Token
, OPTIONAL
86 IN CONST CHAR8
*Module
, OPTIONAL
92 UINT32 NumberOfEntries
;
93 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
102 NumberOfEntries
= mGaugeData
->NumberOfEntries
;
103 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
107 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
108 Index2
= NumberOfEntries
- 1 - Index
;
109 if (GaugeEntryExArray
[Index2
].EndTimeStamp
== 0 &&
110 (GaugeEntryExArray
[Index2
].Handle
== (EFI_PHYSICAL_ADDRESS
) (UINTN
) Handle
) &&
111 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Token
, Token
, DXE_PERFORMANCE_STRING_LENGTH
) == 0 &&
112 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Module
, Module
, DXE_PERFORMANCE_STRING_LENGTH
) == 0 &&
113 (GaugeEntryExArray
[Index2
].Identifier
== Identifier
)) {
123 Adds a record at the end of the performance measurement log
124 that records the start time of a performance measurement.
126 Adds a record to the end of the performance measurement log
127 that contains the Handle, Token, Module and Identifier.
128 The end time of the new record must be set to zero.
129 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
130 If TimeStamp is zero, the start time in the record is filled in with the value
131 read from the current time stamp.
133 @param Handle Pointer to environment specific context used
134 to identify the component being measured.
135 @param Token Pointer to a Null-terminated ASCII string
136 that identifies the component being measured.
137 @param Module Pointer to a Null-terminated ASCII string
138 that identifies the module being measured.
139 @param TimeStamp 64-bit time stamp.
140 @param Identifier 32-bit identifier. If the value is 0, the created record
141 is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.
143 @retval EFI_SUCCESS The data was read correctly from the device.
144 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
150 IN CONST VOID
*Handle
, OPTIONAL
151 IN CONST CHAR8
*Token
, OPTIONAL
152 IN CONST CHAR8
*Module
, OPTIONAL
157 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
159 GAUGE_DATA_HEADER
*NewGaugeData
;
160 UINTN OldGaugeDataSize
;
161 GAUGE_DATA_HEADER
*OldGaugeData
;
164 Index
= mGaugeData
->NumberOfEntries
;
165 if (Index
>= mMaxGaugeRecords
) {
167 // Try to enlarge the scale of gauge array.
169 OldGaugeData
= mGaugeData
;
170 OldGaugeDataSize
= sizeof (GAUGE_DATA_HEADER
) + sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
;
172 GaugeDataSize
= sizeof (GAUGE_DATA_HEADER
) + sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
* 2;
174 NewGaugeData
= AllocateZeroPool (GaugeDataSize
);
175 if (NewGaugeData
== NULL
) {
176 return EFI_OUT_OF_RESOURCES
;
179 mGaugeData
= NewGaugeData
;
180 mMaxGaugeRecords
*= 2;
183 // Initialize new data array and migrate old data one.
185 mGaugeData
= CopyMem (mGaugeData
, OldGaugeData
, OldGaugeDataSize
);
187 FreePool (OldGaugeData
);
190 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
191 GaugeEntryExArray
[Index
].Handle
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) Handle
;
194 AsciiStrnCpy (GaugeEntryExArray
[Index
].Token
, Token
, DXE_PERFORMANCE_STRING_LENGTH
);
196 if (Module
!= NULL
) {
197 AsciiStrnCpy (GaugeEntryExArray
[Index
].Module
, Module
, DXE_PERFORMANCE_STRING_LENGTH
);
200 GaugeEntryExArray
[Index
].EndTimeStamp
= 0;
201 GaugeEntryExArray
[Index
].Identifier
= Identifier
;
203 if (TimeStamp
== 0) {
204 TimeStamp
= GetPerformanceCounter ();
206 GaugeEntryExArray
[Index
].StartTimeStamp
= TimeStamp
;
208 mGaugeData
->NumberOfEntries
++;
214 Searches the performance measurement log from the beginning of the log
215 for the first matching record that contains a zero end time and fills in a valid end time.
217 Searches the performance measurement log from the beginning of the log
218 for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
219 If the record can not be found then return EFI_NOT_FOUND.
220 If the record is found and TimeStamp is not zero,
221 then the end time in the record is filled in with the value specified by TimeStamp.
222 If the record is found and TimeStamp is zero, then the end time in the matching record
223 is filled in with the current time stamp value.
225 @param Handle Pointer to environment specific context used
226 to identify the component being measured.
227 @param Token Pointer to a Null-terminated ASCII string
228 that identifies the component being measured.
229 @param Module Pointer to a Null-terminated ASCII string
230 that identifies the module being measured.
231 @param TimeStamp 64-bit time stamp.
232 @param Identifier 32-bit identifier. If the value is 0, the found record
233 is same as the one found by EndGauge of PERFORMANCE_PROTOCOL.
235 @retval EFI_SUCCESS The end of the measurement was recorded.
236 @retval EFI_NOT_FOUND The specified measurement record could not be found.
242 IN CONST VOID
*Handle
, OPTIONAL
243 IN CONST CHAR8
*Token
, OPTIONAL
244 IN CONST CHAR8
*Module
, OPTIONAL
249 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
252 if (TimeStamp
== 0) {
253 TimeStamp
= GetPerformanceCounter ();
256 Index
= InternalSearchForGaugeEntry (Handle
, Token
, Module
, Identifier
);
257 if (Index
>= mGaugeData
->NumberOfEntries
) {
258 return EFI_NOT_FOUND
;
260 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
261 GaugeEntryExArray
[Index
].EndTimeStamp
= TimeStamp
;
267 Retrieves a previously logged performance measurement.
268 It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
269 and then assign the Identifier with 0.
271 Retrieves the performance log entry from the performance log specified by LogEntryKey.
272 If it stands for a valid entry, then EFI_SUCCESS is returned and
273 GaugeDataEntryEx stores the pointer to that entry.
275 @param LogEntryKey The key for the previous performance measurement log entry.
276 If 0, then the first performance measurement log entry is retrieved.
277 @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
278 if the retrieval is successful.
280 @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
281 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
282 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
283 @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
289 IN UINTN LogEntryKey
,
290 OUT GAUGE_DATA_ENTRY_EX
**GaugeDataEntryEx
293 UINTN NumberOfEntries
;
294 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
296 NumberOfEntries
= (UINTN
) (mGaugeData
->NumberOfEntries
);
297 if (LogEntryKey
> NumberOfEntries
) {
298 return EFI_INVALID_PARAMETER
;
300 if (LogEntryKey
== NumberOfEntries
) {
301 return EFI_NOT_FOUND
;
304 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
306 if (GaugeDataEntryEx
== NULL
) {
307 return EFI_INVALID_PARAMETER
;
309 *GaugeDataEntryEx
= &GaugeEntryExArray
[LogEntryKey
];
315 Adds a record at the end of the performance measurement log
316 that records the start time of a performance measurement.
318 Adds a record to the end of the performance measurement log
319 that contains the Handle, Token, and Module.
320 The end time of the new record must be set to zero.
321 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
322 If TimeStamp is zero, the start time in the record is filled in with the value
323 read from the current time stamp.
325 @param Handle Pointer to environment specific context used
326 to identify the component being measured.
327 @param Token Pointer to a Null-terminated ASCII string
328 that identifies the component being measured.
329 @param Module Pointer to a Null-terminated ASCII string
330 that identifies the module being measured.
331 @param TimeStamp 64-bit time stamp.
333 @retval EFI_SUCCESS The data was read correctly from the device.
334 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
340 IN CONST VOID
*Handle
, OPTIONAL
341 IN CONST CHAR8
*Token
, OPTIONAL
342 IN CONST CHAR8
*Module
, OPTIONAL
346 return StartGaugeEx (Handle
, Token
, Module
, TimeStamp
, 0);
350 Searches the performance measurement log from the beginning of the log
351 for the first matching record that contains a zero end time and fills in a valid end time.
353 Searches the performance measurement log from the beginning of the log
354 for the first record that matches Handle, Token, and Module and has an end time value of zero.
355 If the record can not be found then return EFI_NOT_FOUND.
356 If the record is found and TimeStamp is not zero,
357 then the end time in the record is filled in with the value specified by TimeStamp.
358 If the record is found and TimeStamp is zero, then the end time in the matching record
359 is filled in with the current time stamp value.
361 @param Handle Pointer to environment specific context used
362 to identify the component being measured.
363 @param Token Pointer to a Null-terminated ASCII string
364 that identifies the component being measured.
365 @param Module Pointer to a Null-terminated ASCII string
366 that identifies the module being measured.
367 @param TimeStamp 64-bit time stamp.
369 @retval EFI_SUCCESS The end of the measurement was recorded.
370 @retval EFI_NOT_FOUND The specified measurement record could not be found.
376 IN CONST VOID
*Handle
, OPTIONAL
377 IN CONST CHAR8
*Token
, OPTIONAL
378 IN CONST CHAR8
*Module
, OPTIONAL
382 return EndGaugeEx (Handle
, Token
, Module
, TimeStamp
, 0);
386 Retrieves a previously logged performance measurement.
387 It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
388 and then eliminate the Identifier.
390 Retrieves the performance log entry from the performance log specified by LogEntryKey.
391 If it stands for a valid entry, then EFI_SUCCESS is returned and
392 GaugeDataEntry stores the pointer to that entry.
394 @param LogEntryKey The key for the previous performance measurement log entry.
395 If 0, then the first performance measurement log entry is retrieved.
396 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
397 if the retrieval is successful.
399 @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
400 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
401 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
402 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
408 IN UINTN LogEntryKey
,
409 OUT GAUGE_DATA_ENTRY
**GaugeDataEntry
413 GAUGE_DATA_ENTRY_EX
*GaugeEntryEx
;
417 Status
= GetGaugeEx (LogEntryKey
, &GaugeEntryEx
);
418 if (EFI_ERROR (Status
)) {
422 if (GaugeDataEntry
== NULL
) {
423 return EFI_INVALID_PARAMETER
;
426 *GaugeDataEntry
= (GAUGE_DATA_ENTRY
*) GaugeEntryEx
;
432 Dumps all the PEI performance log to DXE performance gauge array.
434 This internal function dumps all the PEI performance log to the DXE performance gauge array.
435 It retrieves the optional GUID HOB for PEI performance and then saves the performance data
436 to DXE performance data structures.
440 InternalGetPeiPerformance (
444 EFI_HOB_GUID_TYPE
*GuidHob
;
445 PEI_PERFORMANCE_LOG_HEADER
*LogHob
;
446 PEI_PERFORMANCE_LOG_ENTRY
*LogEntryArray
;
448 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
450 UINT32 NumberOfEntries
;
453 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
456 // Dump PEI Log Entries to DXE Guage Data structure.
458 GuidHob
= GetFirstGuidHob (&gPerformanceProtocolGuid
);
459 if (GuidHob
!= NULL
) {
460 LogHob
= GET_GUID_HOB_DATA (GuidHob
);
461 LogEntryArray
= (PEI_PERFORMANCE_LOG_ENTRY
*) (LogHob
+ 1);
463 NumberOfEntries
= LogHob
->NumberOfEntries
;
464 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
465 GaugeEntryExArray
[Index
].Handle
= LogEntryArray
[Index
].Handle
;
466 AsciiStrnCpy (GaugeEntryExArray
[Index
].Token
, LogEntryArray
[Index
].Token
, DXE_PERFORMANCE_STRING_LENGTH
);
467 AsciiStrnCpy (GaugeEntryExArray
[Index
].Module
, LogEntryArray
[Index
].Module
, DXE_PERFORMANCE_STRING_LENGTH
);
468 GaugeEntryExArray
[Index
].StartTimeStamp
= LogEntryArray
[Index
].StartTimeStamp
;
469 GaugeEntryExArray
[Index
].EndTimeStamp
= LogEntryArray
[Index
].EndTimeStamp
;
470 GaugeEntryExArray
[Index
].Identifier
= 0;
473 GuidHob
= GetFirstGuidHob (&gPerformanceExProtocolGuid
);
474 if (GuidHob
!= NULL
) {
475 LogIdArray
= GET_GUID_HOB_DATA (GuidHob
);
476 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
477 GaugeEntryExArray
[Index
].Identifier
= LogIdArray
[Index
];
481 mGaugeData
->NumberOfEntries
= NumberOfEntries
;
485 The constructor function initializes Performance infrastructure for DXE phase.
487 The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
488 and merges PEI performance data to DXE performance log.
489 It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
491 @param ImageHandle The firmware allocated handle for the EFI image.
492 @param SystemTable A pointer to the EFI System Table.
494 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
499 DxeCorePerformanceLibConstructor (
500 IN EFI_HANDLE ImageHandle
,
501 IN EFI_SYSTEM_TABLE
*SystemTable
506 if (!PerformanceMeasurementEnabled ()) {
508 // Do not initialize performance infrastructure if not required.
513 // Install the protocol interfaces.
515 Status
= gBS
->InstallMultipleProtocolInterfaces (
517 &gPerformanceProtocolGuid
,
518 &mPerformanceInterface
,
519 &gPerformanceExProtocolGuid
,
520 &mPerformanceExInterface
,
523 ASSERT_EFI_ERROR (Status
);
525 mMaxGaugeRecords
= INIT_DXE_GAUGE_DATA_ENTRIES
+ PcdGet8 (PcdMaxPeiPerformanceLogEntries
);
527 mGaugeData
= AllocateZeroPool (sizeof (GAUGE_DATA_HEADER
) + (sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
));
528 ASSERT (mGaugeData
!= NULL
);
530 InternalGetPeiPerformance ();
536 Adds a record at the end of the performance measurement log
537 that records the start time of a performance measurement.
539 Adds a record to the end of the performance measurement log
540 that contains the Handle, Token, Module and Identifier.
541 The end time of the new record must be set to zero.
542 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
543 If TimeStamp is zero, the start time in the record is filled in with the value
544 read from the current time stamp.
546 @param Handle Pointer to environment specific context used
547 to identify the component being measured.
548 @param Token Pointer to a Null-terminated ASCII string
549 that identifies the component being measured.
550 @param Module Pointer to a Null-terminated ASCII string
551 that identifies the module being measured.
552 @param TimeStamp 64-bit time stamp.
553 @param Identifier 32-bit identifier. If the value is 0, the created record
554 is same as the one created by StartPerformanceMeasurement.
556 @retval RETURN_SUCCESS The start of the measurement was recorded.
557 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
562 StartPerformanceMeasurementEx (
563 IN CONST VOID
*Handle
, OPTIONAL
564 IN CONST CHAR8
*Token
, OPTIONAL
565 IN CONST CHAR8
*Module
, OPTIONAL
570 return (RETURN_STATUS
) StartGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
574 Searches the performance measurement log from the beginning of the log
575 for the first matching record that contains a zero end time and fills in a valid end time.
577 Searches the performance measurement log from the beginning of the log
578 for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
579 If the record can not be found then return RETURN_NOT_FOUND.
580 If the record is found and TimeStamp is not zero,
581 then the end time in the record is filled in with the value specified by TimeStamp.
582 If the record is found and TimeStamp is zero, then the end time in the matching record
583 is filled in with the current time stamp value.
585 @param Handle Pointer to environment specific context used
586 to identify the component being measured.
587 @param Token Pointer to a Null-terminated ASCII string
588 that identifies the component being measured.
589 @param Module Pointer to a Null-terminated ASCII string
590 that identifies the module being measured.
591 @param TimeStamp 64-bit time stamp.
592 @param Identifier 32-bit identifier. If the value is 0, the found record
593 is same as the one found by EndPerformanceMeasurement.
595 @retval RETURN_SUCCESS The end of the measurement was recorded.
596 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
601 EndPerformanceMeasurementEx (
602 IN CONST VOID
*Handle
, OPTIONAL
603 IN CONST CHAR8
*Token
, OPTIONAL
604 IN CONST CHAR8
*Module
, OPTIONAL
609 return (RETURN_STATUS
) EndGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
613 Attempts to retrieve a performance measurement log entry from the performance measurement log.
614 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
615 and then assign the Identifier with 0.
617 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
618 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
619 and the key for the second entry in the log is returned. If the performance log is empty,
620 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
621 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
622 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
623 retrieved and an implementation specific non-zero key value that specifies the end of the performance
624 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
625 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
626 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
627 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
628 If Handle is NULL, then ASSERT().
629 If Token is NULL, then ASSERT().
630 If Module is NULL, then ASSERT().
631 If StartTimeStamp is NULL, then ASSERT().
632 If EndTimeStamp is NULL, then ASSERT().
633 If Identifier is NULL, then ASSERT().
635 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
636 0, then the first performance measurement log entry is retrieved.
637 On exit, the key of the next performance log entry.
638 @param Handle Pointer to environment specific context used to identify the component
640 @param Token Pointer to a Null-terminated ASCII string that identifies the component
642 @param Module Pointer to a Null-terminated ASCII string that identifies the module
644 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
646 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
648 @param Identifier Pointer to the 32-bit identifier that was recorded.
650 @return The key for the next performance log entry (in general case).
655 GetPerformanceMeasurementEx (
656 IN UINTN LogEntryKey
,
657 OUT CONST VOID
**Handle
,
658 OUT CONST CHAR8
**Token
,
659 OUT CONST CHAR8
**Module
,
660 OUT UINT64
*StartTimeStamp
,
661 OUT UINT64
*EndTimeStamp
,
662 OUT UINT32
*Identifier
666 GAUGE_DATA_ENTRY_EX
*GaugeData
;
670 ASSERT (Handle
!= NULL
);
671 ASSERT (Token
!= NULL
);
672 ASSERT (Module
!= NULL
);
673 ASSERT (StartTimeStamp
!= NULL
);
674 ASSERT (EndTimeStamp
!= NULL
);
675 ASSERT (Identifier
!= NULL
);
677 Status
= GetGaugeEx (LogEntryKey
++, &GaugeData
);
680 // Make sure that LogEntryKey is a valid log entry key,
682 ASSERT (Status
!= EFI_INVALID_PARAMETER
);
684 if (EFI_ERROR (Status
)) {
686 // The LogEntryKey is the last entry (equals to the total entry number).
691 ASSERT (GaugeData
!= NULL
);
693 *Handle
= (VOID
*) (UINTN
) GaugeData
->Handle
;
694 *Token
= GaugeData
->Token
;
695 *Module
= GaugeData
->Module
;
696 *StartTimeStamp
= GaugeData
->StartTimeStamp
;
697 *EndTimeStamp
= GaugeData
->EndTimeStamp
;
698 *Identifier
= GaugeData
->Identifier
;
704 Adds a record at the end of the performance measurement log
705 that records the start time of a performance measurement.
707 Adds a record to the end of the performance measurement log
708 that contains the Handle, Token, and Module.
709 The end time of the new record must be set to zero.
710 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
711 If TimeStamp is zero, the start time in the record is filled in with the value
712 read from the current time stamp.
714 @param Handle Pointer to environment specific context used
715 to identify the component being measured.
716 @param Token Pointer to a Null-terminated ASCII string
717 that identifies the component being measured.
718 @param Module Pointer to a Null-terminated ASCII string
719 that identifies the module being measured.
720 @param TimeStamp 64-bit time stamp.
722 @retval RETURN_SUCCESS The start of the measurement was recorded.
723 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
728 StartPerformanceMeasurement (
729 IN CONST VOID
*Handle
, OPTIONAL
730 IN CONST CHAR8
*Token
, OPTIONAL
731 IN CONST CHAR8
*Module
, OPTIONAL
735 return StartPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
739 Searches the performance measurement log from the beginning of the log
740 for the first matching record that contains a zero end time and fills in a valid end time.
742 Searches the performance measurement log from the beginning of the log
743 for the first record that matches Handle, Token, and Module and has an end time value of zero.
744 If the record can not be found then return RETURN_NOT_FOUND.
745 If the record is found and TimeStamp is not zero,
746 then the end time in the record is filled in with the value specified by TimeStamp.
747 If the record is found and TimeStamp is zero, then the end time in the matching record
748 is filled in with the current time stamp value.
750 @param Handle Pointer to environment specific context used
751 to identify the component being measured.
752 @param Token Pointer to a Null-terminated ASCII string
753 that identifies the component being measured.
754 @param Module Pointer to a Null-terminated ASCII string
755 that identifies the module being measured.
756 @param TimeStamp 64-bit time stamp.
758 @retval RETURN_SUCCESS The end of the measurement was recorded.
759 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
764 EndPerformanceMeasurement (
765 IN CONST VOID
*Handle
, OPTIONAL
766 IN CONST CHAR8
*Token
, OPTIONAL
767 IN CONST CHAR8
*Module
, OPTIONAL
771 return EndPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
775 Attempts to retrieve a performance measurement log entry from the performance measurement log.
776 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
777 and then eliminate the Identifier.
779 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
780 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
781 and the key for the second entry in the log is returned. If the performance log is empty,
782 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
783 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
784 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
785 retrieved and an implementation specific non-zero key value that specifies the end of the performance
786 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
787 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
788 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
789 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
790 If Handle is NULL, then ASSERT().
791 If Token is NULL, then ASSERT().
792 If Module is NULL, then ASSERT().
793 If StartTimeStamp is NULL, then ASSERT().
794 If EndTimeStamp is NULL, then ASSERT().
796 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
797 0, then the first performance measurement log entry is retrieved.
798 On exit, the key of the next performance log entry.
799 @param Handle Pointer to environment specific context used to identify the component
801 @param Token Pointer to a Null-terminated ASCII string that identifies the component
803 @param Module Pointer to a Null-terminated ASCII string that identifies the module
805 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
807 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
810 @return The key for the next performance log entry (in general case).
815 GetPerformanceMeasurement (
816 IN UINTN LogEntryKey
,
817 OUT CONST VOID
**Handle
,
818 OUT CONST CHAR8
**Token
,
819 OUT CONST CHAR8
**Module
,
820 OUT UINT64
*StartTimeStamp
,
821 OUT UINT64
*EndTimeStamp
825 return GetPerformanceMeasurementEx (LogEntryKey
, Handle
, Token
, Module
, StartTimeStamp
, EndTimeStamp
, &Identifier
);
829 Returns TRUE if the performance measurement macros are enabled.
831 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
832 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
834 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
835 PcdPerformanceLibraryPropertyMask is set.
836 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
837 PcdPerformanceLibraryPropertyMask is clear.
842 PerformanceMeasurementEnabled (
846 return (BOOLEAN
) ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0);