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