]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
MdeModulePkg: Update PerformanceLib instances not to check Identifier.
[mirror_edk2.git] / MdeModulePkg / Library / PeiPerformanceLib / PeiPerformanceLib.c
CommitLineData
8dbae30d 1/** @file\r
857dfc45 2 Performance library instance used in PEI phase.\r
3\r
4 This file implements all APIs in Performance Library class in MdePkg. It creates\r
5 performance logging GUIDed HOB on the first performance logging and then logs the\r
6 performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum\r
7c50b343
CS
7 number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or \r
8 PcdMaxPeiPerformanceLogEntries16.\r
a0afd019 9\r
7a9395cd 10Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
7c50b343 11(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
cd5ebaa0 12This program and the accompanying materials\r
a0afd019 13are licensed and made available under the terms and conditions of the BSD License\r
14which accompanies this distribution. The full text of the license may be found at\r
15http://opensource.org/licenses/bsd-license.php\r
16\r
17THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
18WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
19\r
8dbae30d 20**/\r
a0afd019 21\r
ed7748fe 22\r
a0afd019 23#include <PiPei.h>\r
ed7748fe 24\r
ee0961f7 25#include <Guid/Performance.h>\r
ed7748fe 26\r
a0afd019 27#include <Library/PerformanceLib.h>\r
28#include <Library/DebugLib.h>\r
29#include <Library/HobLib.h>\r
30#include <Library/BaseLib.h>\r
31#include <Library/TimerLib.h>\r
32#include <Library/PcdLib.h>\r
33#include <Library/BaseMemoryLib.h>\r
34\r
35\r
36/**\r
f0da4d7d 37 Gets the GUID HOB for PEI performance.\r
a0afd019 38\r
39 This internal function searches for the GUID HOB for PEI performance.\r
40 If that GUID HOB is not found, it will build a new one.\r
f0da4d7d 41 It outputs the data area of that GUID HOB to record performance log.\r
a0afd019 42\r
f0da4d7d
SZ
43 @param PeiPerformanceLog Pointer to Pointer to PEI performance log header.\r
44 @param PeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array.\r
a0afd019 45\r
46**/\r
f0da4d7d 47VOID\r
a0afd019 48InternalGetPerformanceHobLog (\r
f0da4d7d
SZ
49 OUT PEI_PERFORMANCE_LOG_HEADER **PeiPerformanceLog,\r
50 OUT UINT32 **PeiPerformanceIdArray\r
a0afd019 51 )\r
52{\r
53 EFI_HOB_GUID_TYPE *GuidHob;\r
f0da4d7d 54 UINTN PeiPerformanceSize;\r
7c50b343 55 UINT16 PeiPerformanceLogEntries;\r
f0da4d7d
SZ
56\r
57 ASSERT (PeiPerformanceLog != NULL);\r
58 ASSERT (PeiPerformanceIdArray != NULL);\r
a0afd019 59\r
7c50b343
CS
60 PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?\r
61 PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :\r
62 PcdGet8 (PcdMaxPeiPerformanceLogEntries));\r
ee0961f7 63 GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid);\r
a0afd019 64\r
65 if (GuidHob != NULL) {\r
66 //\r
67 // PEI Performance HOB was found, then return the existing one.\r
68 //\r
f0da4d7d
SZ
69 *PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob);\r
70\r
71 GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid);\r
72 ASSERT (GuidHob != NULL);\r
73 *PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob);\r
a0afd019 74 } else {\r
75 //\r
76 // PEI Performance HOB was not found, then build one.\r
77 //\r
f0da4d7d 78 PeiPerformanceSize = sizeof (PEI_PERFORMANCE_LOG_HEADER) +\r
7c50b343 79 sizeof (PEI_PERFORMANCE_LOG_ENTRY) * PeiPerformanceLogEntries;\r
f0da4d7d
SZ
80 *PeiPerformanceLog = BuildGuidHob (&gPerformanceProtocolGuid, PeiPerformanceSize);\r
81 *PeiPerformanceLog = ZeroMem (*PeiPerformanceLog, PeiPerformanceSize);\r
82\r
7c50b343 83 PeiPerformanceSize = sizeof (UINT32) * PeiPerformanceLogEntries;\r
f0da4d7d
SZ
84 *PeiPerformanceIdArray = BuildGuidHob (&gPerformanceExProtocolGuid, PeiPerformanceSize);\r
85 *PeiPerformanceIdArray = ZeroMem (*PeiPerformanceIdArray, PeiPerformanceSize);\r
a0afd019 86 }\r
a0afd019 87}\r
88\r
89/**\r
f0da4d7d 90 Searches in the log array with keyword Handle, Token, Module and Identifier.\r
a0afd019 91\r
92 This internal function searches for the log entry in the log array.\r
f0da4d7d 93 If there is an entry that exactly matches the given keywords\r
a0afd019 94 and its end time stamp is zero, then the index of that log entry is returned;\r
95 otherwise, the the number of log entries in the array is returned.\r
96\r
74935bd7 97 @param PeiPerformanceLog Pointer to the data structure containing PEI \r
98 performance data.\r
843833f9 99 @param PeiPerformanceIdArray Pointer to PEI performance identifier array.\r
a0afd019 100 @param Handle Pointer to environment specific context used\r
101 to identify the component being measured.\r
102 @param Token Pointer to a Null-terminated ASCII string\r
103 that identifies the component being measured.\r
104 @param Module Pointer to a Null-terminated ASCII string\r
105 that identifies the module being measured.\r
f0da4d7d 106 @param Identifier 32-bit identifier.\r
a0afd019 107\r
108 @retval The index of log entry in the array.\r
109\r
110**/\r
a0afd019 111UINT32\r
112InternalSearchForLogEntry (\r
113 IN PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog,\r
f0da4d7d 114 IN UINT32 *PeiPerformanceIdArray,\r
a0afd019 115 IN CONST VOID *Handle, OPTIONAL\r
116 IN CONST CHAR8 *Token, OPTIONAL\r
f0da4d7d
SZ
117 IN CONST CHAR8 *Module, OPTIONAL\r
118 IN UINT32 Identifier\r
a0afd019 119 )\r
120{\r
121 UINT32 Index;\r
b504f519 122 UINT32 Index2;\r
a0afd019 123 UINT32 NumberOfEntries;\r
124 PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
125\r
126\r
127 if (Token == NULL) {\r
128 Token = "";\r
129 }\r
130 if (Module == NULL) {\r
131 Module = "";\r
132 }\r
133 NumberOfEntries = PeiPerformanceLog->NumberOfEntries;\r
134 LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
135\r
b504f519
SZ
136 Index2 = 0;\r
137\r
a0afd019 138 for (Index = 0; Index < NumberOfEntries; Index++) {\r
b504f519
SZ
139 Index2 = NumberOfEntries - 1 - Index;\r
140 if (LogEntryArray[Index2].EndTimeStamp == 0 &&\r
141 (LogEntryArray[Index2].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
142 AsciiStrnCmp (LogEntryArray[Index2].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
7a9395cd 143 AsciiStrnCmp (LogEntryArray[Index2].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0) {\r
b504f519 144 Index = Index2;\r
a0afd019 145 break;\r
146 }\r
147 }\r
148 return Index;\r
149}\r
150\r
151/**\r
152 Creates a record for the beginning of a performance measurement.\r
153\r
f0da4d7d 154 Creates a record that contains the Handle, Token, Module and Identifier.\r
a0afd019 155 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
156 If TimeStamp is zero, then this function reads the current time stamp\r
157 and adds that time stamp value to the record as the start time.\r
158\r
159 @param Handle Pointer to environment specific context used\r
160 to identify the component being measured.\r
161 @param Token Pointer to a Null-terminated ASCII string\r
162 that identifies the component being measured.\r
163 @param Module Pointer to a Null-terminated ASCII string\r
164 that identifies the module being measured.\r
165 @param TimeStamp 64-bit time stamp.\r
f0da4d7d
SZ
166 @param Identifier 32-bit identifier. If the value is 0, the created record\r
167 is same as the one created by StartPerformanceMeasurement.\r
a0afd019 168\r
169 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
170 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
171\r
172**/\r
173RETURN_STATUS\r
174EFIAPI\r
f0da4d7d 175StartPerformanceMeasurementEx (\r
a0afd019 176 IN CONST VOID *Handle, OPTIONAL\r
177 IN CONST CHAR8 *Token, OPTIONAL\r
178 IN CONST CHAR8 *Module, OPTIONAL\r
f0da4d7d
SZ
179 IN UINT64 TimeStamp,\r
180 IN UINT32 Identifier\r
a0afd019 181 )\r
182{\r
183 PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;\r
f0da4d7d 184 UINT32 *PeiPerformanceIdArray;\r
a0afd019 185 PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
186 UINT32 Index;\r
7c50b343
CS
187 UINT16 PeiPerformanceLogEntries;\r
188\r
189 PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?\r
190 PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :\r
191 PcdGet8 (PcdMaxPeiPerformanceLogEntries));\r
a0afd019 192\r
f0da4d7d 193 InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);\r
a0afd019 194\r
7c50b343 195 if (PeiPerformanceLog->NumberOfEntries >= PeiPerformanceLogEntries) {\r
32c8c88d 196 DEBUG ((DEBUG_ERROR, "PEI performance log array out of resources\n"));\r
a0afd019 197 return RETURN_OUT_OF_RESOURCES;\r
198 }\r
199 Index = PeiPerformanceLog->NumberOfEntries++;\r
200 LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
201 LogEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
202\r
203 if (Token != NULL) {\r
8feb7452 204 AsciiStrnCpyS (LogEntryArray[Index].Token, PEI_PERFORMANCE_STRING_SIZE, Token, PEI_PERFORMANCE_STRING_LENGTH);\r
a0afd019 205 }\r
206 if (Module != NULL) {\r
8feb7452 207 AsciiStrnCpyS (LogEntryArray[Index].Module, PEI_PERFORMANCE_STRING_SIZE, Module, PEI_PERFORMANCE_STRING_LENGTH);\r
a0afd019 208 }\r
209\r
f0da4d7d
SZ
210 LogEntryArray[Index].EndTimeStamp = 0;\r
211 PeiPerformanceIdArray[Index] = Identifier;\r
212\r
a0afd019 213 if (TimeStamp == 0) {\r
214 TimeStamp = GetPerformanceCounter ();\r
215 }\r
216 LogEntryArray[Index].StartTimeStamp = TimeStamp;\r
217\r
218 return RETURN_SUCCESS;\r
219}\r
220\r
221/**\r
222 Fills in the end time of a performance measurement.\r
223\r
7a9395cd 224 Looks up the record that matches Handle, Token and Module.\r
a0afd019 225 If the record can not be found then return RETURN_NOT_FOUND.\r
226 If the record is found and TimeStamp is not zero,\r
227 then TimeStamp is added to the record as the end time.\r
228 If the record is found and TimeStamp is zero, then this function reads\r
229 the current time stamp and adds that time stamp value to the record as the end time.\r
a0afd019 230\r
231 @param Handle Pointer to environment specific context used\r
232 to identify the component being measured.\r
233 @param Token Pointer to a Null-terminated ASCII string\r
234 that identifies the component being measured.\r
235 @param Module Pointer to a Null-terminated ASCII string\r
236 that identifies the module being measured.\r
237 @param TimeStamp 64-bit time stamp.\r
f0da4d7d
SZ
238 @param Identifier 32-bit identifier. If the value is 0, the found record\r
239 is same as the one found by EndPerformanceMeasurement.\r
a0afd019 240\r
241 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
242 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
243\r
244**/\r
245RETURN_STATUS\r
246EFIAPI\r
f0da4d7d 247EndPerformanceMeasurementEx (\r
a0afd019 248 IN CONST VOID *Handle, OPTIONAL\r
249 IN CONST CHAR8 *Token, OPTIONAL\r
250 IN CONST CHAR8 *Module, OPTIONAL\r
f0da4d7d
SZ
251 IN UINT64 TimeStamp,\r
252 IN UINT32 Identifier\r
a0afd019 253 )\r
254{\r
255 PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;\r
f0da4d7d 256 UINT32 *PeiPerformanceIdArray;\r
a0afd019 257 PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
258 UINT32 Index;\r
259\r
260 if (TimeStamp == 0) {\r
261 TimeStamp = GetPerformanceCounter ();\r
262 }\r
263\r
f0da4d7d
SZ
264 InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);\r
265 Index = InternalSearchForLogEntry (PeiPerformanceLog, PeiPerformanceIdArray, Handle, Token, Module, Identifier);\r
a0afd019 266 if (Index >= PeiPerformanceLog->NumberOfEntries) {\r
267 return RETURN_NOT_FOUND;\r
268 }\r
269 LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
270 LogEntryArray[Index].EndTimeStamp = TimeStamp;\r
271\r
272 return RETURN_SUCCESS;\r
273}\r
274\r
275/**\r
276 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
f0da4d7d
SZ
277 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r
278 and then assign the Identifier with 0.\r
a0afd019 279\r
280 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
281 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
282 and the key for the second entry in the log is returned. If the performance log is empty,\r
283 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
284 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
285 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
286 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
287 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
288 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
f0da4d7d 289 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r
a0afd019 290 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
291 If Handle is NULL, then ASSERT().\r
292 If Token is NULL, then ASSERT().\r
293 If Module is NULL, then ASSERT().\r
294 If StartTimeStamp is NULL, then ASSERT().\r
295 If EndTimeStamp is NULL, then ASSERT().\r
f0da4d7d 296 If Identifier is NULL, then ASSERT().\r
a0afd019 297\r
298 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
299 0, then the first performance measurement log entry is retrieved.\r
f0da4d7d 300 On exit, the key of the next performance of entry entry.\r
a0afd019 301 @param Handle Pointer to environment specific context used to identify the component\r
302 being measured.\r
303 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
304 being measured.\r
305 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
306 being measured.\r
307 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
308 was started.\r
309 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
310 was ended.\r
f0da4d7d 311 @param Identifier Pointer to the 32-bit identifier that was recorded.\r
a0afd019 312\r
313 @return The key for the next performance log entry (in general case).\r
314\r
315**/\r
316UINTN\r
317EFIAPI\r
f0da4d7d 318GetPerformanceMeasurementEx (\r
a0afd019 319 IN UINTN LogEntryKey,\r
320 OUT CONST VOID **Handle,\r
321 OUT CONST CHAR8 **Token,\r
322 OUT CONST CHAR8 **Module,\r
323 OUT UINT64 *StartTimeStamp,\r
f0da4d7d
SZ
324 OUT UINT64 *EndTimeStamp,\r
325 OUT UINT32 *Identifier\r
a0afd019 326 )\r
327{\r
328 PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;\r
f0da4d7d 329 UINT32 *PeiPerformanceIdArray;\r
a0afd019 330 PEI_PERFORMANCE_LOG_ENTRY *CurrentLogEntry;\r
331 PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
332 UINTN NumberOfEntries;\r
333\r
334 ASSERT (Handle != NULL);\r
335 ASSERT (Token != NULL);\r
336 ASSERT (Module != NULL);\r
337 ASSERT (StartTimeStamp != NULL);\r
338 ASSERT (EndTimeStamp != NULL);\r
f0da4d7d 339 ASSERT (Identifier != NULL);\r
a0afd019 340\r
f0da4d7d 341 InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);\r
a0afd019 342\r
343 NumberOfEntries = (UINTN) (PeiPerformanceLog->NumberOfEntries);\r
344 LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
345 //\r
346 // Make sure that LogEntryKey is a valid log entry key.\r
347 //\r
348 ASSERT (LogEntryKey <= NumberOfEntries);\r
349\r
350 if (LogEntryKey == NumberOfEntries) {\r
351 return 0;\r
352 }\r
353\r
f0da4d7d 354 CurrentLogEntry = &(LogEntryArray[LogEntryKey]);\r
a0afd019 355\r
356 *Handle = (VOID *) (UINTN) (CurrentLogEntry->Handle);\r
357 *Token = CurrentLogEntry->Token;\r
358 *Module = CurrentLogEntry->Module;\r
359 *StartTimeStamp = CurrentLogEntry->StartTimeStamp;\r
360 *EndTimeStamp = CurrentLogEntry->EndTimeStamp;\r
f0da4d7d 361 *Identifier = PeiPerformanceIdArray[LogEntryKey++];\r
a0afd019 362\r
363 return LogEntryKey;\r
364}\r
365\r
f0da4d7d
SZ
366/**\r
367 Creates a record for the beginning of a performance measurement.\r
368\r
369 Creates a record that contains the Handle, Token, and Module.\r
370 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
371 If TimeStamp is zero, then this function reads the current time stamp\r
372 and adds that time stamp value to the record as the start time.\r
373\r
374 @param Handle Pointer to environment specific context used\r
375 to identify the component being measured.\r
376 @param Token Pointer to a Null-terminated ASCII string\r
377 that identifies the component being measured.\r
378 @param Module Pointer to a Null-terminated ASCII string\r
379 that identifies the module being measured.\r
380 @param TimeStamp 64-bit time stamp.\r
381\r
382 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
383 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
384\r
385**/\r
386RETURN_STATUS\r
387EFIAPI\r
388StartPerformanceMeasurement (\r
389 IN CONST VOID *Handle, OPTIONAL\r
390 IN CONST CHAR8 *Token, OPTIONAL\r
391 IN CONST CHAR8 *Module, OPTIONAL\r
392 IN UINT64 TimeStamp\r
393 )\r
394{\r
395 return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r
396}\r
397\r
398/**\r
399 Fills in the end time of a performance measurement.\r
400\r
401 Looks up the record that matches Handle, Token, and Module.\r
402 If the record can not be found then return RETURN_NOT_FOUND.\r
403 If the record is found and TimeStamp is not zero,\r
404 then TimeStamp is added to the record as the end time.\r
405 If the record is found and TimeStamp is zero, then this function reads\r
406 the current time stamp and adds that time stamp value to the record as the end time.\r
407\r
408 @param Handle Pointer to environment specific context used\r
409 to identify the component being measured.\r
410 @param Token Pointer to a Null-terminated ASCII string\r
411 that identifies the component being measured.\r
412 @param Module Pointer to a Null-terminated ASCII string\r
413 that identifies the module being measured.\r
414 @param TimeStamp 64-bit time stamp.\r
415\r
416 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
417 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
418\r
419**/\r
420RETURN_STATUS\r
421EFIAPI\r
422EndPerformanceMeasurement (\r
423 IN CONST VOID *Handle, OPTIONAL\r
424 IN CONST CHAR8 *Token, OPTIONAL\r
425 IN CONST CHAR8 *Module, OPTIONAL\r
426 IN UINT64 TimeStamp\r
427 )\r
428{\r
429 return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r
430}\r
431\r
432/**\r
433 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
434 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r
435 and then eliminate the Identifier.\r
436\r
437 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
438 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
439 and the key for the second entry in the log is returned. If the performance log is empty,\r
440 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
441 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
442 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
443 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
444 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
445 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
446 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
447 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
448 If Handle is NULL, then ASSERT().\r
449 If Token is NULL, then ASSERT().\r
450 If Module is NULL, then ASSERT().\r
451 If StartTimeStamp is NULL, then ASSERT().\r
452 If EndTimeStamp is NULL, then ASSERT().\r
453\r
454 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
455 0, then the first performance measurement log entry is retrieved.\r
456 On exit, the key of the next performance of entry entry.\r
457 @param Handle Pointer to environment specific context used to identify the component\r
458 being measured.\r
459 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
460 being measured.\r
461 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
462 being measured.\r
463 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
464 was started.\r
465 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
466 was ended.\r
467\r
468 @return The key for the next performance log entry (in general case).\r
469\r
470**/\r
471UINTN\r
472EFIAPI\r
473GetPerformanceMeasurement (\r
474 IN UINTN LogEntryKey,\r
475 OUT CONST VOID **Handle,\r
476 OUT CONST CHAR8 **Token,\r
477 OUT CONST CHAR8 **Module,\r
478 OUT UINT64 *StartTimeStamp,\r
479 OUT UINT64 *EndTimeStamp\r
480 )\r
481{\r
482 UINT32 Identifier;\r
483 return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);\r
484}\r
485\r
a0afd019 486/**\r
487 Returns TRUE if the performance measurement macros are enabled.\r
488\r
489 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
490 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r
491\r
492 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
493 PcdPerformanceLibraryPropertyMask is set.\r
494 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
495 PcdPerformanceLibraryPropertyMask is clear.\r
496\r
497**/\r
498BOOLEAN\r
499EFIAPI\r
500PerformanceMeasurementEnabled (\r
501 VOID\r
502 )\r
503{\r
504 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
505}\r