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