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