]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
MdeModulePkg PerformanceLib: Fix GCC build failure caused by cfb0aba
[mirror_edk2.git] / MdeModulePkg / Library / SmmCorePerformanceLib / SmmCorePerformanceLib.c
... / ...
CommitLineData
1/** @file\r
2 Performance library instance used by SMM Core.\r
3\r
4 This library provides the performance measurement interfaces and initializes performance\r
5 logging for the SMM phase.\r
6 It initializes SMM phase performance logging by publishing the SMM Performance and PerformanceEx Protocol,\r
7 which is consumed by SmmPerformanceLib to logging performance data in SMM phase.\r
8\r
9 This library is mainly used by SMM Core to start performance logging to ensure that\r
10 SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.\r
11\r
12 Caution: This module requires additional review when modified.\r
13 This driver will have external input - performance data and communicate buffer in SMM mode.\r
14 This external input must be validated carefully to avoid security issue like\r
15 buffer overflow, integer overflow.\r
16\r
17 SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.\r
18\r
19Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
20This program and the accompanying materials\r
21are licensed and made available under the terms and conditions of the BSD License\r
22which accompanies this distribution. The full text of the license may be found at\r
23http://opensource.org/licenses/bsd-license.php\r
24\r
25THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
26WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
27\r
28**/\r
29\r
30\r
31#include "SmmCorePerformanceLibInternal.h"\r
32\r
33//\r
34// The data structure to hold global performance data.\r
35//\r
36GAUGE_DATA_HEADER *mGaugeData;\r
37\r
38//\r
39// The current maximum number of logging entries. If current number of \r
40// entries exceeds this value, it will re-allocate a larger array and\r
41// migration the old data to the larger array.\r
42//\r
43UINT32 mMaxGaugeRecords;\r
44\r
45//\r
46// The handle to install Performance Protocol instance.\r
47//\r
48EFI_HANDLE mHandle = NULL;\r
49\r
50BOOLEAN mPerformanceMeasurementEnabled;\r
51\r
52SPIN_LOCK mSmmPerfLock;\r
53\r
54//\r
55// Interfaces for SMM Performance Protocol.\r
56//\r
57PERFORMANCE_PROTOCOL mPerformanceInterface = {\r
58 StartGauge,\r
59 EndGauge,\r
60 GetGauge\r
61};\r
62\r
63//\r
64// Interfaces for SMM PerformanceEx Protocol.\r
65//\r
66PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {\r
67 StartGaugeEx,\r
68 EndGaugeEx,\r
69 GetGaugeEx\r
70};\r
71\r
72PERFORMANCE_PROPERTY mPerformanceProperty;\r
73\r
74/**\r
75 Searches in the gauge array with keyword Handle, Token, Module and Identfier.\r
76\r
77 This internal function searches for the gauge entry in the gauge array.\r
78 If there is an entry that exactly matches the given keywords\r
79 and its end time stamp is zero, then the index of that gauge entry is returned;\r
80 otherwise, the the number of gauge entries in the array is returned.\r
81\r
82 @param Handle Pointer to environment specific context used\r
83 to identify the component being measured.\r
84 @param Token Pointer to a Null-terminated ASCII string\r
85 that identifies the component being measured.\r
86 @param Module Pointer to a Null-terminated ASCII string\r
87 that identifies the module being measured.\r
88 @param Identifier 32-bit identifier.\r
89\r
90 @retval The index of gauge entry in the array.\r
91\r
92**/\r
93UINT32\r
94SmmSearchForGaugeEntry (\r
95 IN CONST VOID *Handle, OPTIONAL\r
96 IN CONST CHAR8 *Token, OPTIONAL\r
97 IN CONST CHAR8 *Module, OPTIONAL\r
98 IN CONST UINT32 Identifier\r
99 )\r
100{\r
101 UINT32 Index;\r
102 UINT32 Index2;\r
103 UINT32 NumberOfEntries;\r
104 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
105\r
106 if (Token == NULL) {\r
107 Token = "";\r
108 }\r
109 if (Module == NULL) {\r
110 Module = "";\r
111 }\r
112\r
113 NumberOfEntries = mGaugeData->NumberOfEntries;\r
114 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
115\r
116 Index2 = 0;\r
117\r
118 for (Index = 0; Index < NumberOfEntries; Index++) {\r
119 Index2 = NumberOfEntries - 1 - Index;\r
120 if (GaugeEntryExArray[Index2].EndTimeStamp == 0 &&\r
121 (GaugeEntryExArray[Index2].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
122 AsciiStrnCmp (GaugeEntryExArray[Index2].Token, Token, SMM_PERFORMANCE_STRING_LENGTH) == 0 &&\r
123 AsciiStrnCmp (GaugeEntryExArray[Index2].Module, Module, SMM_PERFORMANCE_STRING_LENGTH) == 0) {\r
124 Index = Index2;\r
125 break;\r
126 }\r
127 }\r
128\r
129 return Index;\r
130}\r
131\r
132/**\r
133 Adds a record at the end of the performance measurement log\r
134 that records the start time of a performance measurement.\r
135\r
136 Adds a record to the end of the performance measurement log\r
137 that contains the Handle, Token, Module and Identifier.\r
138 The end time of the new record must be set to zero.\r
139 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.\r
140 If TimeStamp is zero, the start time in the record is filled in with the value\r
141 read from the current time stamp.\r
142\r
143 @param Handle Pointer to environment specific context used\r
144 to identify the component being measured.\r
145 @param Token Pointer to a Null-terminated ASCII string\r
146 that identifies the component being measured.\r
147 @param Module Pointer to a Null-terminated ASCII string\r
148 that identifies the module being measured.\r
149 @param TimeStamp 64-bit time stamp.\r
150 @param Identifier 32-bit identifier. If the value is 0, the created record\r
151 is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.\r
152\r
153 @retval EFI_SUCCESS The data was read correctly from the device.\r
154 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
155\r
156**/\r
157EFI_STATUS\r
158EFIAPI\r
159StartGaugeEx (\r
160 IN CONST VOID *Handle, OPTIONAL\r
161 IN CONST CHAR8 *Token, OPTIONAL\r
162 IN CONST CHAR8 *Module, OPTIONAL\r
163 IN UINT64 TimeStamp,\r
164 IN UINT32 Identifier\r
165 )\r
166{\r
167 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
168 UINTN GaugeDataSize;\r
169 GAUGE_DATA_HEADER *NewGaugeData;\r
170 UINTN OldGaugeDataSize;\r
171 GAUGE_DATA_HEADER *OldGaugeData;\r
172 UINT32 Index;\r
173\r
174 AcquireSpinLock (&mSmmPerfLock);\r
175\r
176 Index = mGaugeData->NumberOfEntries;\r
177 if (Index >= mMaxGaugeRecords) {\r
178 //\r
179 // Try to enlarge the scale of gauge array.\r
180 //\r
181 OldGaugeData = mGaugeData;\r
182 OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords;\r
183\r
184 GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords * 2;\r
185\r
186 NewGaugeData = AllocateZeroPool (GaugeDataSize);\r
187 if (NewGaugeData == NULL) {\r
188 ReleaseSpinLock (&mSmmPerfLock);\r
189 return EFI_OUT_OF_RESOURCES;\r
190 }\r
191\r
192 mGaugeData = NewGaugeData;\r
193 mMaxGaugeRecords *= 2;\r
194\r
195 //\r
196 // Initialize new data array and migrate old data one.\r
197 //\r
198 mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);\r
199\r
200 FreePool (OldGaugeData);\r
201 }\r
202\r
203 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
204 GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
205\r
206 if (Token != NULL) {\r
207 AsciiStrnCpyS (GaugeEntryExArray[Index].Token, SMM_PERFORMANCE_STRING_SIZE, Token, SMM_PERFORMANCE_STRING_LENGTH);\r
208 }\r
209 if (Module != NULL) {\r
210 AsciiStrnCpyS (GaugeEntryExArray[Index].Module, SMM_PERFORMANCE_STRING_SIZE, Module, SMM_PERFORMANCE_STRING_LENGTH);\r
211 }\r
212\r
213 GaugeEntryExArray[Index].EndTimeStamp = 0;\r
214 GaugeEntryExArray[Index].Identifier = Identifier;\r
215\r
216 if (TimeStamp == 0) {\r
217 TimeStamp = GetPerformanceCounter ();\r
218 }\r
219 GaugeEntryExArray[Index].StartTimeStamp = TimeStamp;\r
220\r
221 mGaugeData->NumberOfEntries++;\r
222\r
223 ReleaseSpinLock (&mSmmPerfLock);\r
224\r
225 return EFI_SUCCESS;\r
226}\r
227\r
228/**\r
229 Searches the performance measurement log from the beginning of the log\r
230 for the first matching record that contains a zero end time and fills in a valid end time.\r
231\r
232 Searches the performance measurement log from the beginning of the log\r
233 for the first record that matches Handle, Token and Module and has an end time value of zero.\r
234 If the record can not be found then return EFI_NOT_FOUND.\r
235 If the record is found and TimeStamp is not zero,\r
236 then the end time in the record is filled in with the value specified by TimeStamp.\r
237 If the record is found and TimeStamp is zero, then the end time in the matching record\r
238 is filled in with the current time stamp value.\r
239\r
240 @param Handle Pointer to environment specific context used\r
241 to identify the component being measured.\r
242 @param Token Pointer to a Null-terminated ASCII string\r
243 that identifies the component being measured.\r
244 @param Module Pointer to a Null-terminated ASCII string\r
245 that identifies the module being measured.\r
246 @param TimeStamp 64-bit time stamp.\r
247 @param Identifier 32-bit identifier. If the value is 0, the found record\r
248 is same as the one found by EndGauge of PERFORMANCE_PROTOCOL.\r
249\r
250 @retval EFI_SUCCESS The end of the measurement was recorded.\r
251 @retval EFI_NOT_FOUND The specified measurement record could not be found.\r
252\r
253**/\r
254EFI_STATUS\r
255EFIAPI\r
256EndGaugeEx (\r
257 IN CONST VOID *Handle, OPTIONAL\r
258 IN CONST CHAR8 *Token, OPTIONAL\r
259 IN CONST CHAR8 *Module, OPTIONAL\r
260 IN UINT64 TimeStamp,\r
261 IN UINT32 Identifier\r
262 )\r
263{\r
264 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
265 UINT32 Index;\r
266\r
267 AcquireSpinLock (&mSmmPerfLock);\r
268\r
269 if (TimeStamp == 0) {\r
270 TimeStamp = GetPerformanceCounter ();\r
271 }\r
272\r
273 Index = SmmSearchForGaugeEntry (Handle, Token, Module, Identifier);\r
274 if (Index >= mGaugeData->NumberOfEntries) {\r
275 ReleaseSpinLock (&mSmmPerfLock);\r
276 return EFI_NOT_FOUND;\r
277 }\r
278 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
279 GaugeEntryExArray[Index].EndTimeStamp = TimeStamp;\r
280\r
281 ReleaseSpinLock (&mSmmPerfLock);\r
282\r
283 return EFI_SUCCESS;\r
284}\r
285\r
286/**\r
287 Retrieves a previously logged performance measurement.\r
288 It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,\r
289 and then assign the Identifier with 0.\r
290\r
291 Retrieves the performance log entry from the performance log specified by LogEntryKey.\r
292 If it stands for a valid entry, then EFI_SUCCESS is returned and\r
293 GaugeDataEntryEx stores the pointer to that entry.\r
294\r
295 @param LogEntryKey The key for the previous performance measurement log entry.\r
296 If 0, then the first performance measurement log entry is retrieved.\r
297 @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey\r
298 if the retrieval is successful.\r
299\r
300 @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.\r
301 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).\r
302 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).\r
303 @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.\r
304\r
305**/\r
306EFI_STATUS\r
307EFIAPI\r
308GetGaugeEx (\r
309 IN UINTN LogEntryKey,\r
310 OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx\r
311 )\r
312{\r
313 UINTN NumberOfEntries;\r
314 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
315\r
316 NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);\r
317 if (LogEntryKey > NumberOfEntries) {\r
318 return EFI_INVALID_PARAMETER;\r
319 }\r
320 if (LogEntryKey == NumberOfEntries) {\r
321 return EFI_NOT_FOUND;\r
322 }\r
323\r
324 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
325\r
326 if (GaugeDataEntryEx == NULL) {\r
327 return EFI_INVALID_PARAMETER;\r
328 }\r
329 *GaugeDataEntryEx = &GaugeEntryExArray[LogEntryKey];\r
330\r
331 return EFI_SUCCESS;\r
332}\r
333\r
334/**\r
335 Adds a record at the end of the performance measurement log\r
336 that records the start time of a performance measurement.\r
337\r
338 Adds a record to the end of the performance measurement log\r
339 that contains the Handle, Token, and Module.\r
340 The end time of the new record must be set to zero.\r
341 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.\r
342 If TimeStamp is zero, the start time in the record is filled in with the value\r
343 read from the current time stamp.\r
344\r
345 @param Handle Pointer to environment specific context used\r
346 to identify the component being measured.\r
347 @param Token Pointer to a Null-terminated ASCII string\r
348 that identifies the component being measured.\r
349 @param Module Pointer to a Null-terminated ASCII string\r
350 that identifies the module being measured.\r
351 @param TimeStamp 64-bit time stamp.\r
352\r
353 @retval EFI_SUCCESS The data was read correctly from the device.\r
354 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
355\r
356**/\r
357EFI_STATUS\r
358EFIAPI\r
359StartGauge (\r
360 IN CONST VOID *Handle, OPTIONAL\r
361 IN CONST CHAR8 *Token, OPTIONAL\r
362 IN CONST CHAR8 *Module, OPTIONAL\r
363 IN UINT64 TimeStamp\r
364 )\r
365{\r
366 return StartGaugeEx (Handle, Token, Module, TimeStamp, 0);\r
367}\r
368\r
369/**\r
370 Searches the performance measurement log from the beginning of the log\r
371 for the first matching record that contains a zero end time and fills in a valid end time.\r
372\r
373 Searches the performance measurement log from the beginning of the log\r
374 for the first record that matches Handle, Token, and Module and has an end time value of zero.\r
375 If the record can not be found then return EFI_NOT_FOUND.\r
376 If the record is found and TimeStamp is not zero,\r
377 then the end time in the record is filled in with the value specified by TimeStamp.\r
378 If the record is found and TimeStamp is zero, then the end time in the matching record\r
379 is filled in with the current time stamp value.\r
380\r
381 @param Handle Pointer to environment specific context used\r
382 to identify the component being measured.\r
383 @param Token Pointer to a Null-terminated ASCII string\r
384 that identifies the component being measured.\r
385 @param Module Pointer to a Null-terminated ASCII string\r
386 that identifies the module being measured.\r
387 @param TimeStamp 64-bit time stamp.\r
388\r
389 @retval EFI_SUCCESS The end of the measurement was recorded.\r
390 @retval EFI_NOT_FOUND The specified measurement record could not be found.\r
391\r
392**/\r
393EFI_STATUS\r
394EFIAPI\r
395EndGauge (\r
396 IN CONST VOID *Handle, OPTIONAL\r
397 IN CONST CHAR8 *Token, OPTIONAL\r
398 IN CONST CHAR8 *Module, OPTIONAL\r
399 IN UINT64 TimeStamp\r
400 )\r
401{\r
402 return EndGaugeEx (Handle, Token, Module, TimeStamp, 0);\r
403}\r
404\r
405/**\r
406 Retrieves a previously logged performance measurement.\r
407 It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,\r
408 and then eliminate the Identifier.\r
409\r
410 Retrieves the performance log entry from the performance log specified by LogEntryKey.\r
411 If it stands for a valid entry, then EFI_SUCCESS is returned and\r
412 GaugeDataEntry stores the pointer to that entry.\r
413\r
414 @param LogEntryKey The key for the previous performance measurement log entry.\r
415 If 0, then the first performance measurement log entry is retrieved.\r
416 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey\r
417 if the retrieval is successful.\r
418\r
419 @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.\r
420 @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).\r
421 @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).\r
422 @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.\r
423\r
424**/\r
425EFI_STATUS\r
426EFIAPI\r
427GetGauge (\r
428 IN UINTN LogEntryKey,\r
429 OUT GAUGE_DATA_ENTRY **GaugeDataEntry\r
430 )\r
431{\r
432 EFI_STATUS Status;\r
433 GAUGE_DATA_ENTRY_EX *GaugeEntryEx;\r
434\r
435 GaugeEntryEx = NULL;\r
436\r
437 Status = GetGaugeEx (LogEntryKey, &GaugeEntryEx);\r
438 if (EFI_ERROR (Status)) {\r
439 return Status;\r
440 }\r
441\r
442 if (GaugeDataEntry == NULL) {\r
443 return EFI_INVALID_PARAMETER;\r
444 }\r
445\r
446 *GaugeDataEntry = (GAUGE_DATA_ENTRY *) GaugeEntryEx;\r
447\r
448 return EFI_SUCCESS;\r
449}\r
450\r
451/**\r
452 Communication service SMI Handler entry.\r
453\r
454 This SMI handler provides services for the performance wrapper driver.\r
455 \r
456 Caution: This function may receive untrusted input.\r
457 Communicate buffer and buffer size are external input, so this function will do basic validation.\r
458\r
459 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
460 @param[in] RegisterContext Points to an optional handler context which was specified when the\r
461 handler was registered.\r
462 @param[in, out] CommBuffer A pointer to a collection of data in memory that will\r
463 be conveyed from a non-SMM environment into an SMM environment.\r
464 @param[in, out] CommBufferSize The size of the CommBuffer.\r
465\r
466 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers \r
467 should still be called.\r
468 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should \r
469 still be called.\r
470 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still \r
471 be called.\r
472 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.\r
473**/\r
474EFI_STATUS\r
475EFIAPI\r
476SmmPerformanceHandlerEx (\r
477 IN EFI_HANDLE DispatchHandle,\r
478 IN CONST VOID *RegisterContext,\r
479 IN OUT VOID *CommBuffer,\r
480 IN OUT UINTN *CommBufferSize\r
481 )\r
482{\r
483 EFI_STATUS Status;\r
484 SMM_PERF_COMMUNICATE_EX *SmmPerfCommData;\r
485 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
486 UINT64 DataSize;\r
487 UINTN Index;\r
488 GAUGE_DATA_ENTRY_EX *GaugeDataEx;\r
489 UINTN NumberOfEntries;\r
490 UINTN LogEntryKey;\r
491 UINTN TempCommBufferSize;\r
492\r
493 GaugeEntryExArray = NULL;\r
494\r
495 //\r
496 // If input is invalid, stop processing this SMI\r
497 //\r
498 if (CommBuffer == NULL || CommBufferSize == NULL) {\r
499 return EFI_SUCCESS;\r
500 }\r
501\r
502 TempCommBufferSize = *CommBufferSize;\r
503\r
504 if(TempCommBufferSize < sizeof (SMM_PERF_COMMUNICATE_EX)) {\r
505 return EFI_SUCCESS;\r
506 }\r
507\r
508 if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
509 DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM communcation data buffer in SMRAM or overflow!\n"));\r
510 return EFI_SUCCESS;\r
511 }\r
512 \r
513 SmmPerfCommData = (SMM_PERF_COMMUNICATE_EX *)CommBuffer;\r
514\r
515 switch (SmmPerfCommData->Function) {\r
516 case SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER :\r
517 SmmPerfCommData->NumberOfEntries = mGaugeData->NumberOfEntries;\r
518 Status = EFI_SUCCESS;\r
519 break;\r
520\r
521 case SMM_PERF_FUNCTION_GET_GAUGE_DATA :\r
522 GaugeDataEx = SmmPerfCommData->GaugeDataEx;\r
523 NumberOfEntries = SmmPerfCommData->NumberOfEntries;\r
524 LogEntryKey = SmmPerfCommData->LogEntryKey;\r
525 if (GaugeDataEx == NULL || NumberOfEntries == 0 || LogEntryKey > mGaugeData->NumberOfEntries ||\r
526 NumberOfEntries > mGaugeData->NumberOfEntries || LogEntryKey > (mGaugeData->NumberOfEntries - NumberOfEntries)) {\r
527 Status = EFI_INVALID_PARAMETER;\r
528 break;\r
529 }\r
530\r
531 //\r
532 // Sanity check\r
533 //\r
534 DataSize = MultU64x32 (NumberOfEntries, sizeof(GAUGE_DATA_ENTRY_EX));\r
535 if (!SmmIsBufferOutsideSmmValid ((UINTN) GaugeDataEx, DataSize)) {\r
536 DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
537 Status = EFI_ACCESS_DENIED;\r
538 break;\r
539 }\r
540\r
541 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
542\r
543 for (Index = 0; Index < NumberOfEntries; Index++) {\r
544 CopyMem (\r
545 (UINT8 *) &GaugeDataEx[Index],\r
546 (UINT8 *) &GaugeEntryExArray[LogEntryKey++],\r
547 sizeof (GAUGE_DATA_ENTRY_EX)\r
548 );\r
549 }\r
550 Status = EFI_SUCCESS;\r
551 break;\r
552\r
553 default:\r
554 Status = EFI_UNSUPPORTED;\r
555 }\r
556\r
557\r
558 SmmPerfCommData->ReturnStatus = Status;\r
559 \r
560 return EFI_SUCCESS;\r
561}\r
562\r
563/**\r
564 Communication service SMI Handler entry.\r
565\r
566 This SMI handler provides services for the performance wrapper driver.\r
567\r
568 Caution: This function may receive untrusted input.\r
569 Communicate buffer and buffer size are external input, so this function will do basic validation.\r
570\r
571 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
572 @param[in] RegisterContext Points to an optional handler context which was specified when the\r
573 handler was registered.\r
574 @param[in, out] CommBuffer A pointer to a collection of data in memory that will\r
575 be conveyed from a non-SMM environment into an SMM environment.\r
576 @param[in, out] CommBufferSize The size of the CommBuffer.\r
577\r
578 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers \r
579 should still be called.\r
580 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should \r
581 still be called.\r
582 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still \r
583 be called.\r
584 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.\r
585**/\r
586EFI_STATUS\r
587EFIAPI\r
588SmmPerformanceHandler (\r
589 IN EFI_HANDLE DispatchHandle,\r
590 IN CONST VOID *RegisterContext,\r
591 IN OUT VOID *CommBuffer,\r
592 IN OUT UINTN *CommBufferSize\r
593 )\r
594{\r
595 EFI_STATUS Status;\r
596 SMM_PERF_COMMUNICATE *SmmPerfCommData;\r
597 GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;\r
598 UINT64 DataSize;\r
599 UINTN Index;\r
600 GAUGE_DATA_ENTRY *GaugeData;\r
601 UINTN NumberOfEntries;\r
602 UINTN LogEntryKey;\r
603 UINTN TempCommBufferSize;\r
604\r
605 GaugeEntryExArray = NULL;\r
606\r
607 //\r
608 // If input is invalid, stop processing this SMI\r
609 //\r
610 if (CommBuffer == NULL || CommBufferSize == NULL) {\r
611 return EFI_SUCCESS;\r
612 }\r
613\r
614 TempCommBufferSize = *CommBufferSize;\r
615\r
616 if(TempCommBufferSize < sizeof (SMM_PERF_COMMUNICATE)) {\r
617 return EFI_SUCCESS;\r
618 }\r
619\r
620 if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
621 DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM communcation data buffer in SMRAM or overflow!\n"));\r
622 return EFI_SUCCESS;\r
623 }\r
624\r
625 SmmPerfCommData = (SMM_PERF_COMMUNICATE *)CommBuffer;\r
626\r
627 switch (SmmPerfCommData->Function) {\r
628 case SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER :\r
629 SmmPerfCommData->NumberOfEntries = mGaugeData->NumberOfEntries;\r
630 Status = EFI_SUCCESS;\r
631 break;\r
632\r
633 case SMM_PERF_FUNCTION_GET_GAUGE_DATA :\r
634 GaugeData = SmmPerfCommData->GaugeData;\r
635 NumberOfEntries = SmmPerfCommData->NumberOfEntries;\r
636 LogEntryKey = SmmPerfCommData->LogEntryKey;\r
637 if (GaugeData == NULL || NumberOfEntries == 0 || LogEntryKey > mGaugeData->NumberOfEntries ||\r
638 NumberOfEntries > mGaugeData->NumberOfEntries || LogEntryKey > (mGaugeData->NumberOfEntries - NumberOfEntries)) {\r
639 Status = EFI_INVALID_PARAMETER;\r
640 break;\r
641 }\r
642\r
643 //\r
644 // Sanity check\r
645 //\r
646 DataSize = MultU64x32 (NumberOfEntries, sizeof(GAUGE_DATA_ENTRY));\r
647 if (!SmmIsBufferOutsideSmmValid ((UINTN) GaugeData, DataSize)) {\r
648 DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
649 Status = EFI_ACCESS_DENIED;\r
650 break;\r
651 }\r
652\r
653 GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
654\r
655 for (Index = 0; Index < NumberOfEntries; Index++) {\r
656 CopyMem (\r
657 (UINT8 *) &GaugeData[Index],\r
658 (UINT8 *) &GaugeEntryExArray[LogEntryKey++],\r
659 sizeof (GAUGE_DATA_ENTRY)\r
660 );\r
661 }\r
662 Status = EFI_SUCCESS;\r
663 break;\r
664\r
665 default:\r
666 Status = EFI_UNSUPPORTED;\r
667 }\r
668\r
669\r
670 SmmPerfCommData->ReturnStatus = Status;\r
671 \r
672 return EFI_SUCCESS;\r
673}\r
674\r
675/**\r
676 SmmBase2 protocol notify callback function, when SMST and SMM memory service get initialized \r
677 this function is callbacked to initialize the Smm Performance Lib \r
678\r
679 @param Event The event of notify protocol.\r
680 @param Context Notify event context.\r
681\r
682**/\r
683VOID\r
684EFIAPI\r
685InitializeSmmCorePerformanceLib (\r
686 IN EFI_EVENT Event,\r
687 IN VOID *Context\r
688 )\r
689{\r
690 EFI_STATUS Status;\r
691 EFI_HANDLE Handle;\r
692 PERFORMANCE_PROPERTY *PerformanceProperty;\r
693\r
694 //\r
695 // Initialize spin lock\r
696 //\r
697 InitializeSpinLock (&mSmmPerfLock);\r
698\r
699 mMaxGaugeRecords = INIT_SMM_GAUGE_DATA_ENTRIES;\r
700\r
701 mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));\r
702 ASSERT (mGaugeData != NULL);\r
703 \r
704 //\r
705 // Install the protocol interfaces.\r
706 //\r
707 Status = gSmst->SmmInstallProtocolInterface (\r
708 &mHandle,\r
709 &gSmmPerformanceProtocolGuid,\r
710 EFI_NATIVE_INTERFACE,\r
711 &mPerformanceInterface\r
712 );\r
713 ASSERT_EFI_ERROR (Status);\r
714\r
715 Status = gSmst->SmmInstallProtocolInterface (\r
716 &mHandle,\r
717 &gSmmPerformanceExProtocolGuid,\r
718 EFI_NATIVE_INTERFACE,\r
719 &mPerformanceExInterface\r
720 );\r
721 ASSERT_EFI_ERROR (Status);\r
722\r
723 ///\r
724 /// Register SMM Performance SMI handler\r
725 ///\r
726 Handle = NULL;\r
727 Status = gSmst->SmiHandlerRegister (SmmPerformanceHandler, &gSmmPerformanceProtocolGuid, &Handle);\r
728 ASSERT_EFI_ERROR (Status);\r
729 Status = gSmst->SmiHandlerRegister (SmmPerformanceHandlerEx, &gSmmPerformanceExProtocolGuid, &Handle);\r
730 ASSERT_EFI_ERROR (Status);\r
731\r
732 Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);\r
733 if (EFI_ERROR (Status)) {\r
734 //\r
735 // Install configuration table for performance property.\r
736 //\r
737 mPerformanceProperty.Revision = PERFORMANCE_PROPERTY_REVISION;\r
738 mPerformanceProperty.Reserved = 0;\r
739 mPerformanceProperty.Frequency = GetPerformanceCounterProperties (\r
740 &mPerformanceProperty.TimerStartValue,\r
741 &mPerformanceProperty.TimerEndValue\r
742 );\r
743 Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty);\r
744 ASSERT_EFI_ERROR (Status);\r
745 }\r
746}\r
747\r
748/**\r
749 The constructor function initializes the Performance Measurement Enable flag and \r
750 registers SmmBase2 protocol notify callback.\r
751 It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.\r
752\r
753 @param ImageHandle The firmware allocated handle for the EFI image.\r
754 @param SystemTable A pointer to the EFI System Table.\r
755\r
756 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
757\r
758**/\r
759EFI_STATUS\r
760EFIAPI\r
761SmmCorePerformanceLibConstructor (\r
762 IN EFI_HANDLE ImageHandle,\r
763 IN EFI_SYSTEM_TABLE *SystemTable\r
764 )\r
765{\r
766 EFI_STATUS Status;\r
767 EFI_EVENT Event;\r
768 VOID *Registration;\r
769\r
770 mPerformanceMeasurementEnabled = (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
771 if (!mPerformanceMeasurementEnabled) {\r
772 //\r
773 // Do not initialize performance infrastructure if not required.\r
774 //\r
775 return EFI_SUCCESS;\r
776 }\r
777\r
778 //\r
779 // Create the events to do the library init.\r
780 //\r
781 Status = gBS->CreateEvent (\r
782 EVT_NOTIFY_SIGNAL,\r
783 TPL_CALLBACK,\r
784 InitializeSmmCorePerformanceLib,\r
785 NULL,\r
786 &Event\r
787 );\r
788 ASSERT_EFI_ERROR (Status);\r
789\r
790 //\r
791 // Register for protocol notifications on this event\r
792 //\r
793 Status = gBS->RegisterProtocolNotify (\r
794 &gEfiSmmBase2ProtocolGuid,\r
795 Event,\r
796 &Registration\r
797 );\r
798\r
799 ASSERT_EFI_ERROR (Status);\r
800\r
801 return EFI_SUCCESS;\r
802}\r
803\r
804/**\r
805 Adds a record at the end of the performance measurement log\r
806 that records the start time of a performance measurement.\r
807\r
808 Adds a record to the end of the performance measurement log\r
809 that contains the Handle, Token, Module and Identifier.\r
810 The end time of the new record must be set to zero.\r
811 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.\r
812 If TimeStamp is zero, the start time in the record is filled in with the value\r
813 read from the current time stamp.\r
814\r
815 @param Handle Pointer to environment specific context used\r
816 to identify the component being measured.\r
817 @param Token Pointer to a Null-terminated ASCII string\r
818 that identifies the component being measured.\r
819 @param Module Pointer to a Null-terminated ASCII string\r
820 that identifies the module being measured.\r
821 @param TimeStamp 64-bit time stamp.\r
822 @param Identifier 32-bit identifier. If the value is 0, the created record\r
823 is same as the one created by StartPerformanceMeasurement.\r
824\r
825 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
826 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
827\r
828**/\r
829RETURN_STATUS\r
830EFIAPI\r
831StartPerformanceMeasurementEx (\r
832 IN CONST VOID *Handle, OPTIONAL\r
833 IN CONST CHAR8 *Token, OPTIONAL\r
834 IN CONST CHAR8 *Module, OPTIONAL\r
835 IN UINT64 TimeStamp,\r
836 IN UINT32 Identifier\r
837 )\r
838{\r
839 return (RETURN_STATUS) StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);\r
840}\r
841\r
842/**\r
843 Searches the performance measurement log from the beginning of the log\r
844 for the first matching record that contains a zero end time and fills in a valid end time.\r
845\r
846 Searches the performance measurement log from the beginning of the log\r
847 for the first record that matches Handle, Token and Module and has an end time value of zero.\r
848 If the record can not be found then return RETURN_NOT_FOUND.\r
849 If the record is found and TimeStamp is not zero,\r
850 then the end time in the record is filled in with the value specified by TimeStamp.\r
851 If the record is found and TimeStamp is zero, then the end time in the matching record\r
852 is filled in with the current time stamp value.\r
853\r
854 @param Handle Pointer to environment specific context used\r
855 to identify the component being measured.\r
856 @param Token Pointer to a Null-terminated ASCII string\r
857 that identifies the component being measured.\r
858 @param Module Pointer to a Null-terminated ASCII string\r
859 that identifies the module being measured.\r
860 @param TimeStamp 64-bit time stamp.\r
861 @param Identifier 32-bit identifier. If the value is 0, the found record\r
862 is same as the one found by EndPerformanceMeasurement.\r
863\r
864 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
865 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
866\r
867**/\r
868RETURN_STATUS\r
869EFIAPI\r
870EndPerformanceMeasurementEx (\r
871 IN CONST VOID *Handle, OPTIONAL\r
872 IN CONST CHAR8 *Token, OPTIONAL\r
873 IN CONST CHAR8 *Module, OPTIONAL\r
874 IN UINT64 TimeStamp,\r
875 IN UINT32 Identifier\r
876 )\r
877{\r
878 return (RETURN_STATUS) EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);\r
879}\r
880\r
881/**\r
882 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
883 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r
884 and then assign the Identifier with 0.\r
885\r
886 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
887 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
888 and the key for the second entry in the log is returned. If the performance log is empty,\r
889 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
890 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
891 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
892 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
893 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
894 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
895 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r
896 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
897 If Handle is NULL, then ASSERT().\r
898 If Token is NULL, then ASSERT().\r
899 If Module is NULL, then ASSERT().\r
900 If StartTimeStamp is NULL, then ASSERT().\r
901 If EndTimeStamp is NULL, then ASSERT().\r
902 If Identifier is NULL, then ASSERT().\r
903\r
904 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
905 0, then the first performance measurement log entry is retrieved.\r
906 On exit, the key of the next performance log entry.\r
907 @param Handle Pointer to environment specific context used to identify the component\r
908 being measured.\r
909 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
910 being measured.\r
911 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
912 being measured.\r
913 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
914 was started.\r
915 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
916 was ended.\r
917 @param Identifier Pointer to the 32-bit identifier that was recorded.\r
918\r
919 @return The key for the next performance log entry (in general case).\r
920\r
921**/\r
922UINTN\r
923EFIAPI\r
924GetPerformanceMeasurementEx (\r
925 IN UINTN LogEntryKey, \r
926 OUT CONST VOID **Handle,\r
927 OUT CONST CHAR8 **Token,\r
928 OUT CONST CHAR8 **Module,\r
929 OUT UINT64 *StartTimeStamp,\r
930 OUT UINT64 *EndTimeStamp,\r
931 OUT UINT32 *Identifier\r
932 )\r
933{\r
934 EFI_STATUS Status;\r
935 GAUGE_DATA_ENTRY_EX *GaugeData;\r
936\r
937 GaugeData = NULL;\r
938 \r
939 ASSERT (Handle != NULL);\r
940 ASSERT (Token != NULL);\r
941 ASSERT (Module != NULL);\r
942 ASSERT (StartTimeStamp != NULL);\r
943 ASSERT (EndTimeStamp != NULL);\r
944 ASSERT (Identifier != NULL);\r
945\r
946 Status = GetGaugeEx (LogEntryKey++, &GaugeData);\r
947\r
948 //\r
949 // Make sure that LogEntryKey is a valid log entry key,\r
950 //\r
951 ASSERT (Status != EFI_INVALID_PARAMETER);\r
952\r
953 if (EFI_ERROR (Status)) {\r
954 //\r
955 // The LogEntryKey is the last entry (equals to the total entry number).\r
956 //\r
957 return 0;\r
958 }\r
959\r
960 ASSERT (GaugeData != NULL);\r
961\r
962 *Handle = (VOID *) (UINTN) GaugeData->Handle;\r
963 *Token = GaugeData->Token;\r
964 *Module = GaugeData->Module;\r
965 *StartTimeStamp = GaugeData->StartTimeStamp;\r
966 *EndTimeStamp = GaugeData->EndTimeStamp;\r
967 *Identifier = GaugeData->Identifier;\r
968\r
969 return LogEntryKey;\r
970}\r
971\r
972/**\r
973 Adds a record at the end of the performance measurement log\r
974 that records the start time of a performance measurement.\r
975\r
976 Adds a record to the end of the performance measurement log\r
977 that contains the Handle, Token, and Module.\r
978 The end time of the new record must be set to zero.\r
979 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.\r
980 If TimeStamp is zero, the start time in the record is filled in with the value\r
981 read from the current time stamp.\r
982\r
983 @param Handle Pointer to environment specific context used\r
984 to identify the component being measured.\r
985 @param Token Pointer to a Null-terminated ASCII string\r
986 that identifies the component being measured.\r
987 @param Module Pointer to a Null-terminated ASCII string\r
988 that identifies the module being measured.\r
989 @param TimeStamp 64-bit time stamp.\r
990\r
991 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
992 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
993\r
994**/\r
995RETURN_STATUS\r
996EFIAPI\r
997StartPerformanceMeasurement (\r
998 IN CONST VOID *Handle, OPTIONAL\r
999 IN CONST CHAR8 *Token, OPTIONAL\r
1000 IN CONST CHAR8 *Module, OPTIONAL\r
1001 IN UINT64 TimeStamp\r
1002 )\r
1003{\r
1004 return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r
1005}\r
1006\r
1007/**\r
1008 Searches the performance measurement log from the beginning of the log\r
1009 for the first matching record that contains a zero end time and fills in a valid end time.\r
1010\r
1011 Searches the performance measurement log from the beginning of the log\r
1012 for the first record that matches Handle, Token, and Module and has an end time value of zero.\r
1013 If the record can not be found then return RETURN_NOT_FOUND.\r
1014 If the record is found and TimeStamp is not zero,\r
1015 then the end time in the record is filled in with the value specified by TimeStamp.\r
1016 If the record is found and TimeStamp is zero, then the end time in the matching record\r
1017 is filled in with the current time stamp value.\r
1018\r
1019 @param Handle Pointer to environment specific context used\r
1020 to identify the component being measured.\r
1021 @param Token Pointer to a Null-terminated ASCII string\r
1022 that identifies the component being measured.\r
1023 @param Module Pointer to a Null-terminated ASCII string\r
1024 that identifies the module being measured.\r
1025 @param TimeStamp 64-bit time stamp.\r
1026\r
1027 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
1028 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
1029\r
1030**/\r
1031RETURN_STATUS\r
1032EFIAPI\r
1033EndPerformanceMeasurement (\r
1034 IN CONST VOID *Handle, OPTIONAL\r
1035 IN CONST CHAR8 *Token, OPTIONAL\r
1036 IN CONST CHAR8 *Module, OPTIONAL\r
1037 IN UINT64 TimeStamp\r
1038 )\r
1039{\r
1040 return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r
1041}\r
1042\r
1043/**\r
1044 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
1045 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r
1046 and then eliminate the Identifier.\r
1047\r
1048 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
1049 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
1050 and the key for the second entry in the log is returned. If the performance log is empty,\r
1051 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
1052 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
1053 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
1054 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
1055 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
1056 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
1057 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
1058 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
1059 If Handle is NULL, then ASSERT().\r
1060 If Token is NULL, then ASSERT().\r
1061 If Module is NULL, then ASSERT().\r
1062 If StartTimeStamp is NULL, then ASSERT().\r
1063 If EndTimeStamp is NULL, then ASSERT().\r
1064\r
1065 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
1066 0, then the first performance measurement log entry is retrieved.\r
1067 On exit, the key of the next performance log entry.\r
1068 @param Handle Pointer to environment specific context used to identify the component\r
1069 being measured.\r
1070 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
1071 being measured.\r
1072 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
1073 being measured.\r
1074 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
1075 was started.\r
1076 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
1077 was ended.\r
1078\r
1079 @return The key for the next performance log entry (in general case).\r
1080\r
1081**/\r
1082UINTN\r
1083EFIAPI\r
1084GetPerformanceMeasurement (\r
1085 IN UINTN LogEntryKey,\r
1086 OUT CONST VOID **Handle,\r
1087 OUT CONST CHAR8 **Token,\r
1088 OUT CONST CHAR8 **Module,\r
1089 OUT UINT64 *StartTimeStamp,\r
1090 OUT UINT64 *EndTimeStamp\r
1091 )\r
1092{\r
1093 UINT32 Identifier;\r
1094 return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);\r
1095}\r
1096\r
1097/**\r
1098 Returns TRUE if the performance measurement macros are enabled.\r
1099\r
1100 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
1101 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r
1102\r
1103 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
1104 PcdPerformanceLibraryPropertyMask is set.\r
1105 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
1106 PcdPerformanceLibraryPropertyMask is clear.\r
1107\r
1108**/\r
1109BOOLEAN\r
1110EFIAPI\r
1111PerformanceMeasurementEnabled (\r
1112 VOID\r
1113 )\r
1114{\r
1115 return mPerformanceMeasurementEnabled;\r
1116}\r