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 - 2017, 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
= {
64 PERFORMANCE_PROPERTY mPerformanceProperty
;
67 Searches in the gauge array with keyword Handle, Token, Module and Identifier.
69 This internal function searches for the gauge entry in the gauge array.
70 If there is an entry that exactly matches the given keywords
71 and its end time stamp is zero, then the index of that gauge entry is returned;
72 otherwise, the the number of gauge entries in the array is returned.
74 @param Handle Pointer to environment specific context used
75 to identify the component being measured.
76 @param Token Pointer to a Null-terminated ASCII string
77 that identifies the component being measured.
78 @param Module Pointer to a Null-terminated ASCII string
79 that identifies the module being measured.
80 @param Identifier 32-bit identifier.
82 @retval The index of gauge entry in the array.
86 InternalSearchForGaugeEntry (
87 IN CONST VOID
*Handle
, OPTIONAL
88 IN CONST CHAR8
*Token
, OPTIONAL
89 IN CONST CHAR8
*Module
, OPTIONAL
95 UINT32 NumberOfEntries
;
96 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
101 if (Module
== NULL
) {
105 NumberOfEntries
= mGaugeData
->NumberOfEntries
;
106 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
110 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
111 Index2
= NumberOfEntries
- 1 - Index
;
112 if (GaugeEntryExArray
[Index2
].EndTimeStamp
== 0 &&
113 (GaugeEntryExArray
[Index2
].Handle
== (EFI_PHYSICAL_ADDRESS
) (UINTN
) Handle
) &&
114 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Token
, Token
, DXE_PERFORMANCE_STRING_LENGTH
) == 0 &&
115 AsciiStrnCmp (GaugeEntryExArray
[Index2
].Module
, Module
, DXE_PERFORMANCE_STRING_LENGTH
) == 0) {
125 Adds a record at the end of the performance measurement log
126 that records the start time of a performance measurement.
128 Adds a record to the end of the performance measurement log
129 that contains the Handle, Token, Module and Identifier.
130 The end time of the new record must be set to zero.
131 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
132 If TimeStamp is zero, the start time in the record is filled in with the value
133 read from the current time stamp.
135 @param Handle Pointer to environment specific context used
136 to identify the component being measured.
137 @param Token Pointer to a Null-terminated ASCII string
138 that identifies the component being measured.
139 @param Module Pointer to a Null-terminated ASCII string
140 that identifies the module being measured.
141 @param TimeStamp 64-bit time stamp.
142 @param Identifier 32-bit identifier. If the value is 0, the created record
143 is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.
145 @retval EFI_SUCCESS The data was read correctly from the device.
146 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
152 IN CONST VOID
*Handle
, OPTIONAL
153 IN CONST CHAR8
*Token
, OPTIONAL
154 IN CONST CHAR8
*Module
, OPTIONAL
159 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
161 GAUGE_DATA_HEADER
*NewGaugeData
;
162 UINTN OldGaugeDataSize
;
163 GAUGE_DATA_HEADER
*OldGaugeData
;
166 Index
= mGaugeData
->NumberOfEntries
;
167 if (Index
>= mMaxGaugeRecords
) {
169 // Try to enlarge the scale of gauge array.
171 OldGaugeData
= mGaugeData
;
172 OldGaugeDataSize
= sizeof (GAUGE_DATA_HEADER
) + sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
;
174 GaugeDataSize
= sizeof (GAUGE_DATA_HEADER
) + sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
* 2;
176 NewGaugeData
= AllocateZeroPool (GaugeDataSize
);
177 if (NewGaugeData
== NULL
) {
178 return EFI_OUT_OF_RESOURCES
;
181 mGaugeData
= NewGaugeData
;
182 mMaxGaugeRecords
*= 2;
185 // Initialize new data array and migrate old data one.
187 mGaugeData
= CopyMem (mGaugeData
, OldGaugeData
, OldGaugeDataSize
);
189 FreePool (OldGaugeData
);
192 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
193 GaugeEntryExArray
[Index
].Handle
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) Handle
;
196 AsciiStrnCpyS (GaugeEntryExArray
[Index
].Token
, DXE_PERFORMANCE_STRING_SIZE
, Token
, DXE_PERFORMANCE_STRING_LENGTH
);
198 if (Module
!= NULL
) {
199 AsciiStrnCpyS (GaugeEntryExArray
[Index
].Module
, DXE_PERFORMANCE_STRING_SIZE
, Module
, DXE_PERFORMANCE_STRING_LENGTH
);
202 GaugeEntryExArray
[Index
].EndTimeStamp
= 0;
203 GaugeEntryExArray
[Index
].Identifier
= Identifier
;
205 if (TimeStamp
== 0) {
206 TimeStamp
= GetPerformanceCounter ();
208 GaugeEntryExArray
[Index
].StartTimeStamp
= TimeStamp
;
210 mGaugeData
->NumberOfEntries
++;
216 Searches the performance measurement log from the beginning of the log
217 for the first matching record that contains a zero end time and fills in a valid end time.
219 Searches the performance measurement log from the beginning of the log
220 for the first record that matches Handle, Token and Module and has an end time value of zero.
221 If the record can not be found then return EFI_NOT_FOUND.
222 If the record is found and TimeStamp is not zero,
223 then the end time in the record is filled in with the value specified by TimeStamp.
224 If the record is found and TimeStamp is zero, then the end time in the matching record
225 is filled in with the current time stamp value.
227 @param Handle Pointer to environment specific context used
228 to identify the component being measured.
229 @param Token Pointer to a Null-terminated ASCII string
230 that identifies the component being measured.
231 @param Module Pointer to a Null-terminated ASCII string
232 that identifies the module being measured.
233 @param TimeStamp 64-bit time stamp.
234 @param Identifier 32-bit identifier. If the value is 0, the found record
235 is same as the one found by EndGauge of PERFORMANCE_PROTOCOL.
237 @retval EFI_SUCCESS The end of the measurement was recorded.
238 @retval EFI_NOT_FOUND The specified measurement record could not be found.
244 IN CONST VOID
*Handle
, OPTIONAL
245 IN CONST CHAR8
*Token
, OPTIONAL
246 IN CONST CHAR8
*Module
, OPTIONAL
251 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
254 if (TimeStamp
== 0) {
255 TimeStamp
= GetPerformanceCounter ();
258 Index
= InternalSearchForGaugeEntry (Handle
, Token
, Module
, Identifier
);
259 if (Index
>= mGaugeData
->NumberOfEntries
) {
260 return EFI_NOT_FOUND
;
262 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
263 GaugeEntryExArray
[Index
].EndTimeStamp
= TimeStamp
;
269 Retrieves a previously logged performance measurement.
270 It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
271 and then assign the Identifier with 0.
273 Retrieves the performance log entry from the performance log specified by LogEntryKey.
274 If it stands for a valid entry, then EFI_SUCCESS is returned and
275 GaugeDataEntryEx stores the pointer to that entry.
277 @param LogEntryKey The key for the previous performance measurement log entry.
278 If 0, then the first performance measurement log entry is retrieved.
279 @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
280 if the retrieval is successful.
282 @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
283 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
284 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
285 @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
291 IN UINTN LogEntryKey
,
292 OUT GAUGE_DATA_ENTRY_EX
**GaugeDataEntryEx
295 UINTN NumberOfEntries
;
296 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
298 NumberOfEntries
= (UINTN
) (mGaugeData
->NumberOfEntries
);
299 if (LogEntryKey
> NumberOfEntries
) {
300 return EFI_INVALID_PARAMETER
;
302 if (LogEntryKey
== NumberOfEntries
) {
303 return EFI_NOT_FOUND
;
306 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
308 if (GaugeDataEntryEx
== NULL
) {
309 return EFI_INVALID_PARAMETER
;
311 *GaugeDataEntryEx
= &GaugeEntryExArray
[LogEntryKey
];
317 Adds a record at the end of the performance measurement log
318 that records the start time of a performance measurement.
320 Adds a record to the end of the performance measurement log
321 that contains the Handle, Token, and Module.
322 The end time of the new record must be set to zero.
323 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
324 If TimeStamp is zero, the start time in the record is filled in with the value
325 read from the current time stamp.
327 @param Handle Pointer to environment specific context used
328 to identify the component being measured.
329 @param Token Pointer to a Null-terminated ASCII string
330 that identifies the component being measured.
331 @param Module Pointer to a Null-terminated ASCII string
332 that identifies the module being measured.
333 @param TimeStamp 64-bit time stamp.
335 @retval EFI_SUCCESS The data was read correctly from the device.
336 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
342 IN CONST VOID
*Handle
, OPTIONAL
343 IN CONST CHAR8
*Token
, OPTIONAL
344 IN CONST CHAR8
*Module
, OPTIONAL
348 return StartGaugeEx (Handle
, Token
, Module
, TimeStamp
, 0);
352 Searches the performance measurement log from the beginning of the log
353 for the first matching record that contains a zero end time and fills in a valid end time.
355 Searches the performance measurement log from the beginning of the log
356 for the first record that matches Handle, Token, and Module and has an end time value of zero.
357 If the record can not be found then return EFI_NOT_FOUND.
358 If the record is found and TimeStamp is not zero,
359 then the end time in the record is filled in with the value specified by TimeStamp.
360 If the record is found and TimeStamp is zero, then the end time in the matching record
361 is filled in with the current time stamp value.
363 @param Handle Pointer to environment specific context used
364 to identify the component being measured.
365 @param Token Pointer to a Null-terminated ASCII string
366 that identifies the component being measured.
367 @param Module Pointer to a Null-terminated ASCII string
368 that identifies the module being measured.
369 @param TimeStamp 64-bit time stamp.
371 @retval EFI_SUCCESS The end of the measurement was recorded.
372 @retval EFI_NOT_FOUND The specified measurement record could not be found.
378 IN CONST VOID
*Handle
, OPTIONAL
379 IN CONST CHAR8
*Token
, OPTIONAL
380 IN CONST CHAR8
*Module
, OPTIONAL
384 return EndGaugeEx (Handle
, Token
, Module
, TimeStamp
, 0);
388 Retrieves a previously logged performance measurement.
389 It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
390 and then eliminate the Identifier.
392 Retrieves the performance log entry from the performance log specified by LogEntryKey.
393 If it stands for a valid entry, then EFI_SUCCESS is returned and
394 GaugeDataEntry stores the pointer to that entry.
396 @param LogEntryKey The key for the previous performance measurement log entry.
397 If 0, then the first performance measurement log entry is retrieved.
398 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
399 if the retrieval is successful.
401 @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
402 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
403 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
404 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
410 IN UINTN LogEntryKey
,
411 OUT GAUGE_DATA_ENTRY
**GaugeDataEntry
415 GAUGE_DATA_ENTRY_EX
*GaugeEntryEx
;
419 Status
= GetGaugeEx (LogEntryKey
, &GaugeEntryEx
);
420 if (EFI_ERROR (Status
)) {
424 if (GaugeDataEntry
== NULL
) {
425 return EFI_INVALID_PARAMETER
;
428 *GaugeDataEntry
= (GAUGE_DATA_ENTRY
*) GaugeEntryEx
;
434 Dumps all the PEI performance log to DXE performance gauge array.
436 This internal function dumps all the PEI performance log to the DXE performance gauge array.
437 It retrieves the optional GUID HOB for PEI performance and then saves the performance data
438 to DXE performance data structures.
442 InternalGetPeiPerformance (
446 EFI_HOB_GUID_TYPE
*GuidHob
;
447 PEI_PERFORMANCE_LOG_HEADER
*LogHob
;
448 PEI_PERFORMANCE_LOG_ENTRY
*LogEntryArray
;
450 GAUGE_DATA_ENTRY_EX
*GaugeEntryExArray
;
452 UINT32 NumberOfEntries
;
455 GaugeEntryExArray
= (GAUGE_DATA_ENTRY_EX
*) (mGaugeData
+ 1);
458 // Dump PEI Log Entries to DXE Guage Data structure.
460 GuidHob
= GetFirstGuidHob (&gPerformanceProtocolGuid
);
461 if (GuidHob
!= NULL
) {
462 LogHob
= GET_GUID_HOB_DATA (GuidHob
);
463 LogEntryArray
= (PEI_PERFORMANCE_LOG_ENTRY
*) (LogHob
+ 1);
465 NumberOfEntries
= LogHob
->NumberOfEntries
;
466 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
467 GaugeEntryExArray
[Index
].Handle
= LogEntryArray
[Index
].Handle
;
468 AsciiStrCpyS (GaugeEntryExArray
[Index
].Token
, DXE_PERFORMANCE_STRING_SIZE
, LogEntryArray
[Index
].Token
);
469 AsciiStrCpyS (GaugeEntryExArray
[Index
].Module
, DXE_PERFORMANCE_STRING_SIZE
, LogEntryArray
[Index
].Module
);
470 GaugeEntryExArray
[Index
].StartTimeStamp
= LogEntryArray
[Index
].StartTimeStamp
;
471 GaugeEntryExArray
[Index
].EndTimeStamp
= LogEntryArray
[Index
].EndTimeStamp
;
472 GaugeEntryExArray
[Index
].Identifier
= 0;
475 GuidHob
= GetFirstGuidHob (&gPerformanceExProtocolGuid
);
476 if (GuidHob
!= NULL
) {
477 LogIdArray
= GET_GUID_HOB_DATA (GuidHob
);
478 for (Index
= 0; Index
< NumberOfEntries
; Index
++) {
479 GaugeEntryExArray
[Index
].Identifier
= LogIdArray
[Index
];
483 mGaugeData
->NumberOfEntries
= NumberOfEntries
;
487 The constructor function initializes Performance infrastructure for DXE phase.
489 The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
490 and merges PEI performance data to DXE performance log.
491 It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
493 @param ImageHandle The firmware allocated handle for the EFI image.
494 @param SystemTable A pointer to the EFI System Table.
496 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
501 DxeCorePerformanceLibConstructor (
502 IN EFI_HANDLE ImageHandle
,
503 IN EFI_SYSTEM_TABLE
*SystemTable
507 PERFORMANCE_PROPERTY
*PerformanceProperty
;
510 if (!PerformanceMeasurementEnabled ()) {
512 // Do not initialize performance infrastructure if not required.
517 // Install the protocol interfaces.
519 Status
= gBS
->InstallMultipleProtocolInterfaces (
521 &gPerformanceProtocolGuid
,
522 &mPerformanceInterface
,
523 &gPerformanceExProtocolGuid
,
524 &mPerformanceExInterface
,
527 ASSERT_EFI_ERROR (Status
);
529 mMaxGaugeRecords
= INIT_DXE_GAUGE_DATA_ENTRIES
+ (UINT16
) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16
) != 0 ?
530 PcdGet16 (PcdMaxPeiPerformanceLogEntries16
) :
531 PcdGet8 (PcdMaxPeiPerformanceLogEntries
));
533 mGaugeData
= AllocateZeroPool (sizeof (GAUGE_DATA_HEADER
) + (sizeof (GAUGE_DATA_ENTRY_EX
) * mMaxGaugeRecords
));
534 ASSERT (mGaugeData
!= NULL
);
536 InternalGetPeiPerformance ();
538 Status
= EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid
, (VOID
**) &PerformanceProperty
);
539 if (EFI_ERROR (Status
)) {
541 // Install configuration table for performance property.
543 mPerformanceProperty
.Revision
= PERFORMANCE_PROPERTY_REVISION
;
544 mPerformanceProperty
.Reserved
= 0;
545 mPerformanceProperty
.Frequency
= GetPerformanceCounterProperties (
546 &mPerformanceProperty
.TimerStartValue
,
547 &mPerformanceProperty
.TimerEndValue
549 Status
= gBS
->InstallConfigurationTable (&gPerformanceProtocolGuid
, &mPerformanceProperty
);
550 ASSERT_EFI_ERROR (Status
);
557 Adds a record at the end of the performance measurement log
558 that records the start time of a performance measurement.
560 Adds a record to the end of the performance measurement log
561 that contains the Handle, Token, Module and Identifier.
562 The end time of the new record must be set to zero.
563 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
564 If TimeStamp is zero, the start time in the record is filled in with the value
565 read from the current time stamp.
567 @param Handle Pointer to environment specific context used
568 to identify the component being measured.
569 @param Token Pointer to a Null-terminated ASCII string
570 that identifies the component being measured.
571 @param Module Pointer to a Null-terminated ASCII string
572 that identifies the module being measured.
573 @param TimeStamp 64-bit time stamp.
574 @param Identifier 32-bit identifier. If the value is 0, the created record
575 is same as the one created by StartPerformanceMeasurement.
577 @retval RETURN_SUCCESS The start of the measurement was recorded.
578 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
583 StartPerformanceMeasurementEx (
584 IN CONST VOID
*Handle
, OPTIONAL
585 IN CONST CHAR8
*Token
, OPTIONAL
586 IN CONST CHAR8
*Module
, OPTIONAL
591 return (RETURN_STATUS
) StartGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
595 Searches the performance measurement log from the beginning of the log
596 for the first matching record that contains a zero end time and fills in a valid end time.
598 Searches the performance measurement log from the beginning of the log
599 for the first record that matches Handle, Token and Module and has an end time value of zero.
600 If the record can not be found then return RETURN_NOT_FOUND.
601 If the record is found and TimeStamp is not zero,
602 then the end time in the record is filled in with the value specified by TimeStamp.
603 If the record is found and TimeStamp is zero, then the end time in the matching record
604 is filled in with the current time stamp value.
606 @param Handle Pointer to environment specific context used
607 to identify the component being measured.
608 @param Token Pointer to a Null-terminated ASCII string
609 that identifies the component being measured.
610 @param Module Pointer to a Null-terminated ASCII string
611 that identifies the module being measured.
612 @param TimeStamp 64-bit time stamp.
613 @param Identifier 32-bit identifier. If the value is 0, the found record
614 is same as the one found by EndPerformanceMeasurement.
616 @retval RETURN_SUCCESS The end of the measurement was recorded.
617 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
622 EndPerformanceMeasurementEx (
623 IN CONST VOID
*Handle
, OPTIONAL
624 IN CONST CHAR8
*Token
, OPTIONAL
625 IN CONST CHAR8
*Module
, OPTIONAL
630 return (RETURN_STATUS
) EndGaugeEx (Handle
, Token
, Module
, TimeStamp
, Identifier
);
634 Attempts to retrieve a performance measurement log entry from the performance measurement log.
635 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
636 and then assign the Identifier with 0.
638 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
639 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
640 and the key for the second entry in the log is returned. If the performance log is empty,
641 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
642 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
643 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
644 retrieved and an implementation specific non-zero key value that specifies the end of the performance
645 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
646 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
647 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
648 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
649 If Handle is NULL, then ASSERT().
650 If Token is NULL, then ASSERT().
651 If Module is NULL, then ASSERT().
652 If StartTimeStamp is NULL, then ASSERT().
653 If EndTimeStamp is NULL, then ASSERT().
654 If Identifier is NULL, then ASSERT().
656 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
657 0, then the first performance measurement log entry is retrieved.
658 On exit, the key of the next performance log entry.
659 @param Handle Pointer to environment specific context used to identify the component
661 @param Token Pointer to a Null-terminated ASCII string that identifies the component
663 @param Module Pointer to a Null-terminated ASCII string that identifies the module
665 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
667 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
669 @param Identifier Pointer to the 32-bit identifier that was recorded.
671 @return The key for the next performance log entry (in general case).
676 GetPerformanceMeasurementEx (
677 IN UINTN LogEntryKey
,
678 OUT CONST VOID
**Handle
,
679 OUT CONST CHAR8
**Token
,
680 OUT CONST CHAR8
**Module
,
681 OUT UINT64
*StartTimeStamp
,
682 OUT UINT64
*EndTimeStamp
,
683 OUT UINT32
*Identifier
687 GAUGE_DATA_ENTRY_EX
*GaugeData
;
691 ASSERT (Handle
!= NULL
);
692 ASSERT (Token
!= NULL
);
693 ASSERT (Module
!= NULL
);
694 ASSERT (StartTimeStamp
!= NULL
);
695 ASSERT (EndTimeStamp
!= NULL
);
696 ASSERT (Identifier
!= NULL
);
698 Status
= GetGaugeEx (LogEntryKey
++, &GaugeData
);
701 // Make sure that LogEntryKey is a valid log entry key,
703 ASSERT (Status
!= EFI_INVALID_PARAMETER
);
705 if (EFI_ERROR (Status
)) {
707 // The LogEntryKey is the last entry (equals to the total entry number).
712 ASSERT (GaugeData
!= NULL
);
714 *Handle
= (VOID
*) (UINTN
) GaugeData
->Handle
;
715 *Token
= GaugeData
->Token
;
716 *Module
= GaugeData
->Module
;
717 *StartTimeStamp
= GaugeData
->StartTimeStamp
;
718 *EndTimeStamp
= GaugeData
->EndTimeStamp
;
719 *Identifier
= GaugeData
->Identifier
;
725 Adds a record at the end of the performance measurement log
726 that records the start time of a performance measurement.
728 Adds a record to the end of the performance measurement log
729 that contains the Handle, Token, and Module.
730 The end time of the new record must be set to zero.
731 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
732 If TimeStamp is zero, the start time in the record is filled in with the value
733 read from the current time stamp.
735 @param Handle Pointer to environment specific context used
736 to identify the component being measured.
737 @param Token Pointer to a Null-terminated ASCII string
738 that identifies the component being measured.
739 @param Module Pointer to a Null-terminated ASCII string
740 that identifies the module being measured.
741 @param TimeStamp 64-bit time stamp.
743 @retval RETURN_SUCCESS The start of the measurement was recorded.
744 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
749 StartPerformanceMeasurement (
750 IN CONST VOID
*Handle
, OPTIONAL
751 IN CONST CHAR8
*Token
, OPTIONAL
752 IN CONST CHAR8
*Module
, OPTIONAL
756 return StartPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
760 Searches the performance measurement log from the beginning of the log
761 for the first matching record that contains a zero end time and fills in a valid end time.
763 Searches the performance measurement log from the beginning of the log
764 for the first record that matches Handle, Token, and Module and has an end time value of zero.
765 If the record can not be found then return RETURN_NOT_FOUND.
766 If the record is found and TimeStamp is not zero,
767 then the end time in the record is filled in with the value specified by TimeStamp.
768 If the record is found and TimeStamp is zero, then the end time in the matching record
769 is filled in with the current time stamp value.
771 @param Handle Pointer to environment specific context used
772 to identify the component being measured.
773 @param Token Pointer to a Null-terminated ASCII string
774 that identifies the component being measured.
775 @param Module Pointer to a Null-terminated ASCII string
776 that identifies the module being measured.
777 @param TimeStamp 64-bit time stamp.
779 @retval RETURN_SUCCESS The end of the measurement was recorded.
780 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
785 EndPerformanceMeasurement (
786 IN CONST VOID
*Handle
, OPTIONAL
787 IN CONST CHAR8
*Token
, OPTIONAL
788 IN CONST CHAR8
*Module
, OPTIONAL
792 return EndPerformanceMeasurementEx (Handle
, Token
, Module
, TimeStamp
, 0);
796 Attempts to retrieve a performance measurement log entry from the performance measurement log.
797 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
798 and then eliminate the Identifier.
800 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
801 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
802 and the key for the second entry in the log is returned. If the performance log is empty,
803 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
804 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
805 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
806 retrieved and an implementation specific non-zero key value that specifies the end of the performance
807 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
808 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
809 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
810 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
811 If Handle is NULL, then ASSERT().
812 If Token is NULL, then ASSERT().
813 If Module is NULL, then ASSERT().
814 If StartTimeStamp is NULL, then ASSERT().
815 If EndTimeStamp is NULL, then ASSERT().
817 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
818 0, then the first performance measurement log entry is retrieved.
819 On exit, the key of the next performance log entry.
820 @param Handle Pointer to environment specific context used to identify the component
822 @param Token Pointer to a Null-terminated ASCII string that identifies the component
824 @param Module Pointer to a Null-terminated ASCII string that identifies the module
826 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
828 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
831 @return The key for the next performance log entry (in general case).
836 GetPerformanceMeasurement (
837 IN UINTN LogEntryKey
,
838 OUT CONST VOID
**Handle
,
839 OUT CONST CHAR8
**Token
,
840 OUT CONST CHAR8
**Module
,
841 OUT UINT64
*StartTimeStamp
,
842 OUT UINT64
*EndTimeStamp
846 return GetPerformanceMeasurementEx (LogEntryKey
, Handle
, Token
, Module
, StartTimeStamp
, EndTimeStamp
, &Identifier
);
850 Returns TRUE if the performance measurement macros are enabled.
852 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
853 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
855 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
856 PcdPerformanceLibraryPropertyMask is set.
857 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
858 PcdPerformanceLibraryPropertyMask is clear.
863 PerformanceMeasurementEnabled (
867 return (BOOLEAN
) ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0);