Import DxeCorePerformanceLib DxePerformanceLib PeiPerformanceLib and EdkDxePrintLib
[mirror_edk2.git] / MdeModulePkg / Library / DxeCorePerformanceLib / DxeCorePerformanceLib.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DxeCorePerformance.c
15
16 Abstract:
17
18 Support for measurement of DXE performance
19
20 --*/
21
22 //
23 // The package level header files this module uses
24 //
25 #include <PiDxe.h>
26 //
27 // The protocols, PPI and GUID defintions for this module
28 //
29 #include <Protocol/Performance.h>
30 #include <Guid/PeiPerformanceHob.h>
31 //
32 // The Library classes this module consumes
33 //
34 #include <Library/PerformanceLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/HobLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/TimerLib.h>
40 #include <Library/PcdLib.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/MemoryAllocationLib.h>
43
44 //
45 // Interface declarations for Performance Protocol.
46 //
47 /**
48 Adds a record at the end of the performance measurement log
49 that records the start time of a performance measurement.
50
51 Adds a record to the end of the performance measurement log
52 that contains the Handle, Token, and Module.
53 The end time of the new record must be set to zero.
54 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
55 If TimeStamp is zero, the start time in the record is filled in with the value
56 read from the current time stamp.
57
58 @param Handle Pointer to environment specific context used
59 to identify the component being measured.
60 @param Token Pointer to a Null-terminated ASCII string
61 that identifies the component being measured.
62 @param Module Pointer to a Null-terminated ASCII string
63 that identifies the module being measured.
64 @param TimeStamp 64-bit time stamp.
65
66 @retval EFI_SUCCESS The data was read correctly from the device.
67 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
68
69 **/
70 STATIC
71 EFI_STATUS
72 EFIAPI
73 StartGauge (
74 IN CONST VOID *Handle, OPTIONAL
75 IN CONST CHAR8 *Token, OPTIONAL
76 IN CONST CHAR8 *Module, OPTIONAL
77 IN UINT64 TimeStamp
78 );
79
80 /**
81 Searches the performance measurement log from the beginning of the log
82 for the first matching record that contains a zero end time and fills in a valid end time.
83
84 Searches the performance measurement log from the beginning of the log
85 for the first record that matches Handle, Token, and Module and has an end time value of zero.
86 If the record can not be found then return EFI_NOT_FOUND.
87 If the record is found and TimeStamp is not zero,
88 then the end time in the record is filled in with the value specified by TimeStamp.
89 If the record is found and TimeStamp is zero, then the end time in the matching record
90 is filled in with the current time stamp value.
91
92 @param Handle Pointer to environment specific context used
93 to identify the component being measured.
94 @param Token Pointer to a Null-terminated ASCII string
95 that identifies the component being measured.
96 @param Module Pointer to a Null-terminated ASCII string
97 that identifies the module being measured.
98 @param TimeStamp 64-bit time stamp.
99
100 @retval EFI_SUCCESS The end of the measurement was recorded.
101 @retval EFI_NOT_FOUND The specified measurement record could not be found.
102
103 **/
104 STATIC
105 EFI_STATUS
106 EFIAPI
107 EndGauge (
108 IN CONST VOID *Handle, OPTIONAL
109 IN CONST CHAR8 *Token, OPTIONAL
110 IN CONST CHAR8 *Module, OPTIONAL
111 IN UINT64 TimeStamp
112 );
113
114 /**
115 Retrieves a previously logged performance measurement.
116
117 Retrieves the performance log entry from the performance log specified by LogEntryKey.
118 If it stands for a valid entry, then EFI_SUCCESS is returned and
119 GaugeDataEntry stores the pointer to that entry.
120
121 @param LogEntryKey The key for the previous performance measurement log entry.
122 If 0, then the first performance measurement log entry is retrieved.
123 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
124 if the retrieval is successful.
125
126 @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey.
127 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
128 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
129 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
130
131 **/
132 STATIC
133 EFI_STATUS
134 EFIAPI
135 GetGauge (
136 IN UINTN LogEntryKey,
137 OUT GAUGE_DATA_ENTRY **GaugeDataEntry
138 );
139
140 //
141 // Definition for global variables.
142 //
143 STATIC GAUGE_DATA_HEADER *mGaugeData;
144 STATIC UINT32 mMaxGaugeRecords;
145
146 EFI_HANDLE mHandle = NULL;
147 PERFORMANCE_PROTOCOL mPerformanceInterface = {
148 StartGauge,
149 EndGauge,
150 GetGauge
151 };
152
153
154 /**
155 Searches in the gauge array with keyword Handle, Token and Module.
156
157 This internal function searches for the gauge entry in the gauge array.
158 If there is an entry that exactly matches the given key word triple
159 and its end time stamp is zero, then the index of that gauge entry is returned;
160 otherwise, the the number of gauge entries in the array is returned.
161
162 @param Handle Pointer to environment specific context used
163 to identify the component being measured.
164 @param Token Pointer to a Null-terminated ASCII string
165 that identifies the component being measured.
166 @param Module Pointer to a Null-terminated ASCII string
167 that identifies the module being measured.
168
169 @retval The index of gauge entry in the array.
170
171 **/
172 STATIC
173 UINT32
174 InternalSearchForGaugeEntry (
175 IN CONST VOID *Handle, OPTIONAL
176 IN CONST CHAR8 *Token, OPTIONAL
177 IN CONST CHAR8 *Module OPTIONAL
178 )
179 {
180 UINT32 Index;
181 UINT32 NumberOfEntries;
182 GAUGE_DATA_ENTRY *GaugeEntryArray;
183
184 if (Token == NULL) {
185 Token = "";
186 }
187 if (Module == NULL) {
188 Module = "";
189 }
190
191 NumberOfEntries = mGaugeData->NumberOfEntries;
192 GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
193
194 for (Index = 0; Index < NumberOfEntries; Index++) {
195 if ((GaugeEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
196 AsciiStrnCmp (GaugeEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
197 AsciiStrnCmp (GaugeEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
198 GaugeEntryArray[Index].EndTimeStamp == 0
199 ) {
200 break;
201 }
202 }
203
204 return Index;
205 }
206
207 /**
208 Adds a record at the end of the performance measurement log
209 that records the start time of a performance measurement.
210
211 Adds a record to the end of the performance measurement log
212 that contains the Handle, Token, and Module.
213 The end time of the new record must be set to zero.
214 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
215 If TimeStamp is zero, the start time in the record is filled in with the value
216 read from the current time stamp.
217
218 @param Handle Pointer to environment specific context used
219 to identify the component being measured.
220 @param Token Pointer to a Null-terminated ASCII string
221 that identifies the component being measured.
222 @param Module Pointer to a Null-terminated ASCII string
223 that identifies the module being measured.
224 @param TimeStamp 64-bit time stamp.
225
226 @retval EFI_SUCCESS The data was read correctly from the device.
227 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
228
229 **/
230 STATIC
231 EFI_STATUS
232 EFIAPI
233 StartGauge (
234 IN CONST VOID *Handle, OPTIONAL
235 IN CONST CHAR8 *Token, OPTIONAL
236 IN CONST CHAR8 *Module, OPTIONAL
237 IN UINT64 TimeStamp
238 )
239 {
240 GAUGE_DATA_ENTRY *GaugeEntryArray;
241 UINTN GaugeDataSize;
242 UINTN OldGaugeDataSize;
243 GAUGE_DATA_HEADER *OldGaugeData;
244 UINT32 Index;
245
246 Index = mGaugeData->NumberOfEntries;
247 if (Index >= mMaxGaugeRecords) {
248 //
249 // Try to enlarge the scale of gauge arrary.
250 //
251 OldGaugeData = mGaugeData;
252 OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
253
254 mMaxGaugeRecords *= 2;
255 GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
256
257 mGaugeData = AllocateZeroPool (GaugeDataSize);
258 if (mGaugeData == NULL) {
259 return EFI_OUT_OF_RESOURCES;
260 }
261 //
262 // Initialize new data arry and migrate old data one.
263 //
264 mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);
265
266 FreePool (OldGaugeData);
267 }
268
269 GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
270 GaugeEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
271
272 if (Token != NULL) {
273 AsciiStrnCpy (GaugeEntryArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);
274 }
275 if (Module != NULL) {
276 AsciiStrnCpy (GaugeEntryArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);
277 }
278
279 if (TimeStamp == 0) {
280 TimeStamp = GetPerformanceCounter ();
281 }
282 GaugeEntryArray[Index].StartTimeStamp = TimeStamp;
283
284 mGaugeData->NumberOfEntries++;
285
286 return EFI_SUCCESS;
287 }
288
289 /**
290 Searches the performance measurement log from the beginning of the log
291 for the first matching record that contains a zero end time and fills in a valid end time.
292
293 Searches the performance measurement log from the beginning of the log
294 for the first record that matches Handle, Token, and Module and has an end time value of zero.
295 If the record can not be found then return EFI_NOT_FOUND.
296 If the record is found and TimeStamp is not zero,
297 then the end time in the record is filled in with the value specified by TimeStamp.
298 If the record is found and TimeStamp is zero, then the end time in the matching record
299 is filled in with the current time stamp value.
300
301 @param Handle Pointer to environment specific context used
302 to identify the component being measured.
303 @param Token Pointer to a Null-terminated ASCII string
304 that identifies the component being measured.
305 @param Module Pointer to a Null-terminated ASCII string
306 that identifies the module being measured.
307 @param TimeStamp 64-bit time stamp.
308
309 @retval EFI_SUCCESS The end of the measurement was recorded.
310 @retval EFI_NOT_FOUND The specified measurement record could not be found.
311
312 **/
313 STATIC
314 EFI_STATUS
315 EFIAPI
316 EndGauge (
317 IN CONST VOID *Handle, OPTIONAL
318 IN CONST CHAR8 *Token, OPTIONAL
319 IN CONST CHAR8 *Module, OPTIONAL
320 IN UINT64 TimeStamp
321 )
322 {
323 GAUGE_DATA_ENTRY *GaugeEntryArray;
324 UINT32 Index;
325
326 if (TimeStamp == 0) {
327 TimeStamp = GetPerformanceCounter ();
328 }
329
330 Index = InternalSearchForGaugeEntry (Handle, Token, Module);
331 if (Index >= mGaugeData->NumberOfEntries) {
332 return EFI_NOT_FOUND;
333 }
334 GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
335 GaugeEntryArray[Index].EndTimeStamp = TimeStamp;
336
337 return EFI_SUCCESS;
338 }
339
340 /**
341 Retrieves a previously logged performance measurement.
342
343 Retrieves the performance log entry from the performance log specified by LogEntryKey.
344 If it stands for a valid entry, then EFI_SUCCESS is returned and
345 GaugeDataEntry stores the pointer to that entry.
346
347 @param LogEntryKey The key for the previous performance measurement log entry.
348 If 0, then the first performance measurement log entry is retrieved.
349 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
350 if the retrieval is successful.
351
352 @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey.
353 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
354 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
355 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
356
357 **/
358 STATIC
359 EFI_STATUS
360 EFIAPI
361 GetGauge (
362 IN UINTN LogEntryKey,
363 OUT GAUGE_DATA_ENTRY **GaugeDataEntry
364 )
365 {
366 UINTN NumberOfEntries;
367 GAUGE_DATA_ENTRY *LogEntryArray;
368
369 NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);
370 if (LogEntryKey > NumberOfEntries) {
371 return EFI_INVALID_PARAMETER;
372 }
373 if (LogEntryKey == NumberOfEntries) {
374 return EFI_NOT_FOUND;
375 }
376
377 LogEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
378
379 if (GaugeDataEntry == NULL) {
380 return EFI_INVALID_PARAMETER;
381 }
382 *GaugeDataEntry = &LogEntryArray[LogEntryKey];
383
384 return EFI_SUCCESS;
385 }
386
387 /**
388 Dumps all the PEI performance log to DXE performance gauge array.
389
390 This internal function dumps all the PEI performance log to the DXE performance gauge array.
391 It retrieves the optional GUID HOB for PEI performance and then saves the performance data
392 to DXE performance data structures.
393
394 **/
395 STATIC
396 VOID
397 InternalGetPeiPerformance (
398 VOID
399 )
400 {
401 EFI_HOB_GUID_TYPE *GuidHob;
402 PEI_PERFORMANCE_LOG_HEADER *LogHob;
403 PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
404 GAUGE_DATA_ENTRY *GaugeEntryArray;
405 UINT32 Index;
406 UINT32 NumberOfEntries;
407
408 NumberOfEntries = 0;
409 GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
410
411 //
412 // Dump PEI Log Entries to DXE Guage Data structure.
413 //
414 GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);
415 if (GuidHob != NULL) {
416 LogHob = GET_GUID_HOB_DATA (GuidHob);
417 LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (LogHob + 1);
418 GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
419
420 NumberOfEntries = LogHob->NumberOfEntries;
421 for (Index = 0; Index < NumberOfEntries; Index++) {
422 GaugeEntryArray[Index].Handle = LogEntryArray[Index].Handle;
423 AsciiStrnCpy (GaugeEntryArray[Index].Token, LogEntryArray[Index].Token, DXE_PERFORMANCE_STRING_LENGTH);
424 AsciiStrnCpy (GaugeEntryArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);
425 GaugeEntryArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;
426 GaugeEntryArray[Index].EndTimeStamp = LogEntryArray[Index].EndTimeStamp;
427 }
428 }
429 mGaugeData->NumberOfEntries = NumberOfEntries;
430 }
431
432 /**
433 The constructor function initializes Performance infrastructure for DXE phase.
434
435 The constructor function publishes Performance protocol, allocates memory to log DXE performance
436 and merges PEI performance data to DXE performance log.
437 It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
438
439 @param ImageHandle The firmware allocated handle for the EFI image.
440 @param SystemTable A pointer to the EFI System Table.
441
442 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
443
444 **/
445 EFI_STATUS
446 EFIAPI
447 DxeCorePerformanceLibConstructor (
448 IN EFI_HANDLE ImageHandle,
449 IN EFI_SYSTEM_TABLE *SystemTable
450 )
451 {
452 EFI_STATUS Status;
453
454 if (!PerformanceMeasurementEnabled ()) {
455 //
456 // Do not initialize performance infrastructure if not required.
457 //
458 return EFI_SUCCESS;
459 }
460 //
461 // Install the protocol interfaces.
462 //
463 Status = gBS->InstallProtocolInterface (
464 &mHandle,
465 &gPerformanceProtocolGuid,
466 EFI_NATIVE_INTERFACE,
467 &mPerformanceInterface
468 );
469 ASSERT_EFI_ERROR (Status);
470
471 mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + PcdGet8 (PcdMaxPeiPerformanceLogEntries);
472
473 mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords));
474 ASSERT (mGaugeData != NULL);
475
476 InternalGetPeiPerformance ();
477
478 return Status;
479 }
480
481 /**
482 Adds a record at the end of the performance measurement log
483 that records the start time of a performance measurement.
484
485 Adds a record to the end of the performance measurement log
486 that contains the Handle, Token, and Module.
487 The end time of the new record must be set to zero.
488 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
489 If TimeStamp is zero, the start time in the record is filled in with the value
490 read from the current time stamp.
491
492 @param Handle Pointer to environment specific context used
493 to identify the component being measured.
494 @param Token Pointer to a Null-terminated ASCII string
495 that identifies the component being measured.
496 @param Module Pointer to a Null-terminated ASCII string
497 that identifies the module being measured.
498 @param TimeStamp 64-bit time stamp.
499
500 @retval RETURN_SUCCESS The start of the measurement was recorded.
501 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
502
503 **/
504 RETURN_STATUS
505 EFIAPI
506 StartPerformanceMeasurement (
507 IN CONST VOID *Handle, OPTIONAL
508 IN CONST CHAR8 *Token, OPTIONAL
509 IN CONST CHAR8 *Module, OPTIONAL
510 IN UINT64 TimeStamp
511 )
512 {
513 EFI_STATUS Status;
514
515 Status = StartGauge (Handle, Token, Module, TimeStamp);
516 return (RETURN_STATUS) Status;
517 }
518
519 /**
520 Searches the performance measurement log from the beginning of the log
521 for the first matching record that contains a zero end time and fills in a valid end time.
522
523 Searches the performance measurement log from the beginning of the log
524 for the first record that matches Handle, Token, and Module and has an end time value of zero.
525 If the record can not be found then return RETURN_NOT_FOUND.
526 If the record is found and TimeStamp is not zero,
527 then the end time in the record is filled in with the value specified by TimeStamp.
528 If the record is found and TimeStamp is zero, then the end time in the matching record
529 is filled in with the current time stamp value.
530
531 @param Handle Pointer to environment specific context used
532 to identify the component being measured.
533 @param Token Pointer to a Null-terminated ASCII string
534 that identifies the component being measured.
535 @param Module Pointer to a Null-terminated ASCII string
536 that identifies the module being measured.
537 @param TimeStamp 64-bit time stamp.
538
539 @retval RETURN_SUCCESS The end of the measurement was recorded.
540 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
541
542 **/
543 RETURN_STATUS
544 EFIAPI
545 EndPerformanceMeasurement (
546 IN CONST VOID *Handle, OPTIONAL
547 IN CONST CHAR8 *Token, OPTIONAL
548 IN CONST CHAR8 *Module, OPTIONAL
549 IN UINT64 TimeStamp
550 )
551 {
552 EFI_STATUS Status;
553
554 Status = EndGauge (Handle, Token, Module, TimeStamp);
555 return (RETURN_STATUS) Status;
556 }
557
558 /**
559 Attempts to retrieve a performance measurement log entry from the performance measurement log.
560
561 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
562 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
563 and the key for the second entry in the log is returned. If the performance log is empty,
564 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
565 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
566 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
567 retrieved and an implementation specific non-zero key value that specifies the end of the performance
568 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
569 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
570 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
571 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
572 If Handle is NULL, then ASSERT().
573 If Token is NULL, then ASSERT().
574 If Module is NULL, then ASSERT().
575 If StartTimeStamp is NULL, then ASSERT().
576 If EndTimeStamp is NULL, then ASSERT().
577
578 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
579 0, then the first performance measurement log entry is retrieved.
580 On exit, the key of the next performance lof entry entry.
581 @param Handle Pointer to environment specific context used to identify the component
582 being measured.
583 @param Token Pointer to a Null-terminated ASCII string that identifies the component
584 being measured.
585 @param Module Pointer to a Null-terminated ASCII string that identifies the module
586 being measured.
587 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
588 was started.
589 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
590 was ended.
591
592 @return The key for the next performance log entry (in general case).
593
594 **/
595 UINTN
596 EFIAPI
597 GetPerformanceMeasurement (
598 IN UINTN LogEntryKey,
599 OUT CONST VOID **Handle,
600 OUT CONST CHAR8 **Token,
601 OUT CONST CHAR8 **Module,
602 OUT UINT64 *StartTimeStamp,
603 OUT UINT64 *EndTimeStamp
604 )
605 {
606 EFI_STATUS Status;
607 GAUGE_DATA_ENTRY *GaugeData;
608
609 ASSERT (Handle != NULL);
610 ASSERT (Token != NULL);
611 ASSERT (Module != NULL);
612 ASSERT (StartTimeStamp != NULL);
613 ASSERT (EndTimeStamp != NULL);
614
615 Status = GetGauge (LogEntryKey++, &GaugeData);
616
617 //
618 // Make sure that LogEntryKey is a valid log entry key,
619 //
620 ASSERT (Status != EFI_INVALID_PARAMETER);
621
622 if (EFI_ERROR (Status)) {
623 //
624 // The LogEntryKey is the last entry (equals to the total entry number).
625 //
626 return 0;
627 }
628
629 ASSERT (GaugeData != NULL);
630
631 *Handle = (VOID *) (UINTN) GaugeData->Handle;
632 *Token = GaugeData->Token;
633 *Module = GaugeData->Module;
634 *StartTimeStamp = GaugeData->StartTimeStamp;
635 *EndTimeStamp = GaugeData->EndTimeStamp;
636
637 return LogEntryKey;
638 }
639
640 /**
641 Returns TRUE if the performance measurement macros are enabled.
642
643 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
644 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
645
646 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
647 PcdPerformanceLibraryPropertyMask is set.
648 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
649 PcdPerformanceLibraryPropertyMask is clear.
650
651 **/
652 BOOLEAN
653 EFIAPI
654 PerformanceMeasurementEnabled (
655 VOID
656 )
657 {
658 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
659 }