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