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