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