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 - 2016, 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"
30 // The data structure to hold global performance data.
32 GAUGE_DATA_HEADER
*mGaugeData
;
35 // The current maximum number of logging entries. If current number of
36 // entries exceeds this value, it will re-allocate a larger array and
37 // migration the old data to the larger array.
39 UINT32 mMaxGaugeRecords
;
42 // The handle to install Performance Protocol instance.
44 EFI_HANDLE mHandle
= NULL
;
47 // Interfaces for Performance Protocol.
49 PERFORMANCE_PROTOCOL mPerformanceInterface
= {
56 // Interfaces for PerformanceEx Protocol.
58 PERFORMANCE_EX_PROTOCOL mPerformanceExInterface
= {
65 Searches in the gauge array with keyword Handle, Token, Module and Identifier.
67 This internal function searches for the gauge entry in the gauge array.
68 If there is an entry that exactly matches the given keywords
69 and its end time stamp is zero, then the index of that gauge entry is returned;
70 otherwise, the the number of gauge entries in the array is returned.
72 @param Handle Pointer to environment specific context used
73 to identify the component being measured.
74 @param Token Pointer to a Null-terminated ASCII string
75 that identifies the component being measured.
76 @param Module Pointer to a Null-terminated ASCII string
77 that identifies the module being measured.
78 @param Identifier 32-bit identifier.
80 @retval The index of gauge entry in the array.
84 InternalSearchForGaugeEntry (
85 IN CONST VOID
*Handle
, OPTIONAL
86 IN CONST CHAR8
*Token
, OPTIONAL
87 IN CONST CHAR8
*Module
, OPTIONAL
93 UINT32 NumberOfEntries
;
94 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
103 NumberOfEntries
= mGaugeData
->NumberOfEntries
;
104 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
108 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
109 Index2
= NumberOfEntries
- 1 - Index
;
110 if (GaugeEntryExArray
[Index2
].EndTimeStamp
== 0 &&
111 (GaugeEntryExArray
[Index2
].Handle
== (EFI_PHYSICAL_ADDRESS
) (UINTN
) Handle
) &&
112 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Token
, Token
, DXE_PERFORMANCE_STRING_LENGTH
) == 0 &&
113 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Module
, Module
, DXE_PERFORMANCE_STRING_LENGTH
) == 0) {
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 AsciiStrnCpyS (GaugeEntryExArray
[Index
].Token
, DXE_PERFORMANCE_STRING_SIZE
, Token
, DXE_PERFORMANCE_STRING_LENGTH
);
196 if (Module
!= NULL
) {
197 AsciiStrnCpyS (GaugeEntryExArray
[Index
].Module
, DXE_PERFORMANCE_STRING_SIZE
, 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 and Module 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 AsciiStrCpyS (GaugeEntryExArray
[Index
].Token
, DXE_PERFORMANCE_STRING_SIZE
, LogEntryArray
[Index
].Token
);
467 AsciiStrCpyS (GaugeEntryExArray
[Index
].Module
, DXE_PERFORMANCE_STRING_SIZE
, LogEntryArray
[Index
].Module
);
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
+ (UINT16
) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16
) != 0 ?
526 PcdGet16 (PcdMaxPeiPerformanceLogEntries16
) :
527 PcdGet8 (PcdMaxPeiPerformanceLogEntries
));
529 mGaugeData
= AllocateZeroPool (sizeof (GAUGE_DATA_HEADER
) + (sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
));
530 ASSERT (mGaugeData
!= NULL
);
532 InternalGetPeiPerformance ();
538 Adds a record at the end of the performance measurement log
539 that records the start time of a performance measurement.
541 Adds a record to the end of the performance measurement log
542 that contains the Handle, Token, Module and Identifier.
543 The end time of the new record must be set to zero.
544 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
545 If TimeStamp is zero, the start time in the record is filled in with the value
546 read from the current time stamp.
548 @param Handle Pointer to environment specific context used
549 to identify the component being measured.
550 @param Token Pointer to a Null-terminated ASCII string
551 that identifies the component being measured.
552 @param Module Pointer to a Null-terminated ASCII string
553 that identifies the module being measured.
554 @param TimeStamp 64-bit time stamp.
555 @param Identifier 32-bit identifier. If the value is 0, the created record
556 is same as the one created by StartPerformanceMeasurement.
558 @retval RETURN_SUCCESS The start of the measurement was recorded.
559 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
564 StartPerformanceMeasurementEx (
565 IN CONST VOID
*Handle
, OPTIONAL
566 IN CONST CHAR8
*Token
, OPTIONAL
567 IN CONST CHAR8
*Module
, OPTIONAL
572 return (RETURN_STATUS
) StartGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
576 Searches the performance measurement log from the beginning of the log
577 for the first matching record that contains a zero end time and fills in a valid end time.
579 Searches the performance measurement log from the beginning of the log
580 for the first record that matches Handle, Token and Module and has an end time value of zero.
581 If the record can not be found then return RETURN_NOT_FOUND.
582 If the record is found and TimeStamp is not zero,
583 then the end time in the record is filled in with the value specified by TimeStamp.
584 If the record is found and TimeStamp is zero, then the end time in the matching record
585 is filled in with the current time stamp value.
587 @param Handle Pointer to environment specific context used
588 to identify the component being measured.
589 @param Token Pointer to a Null-terminated ASCII string
590 that identifies the component being measured.
591 @param Module Pointer to a Null-terminated ASCII string
592 that identifies the module being measured.
593 @param TimeStamp 64-bit time stamp.
594 @param Identifier 32-bit identifier. If the value is 0, the found record
595 is same as the one found by EndPerformanceMeasurement.
597 @retval RETURN_SUCCESS The end of the measurement was recorded.
598 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
603 EndPerformanceMeasurementEx (
604 IN CONST VOID
*Handle
, OPTIONAL
605 IN CONST CHAR8
*Token
, OPTIONAL
606 IN CONST CHAR8
*Module
, OPTIONAL
611 return (RETURN_STATUS
) EndGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
615 Attempts to retrieve a performance measurement log entry from the performance measurement log.
616 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
617 and then assign the Identifier with 0.
619 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
620 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
621 and the key for the second entry in the log is returned. If the performance log is empty,
622 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
623 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
624 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
625 retrieved and an implementation specific non-zero key value that specifies the end of the performance
626 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
627 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
628 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
629 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
630 If Handle is NULL, then ASSERT().
631 If Token is NULL, then ASSERT().
632 If Module is NULL, then ASSERT().
633 If StartTimeStamp is NULL, then ASSERT().
634 If EndTimeStamp is NULL, then ASSERT().
635 If Identifier is NULL, then ASSERT().
637 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
638 0, then the first performance measurement log entry is retrieved.
639 On exit, the key of the next performance log entry.
640 @param Handle Pointer to environment specific context used to identify the component
642 @param Token Pointer to a Null-terminated ASCII string that identifies the component
644 @param Module Pointer to a Null-terminated ASCII string that identifies the module
646 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
648 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
650 @param Identifier Pointer to the 32-bit identifier that was recorded.
652 @return The key for the next performance log entry (in general case).
657 GetPerformanceMeasurementEx (
658 IN UINTN LogEntryKey
,
659 OUT CONST VOID
**Handle
,
660 OUT CONST CHAR8
**Token
,
661 OUT CONST CHAR8
**Module
,
662 OUT UINT64
*StartTimeStamp
,
663 OUT UINT64
*EndTimeStamp
,
664 OUT UINT32
*Identifier
668 GAUGE_DATA_ENTRY_EX
*GaugeData
;
672 ASSERT (Handle
!= NULL
);
673 ASSERT (Token
!= NULL
);
674 ASSERT (Module
!= NULL
);
675 ASSERT (StartTimeStamp
!= NULL
);
676 ASSERT (EndTimeStamp
!= NULL
);
677 ASSERT (Identifier
!= NULL
);
679 Status
= GetGaugeEx (LogEntryKey
++, &GaugeData
);
682 // Make sure that LogEntryKey is a valid log entry key,
684 ASSERT (Status
!= EFI_INVALID_PARAMETER
);
686 if (EFI_ERROR (Status
)) {
688 // The LogEntryKey is the last entry (equals to the total entry number).
693 ASSERT (GaugeData
!= NULL
);
695 *Handle
= (VOID
*) (UINTN
) GaugeData
->Handle
;
696 *Token
= GaugeData
->Token
;
697 *Module
= GaugeData
->Module
;
698 *StartTimeStamp
= GaugeData
->StartTimeStamp
;
699 *EndTimeStamp
= GaugeData
->EndTimeStamp
;
700 *Identifier
= GaugeData
->Identifier
;
706 Adds a record at the end of the performance measurement log
707 that records the start time of a performance measurement.
709 Adds a record to the end of the performance measurement log
710 that contains the Handle, Token, and Module.
711 The end time of the new record must be set to zero.
712 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
713 If TimeStamp is zero, the start time in the record is filled in with the value
714 read from the current time stamp.
716 @param Handle Pointer to environment specific context used
717 to identify the component being measured.
718 @param Token Pointer to a Null-terminated ASCII string
719 that identifies the component being measured.
720 @param Module Pointer to a Null-terminated ASCII string
721 that identifies the module being measured.
722 @param TimeStamp 64-bit time stamp.
724 @retval RETURN_SUCCESS The start of the measurement was recorded.
725 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
730 StartPerformanceMeasurement (
731 IN CONST VOID
*Handle
, OPTIONAL
732 IN CONST CHAR8
*Token
, OPTIONAL
733 IN CONST CHAR8
*Module
, OPTIONAL
737 return StartPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
741 Searches the performance measurement log from the beginning of the log
742 for the first matching record that contains a zero end time and fills in a valid end time.
744 Searches the performance measurement log from the beginning of the log
745 for the first record that matches Handle, Token, and Module and has an end time value of zero.
746 If the record can not be found then return RETURN_NOT_FOUND.
747 If the record is found and TimeStamp is not zero,
748 then the end time in the record is filled in with the value specified by TimeStamp.
749 If the record is found and TimeStamp is zero, then the end time in the matching record
750 is filled in with the current time stamp value.
752 @param Handle Pointer to environment specific context used
753 to identify the component being measured.
754 @param Token Pointer to a Null-terminated ASCII string
755 that identifies the component being measured.
756 @param Module Pointer to a Null-terminated ASCII string
757 that identifies the module being measured.
758 @param TimeStamp 64-bit time stamp.
760 @retval RETURN_SUCCESS The end of the measurement was recorded.
761 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
766 EndPerformanceMeasurement (
767 IN CONST VOID
*Handle
, OPTIONAL
768 IN CONST CHAR8
*Token
, OPTIONAL
769 IN CONST CHAR8
*Module
, OPTIONAL
773 return EndPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
777 Attempts to retrieve a performance measurement log entry from the performance measurement log.
778 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
779 and then eliminate the Identifier.
781 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
782 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
783 and the key for the second entry in the log is returned. If the performance log is empty,
784 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
785 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
786 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
787 retrieved and an implementation specific non-zero key value that specifies the end of the performance
788 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
789 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
790 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
791 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
792 If Handle is NULL, then ASSERT().
793 If Token is NULL, then ASSERT().
794 If Module is NULL, then ASSERT().
795 If StartTimeStamp is NULL, then ASSERT().
796 If EndTimeStamp is NULL, then ASSERT().
798 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
799 0, then the first performance measurement log entry is retrieved.
800 On exit, the key of the next performance log entry.
801 @param Handle Pointer to environment specific context used to identify the component
803 @param Token Pointer to a Null-terminated ASCII string that identifies the component
805 @param Module Pointer to a Null-terminated ASCII string that identifies the module
807 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
809 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
812 @return The key for the next performance log entry (in general case).
817 GetPerformanceMeasurement (
818 IN UINTN LogEntryKey
,
819 OUT CONST VOID
**Handle
,
820 OUT CONST CHAR8
**Token
,
821 OUT CONST CHAR8
**Module
,
822 OUT UINT64
*StartTimeStamp
,
823 OUT UINT64
*EndTimeStamp
827 return GetPerformanceMeasurementEx (LogEntryKey
, Handle
, Token
, Module
, StartTimeStamp
, EndTimeStamp
, &Identifier
);
831 Returns TRUE if the performance measurement macros are enabled.
833 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
834 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
836 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
837 PcdPerformanceLibraryPropertyMask is set.
838 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
839 PcdPerformanceLibraryPropertyMask is clear.
844 PerformanceMeasurementEnabled (
848 return (BOOLEAN
) ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0);