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