1 | /** @file
|
---|
2 | Provides services to log the execution times and retrieve them later.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef __PERFORMANCE_LIB_H__
|
---|
10 | #define __PERFORMANCE_LIB_H__
|
---|
11 |
|
---|
12 | ///
|
---|
13 | /// Performance library propery mask bits
|
---|
14 | ///
|
---|
15 | #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001
|
---|
16 |
|
---|
17 | //
|
---|
18 | // Public Progress Identifiers for Event Records.
|
---|
19 | //
|
---|
20 | #define PERF_EVENT_ID 0x00
|
---|
21 |
|
---|
22 | #define MODULE_START_ID 0x01
|
---|
23 | #define MODULE_END_ID 0x02
|
---|
24 | #define MODULE_LOADIMAGE_START_ID 0x03
|
---|
25 | #define MODULE_LOADIMAGE_END_ID 0x04
|
---|
26 | #define MODULE_DB_START_ID 0x05
|
---|
27 | #define MODULE_DB_END_ID 0x06
|
---|
28 | #define MODULE_DB_SUPPORT_START_ID 0x07
|
---|
29 | #define MODULE_DB_SUPPORT_END_ID 0x08
|
---|
30 | #define MODULE_DB_STOP_START_ID 0x09
|
---|
31 | #define MODULE_DB_STOP_END_ID 0x0A
|
---|
32 |
|
---|
33 | #define PERF_EVENTSIGNAL_START_ID 0x10
|
---|
34 | #define PERF_EVENTSIGNAL_END_ID 0x11
|
---|
35 | #define PERF_CALLBACK_START_ID 0x20
|
---|
36 | #define PERF_CALLBACK_END_ID 0x21
|
---|
37 | #define PERF_FUNCTION_START_ID 0x30
|
---|
38 | #define PERF_FUNCTION_END_ID 0x31
|
---|
39 | #define PERF_INMODULE_START_ID 0x40
|
---|
40 | #define PERF_INMODULE_END_ID 0x41
|
---|
41 | #define PERF_CROSSMODULE_START_ID 0x50
|
---|
42 | #define PERF_CROSSMODULE_END_ID 0x51
|
---|
43 |
|
---|
44 | //
|
---|
45 | // Declare bits for PcdPerformanceLibraryPropertyMask and
|
---|
46 | // also used as the Type parameter of LogPerformanceMeasurementEnabled().
|
---|
47 | //
|
---|
48 | #define PERF_CORE_START_IMAGE 0x0002
|
---|
49 | #define PERF_CORE_LOAD_IMAGE 0x0004
|
---|
50 | #define PERF_CORE_DB_SUPPORT 0x0008
|
---|
51 | #define PERF_CORE_DB_START 0x0010
|
---|
52 | #define PERF_CORE_DB_STOP 0x0020
|
---|
53 |
|
---|
54 | #define PERF_GENERAL_TYPE 0x0040
|
---|
55 |
|
---|
56 | /**
|
---|
57 | Creates a record for the beginning of a performance measurement.
|
---|
58 |
|
---|
59 | Creates a record that contains the Handle, Token, and Module.
|
---|
60 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
|
---|
61 | If TimeStamp is zero, then this function reads the current time stamp
|
---|
62 | and adds that time stamp value to the record as the start time.
|
---|
63 |
|
---|
64 | @param Handle Pointer to environment specific context used
|
---|
65 | to identify the component being measured.
|
---|
66 | @param Token Pointer to a Null-terminated ASCII string
|
---|
67 | that identifies the component being measured.
|
---|
68 | @param Module Pointer to a Null-terminated ASCII string
|
---|
69 | that identifies the module being measured.
|
---|
70 | @param TimeStamp 64-bit time stamp.
|
---|
71 |
|
---|
72 | @retval RETURN_SUCCESS The start of the measurement was recorded.
|
---|
73 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
|
---|
74 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
|
---|
75 |
|
---|
76 | **/
|
---|
77 | RETURN_STATUS
|
---|
78 | EFIAPI
|
---|
79 | StartPerformanceMeasurement (
|
---|
80 | IN CONST VOID *Handle OPTIONAL,
|
---|
81 | IN CONST CHAR8 *Token OPTIONAL,
|
---|
82 | IN CONST CHAR8 *Module OPTIONAL,
|
---|
83 | IN UINT64 TimeStamp
|
---|
84 | );
|
---|
85 |
|
---|
86 | /**
|
---|
87 | Fills in the end time of a performance measurement.
|
---|
88 |
|
---|
89 | Looks up the record that matches Handle, Token, and Module.
|
---|
90 | If the record can not be found then return RETURN_NOT_FOUND.
|
---|
91 | If the record is found and TimeStamp is not zero,
|
---|
92 | then TimeStamp is added to the record as the end time.
|
---|
93 | If the record is found and TimeStamp is zero, then this function reads
|
---|
94 | the current time stamp and adds that time stamp value to the record as the end time.
|
---|
95 |
|
---|
96 | @param Handle Pointer to environment specific context used
|
---|
97 | to identify the component being measured.
|
---|
98 | @param Token Pointer to a Null-terminated ASCII string
|
---|
99 | that identifies the component being measured.
|
---|
100 | @param Module Pointer to a Null-terminated ASCII string
|
---|
101 | that identifies the module being measured.
|
---|
102 | @param TimeStamp 64-bit time stamp.
|
---|
103 |
|
---|
104 | @retval RETURN_SUCCESS The end of the measurement was recorded.
|
---|
105 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.
|
---|
106 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
|
---|
107 |
|
---|
108 | **/
|
---|
109 | RETURN_STATUS
|
---|
110 | EFIAPI
|
---|
111 | EndPerformanceMeasurement (
|
---|
112 | IN CONST VOID *Handle OPTIONAL,
|
---|
113 | IN CONST CHAR8 *Token OPTIONAL,
|
---|
114 | IN CONST CHAR8 *Module OPTIONAL,
|
---|
115 | IN UINT64 TimeStamp
|
---|
116 | );
|
---|
117 |
|
---|
118 | /**
|
---|
119 | Attempts to retrieve a performance measurement log entry from the performance measurement log.
|
---|
120 | It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
|
---|
121 | and then eliminate the Identifier.
|
---|
122 |
|
---|
123 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
|
---|
124 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,
|
---|
125 | and the key for the second entry in the log is returned. If the performance log is empty,
|
---|
126 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
|
---|
127 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
|
---|
128 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
|
---|
129 | retrieved and an implementation specific non-zero key value that specifies the end of the performance
|
---|
130 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
|
---|
131 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,
|
---|
132 | the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
|
---|
133 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
|
---|
134 | If Handle is NULL, then ASSERT().
|
---|
135 | If Token is NULL, then ASSERT().
|
---|
136 | If Module is NULL, then ASSERT().
|
---|
137 | If StartTimeStamp is NULL, then ASSERT().
|
---|
138 | If EndTimeStamp is NULL, then ASSERT().
|
---|
139 |
|
---|
140 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
|
---|
141 | 0, then the first performance measurement log entry is retrieved.
|
---|
142 | On exit, the key of the next performance lof entry entry.
|
---|
143 | @param Handle Pointer to environment specific context used to identify the component
|
---|
144 | being measured.
|
---|
145 | @param Token Pointer to a Null-terminated ASCII string that identifies the component
|
---|
146 | being measured.
|
---|
147 | @param Module Pointer to a Null-terminated ASCII string that identifies the module
|
---|
148 | being measured.
|
---|
149 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
|
---|
150 | was started.
|
---|
151 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
|
---|
152 | was ended.
|
---|
153 |
|
---|
154 | @return The key for the next performance log entry (in general case).
|
---|
155 |
|
---|
156 | **/
|
---|
157 | UINTN
|
---|
158 | EFIAPI
|
---|
159 | GetPerformanceMeasurement (
|
---|
160 | IN UINTN LogEntryKey,
|
---|
161 | OUT CONST VOID **Handle,
|
---|
162 | OUT CONST CHAR8 **Token,
|
---|
163 | OUT CONST CHAR8 **Module,
|
---|
164 | OUT UINT64 *StartTimeStamp,
|
---|
165 | OUT UINT64 *EndTimeStamp
|
---|
166 | );
|
---|
167 |
|
---|
168 | /**
|
---|
169 | Creates a record for the beginning of a performance measurement.
|
---|
170 |
|
---|
171 | Creates a record that contains the Handle, Token, Module and Identifier.
|
---|
172 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
|
---|
173 | If TimeStamp is zero, then this function reads the current time stamp
|
---|
174 | and adds that time stamp value to the record as the start time.
|
---|
175 |
|
---|
176 | @param Handle Pointer to environment specific context used
|
---|
177 | to identify the component being measured.
|
---|
178 | @param Token Pointer to a Null-terminated ASCII string
|
---|
179 | that identifies the component being measured.
|
---|
180 | @param Module Pointer to a Null-terminated ASCII string
|
---|
181 | that identifies the module being measured.
|
---|
182 | @param TimeStamp 64-bit time stamp.
|
---|
183 | @param Identifier 32-bit identifier. If the value is 0, the created record
|
---|
184 | is same as the one created by StartPerformanceMeasurement.
|
---|
185 |
|
---|
186 | @retval RETURN_SUCCESS The start of the measurement was recorded.
|
---|
187 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
|
---|
188 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
|
---|
189 |
|
---|
190 | **/
|
---|
191 | RETURN_STATUS
|
---|
192 | EFIAPI
|
---|
193 | StartPerformanceMeasurementEx (
|
---|
194 | IN CONST VOID *Handle OPTIONAL,
|
---|
195 | IN CONST CHAR8 *Token OPTIONAL,
|
---|
196 | IN CONST CHAR8 *Module OPTIONAL,
|
---|
197 | IN UINT64 TimeStamp,
|
---|
198 | IN UINT32 Identifier
|
---|
199 | );
|
---|
200 |
|
---|
201 | /**
|
---|
202 | Fills in the end time of a performance measurement.
|
---|
203 |
|
---|
204 | Looks up the record that matches Handle, Token and Module.
|
---|
205 | If the record can not be found then return RETURN_NOT_FOUND.
|
---|
206 | If the record is found and TimeStamp is not zero,
|
---|
207 | then TimeStamp is added to the record as the end time.
|
---|
208 | If the record is found and TimeStamp is zero, then this function reads
|
---|
209 | the current time stamp and adds that time stamp value to the record as the end time.
|
---|
210 |
|
---|
211 | @param Handle Pointer to environment specific context used
|
---|
212 | to identify the component being measured.
|
---|
213 | @param Token Pointer to a Null-terminated ASCII string
|
---|
214 | that identifies the component being measured.
|
---|
215 | @param Module Pointer to a Null-terminated ASCII string
|
---|
216 | that identifies the module being measured.
|
---|
217 | @param TimeStamp 64-bit time stamp.
|
---|
218 | @param Identifier 32-bit identifier. If the value is 0, the found record
|
---|
219 | is same as the one found by EndPerformanceMeasurement.
|
---|
220 |
|
---|
221 | @retval RETURN_SUCCESS The end of the measurement was recorded.
|
---|
222 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.
|
---|
223 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.
|
---|
224 |
|
---|
225 | **/
|
---|
226 | RETURN_STATUS
|
---|
227 | EFIAPI
|
---|
228 | EndPerformanceMeasurementEx (
|
---|
229 | IN CONST VOID *Handle OPTIONAL,
|
---|
230 | IN CONST CHAR8 *Token OPTIONAL,
|
---|
231 | IN CONST CHAR8 *Module OPTIONAL,
|
---|
232 | IN UINT64 TimeStamp,
|
---|
233 | IN UINT32 Identifier
|
---|
234 | );
|
---|
235 |
|
---|
236 | /**
|
---|
237 | Attempts to retrieve a performance measurement log entry from the performance measurement log.
|
---|
238 | It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
|
---|
239 | and then assign the Identifier with 0.
|
---|
240 |
|
---|
241 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
|
---|
242 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,
|
---|
243 | and the key for the second entry in the log is returned. If the performance log is empty,
|
---|
244 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
|
---|
245 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
|
---|
246 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
|
---|
247 | retrieved and an implementation specific non-zero key value that specifies the end of the performance
|
---|
248 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
|
---|
249 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,
|
---|
250 | the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
|
---|
251 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
|
---|
252 | If Handle is NULL, then ASSERT().
|
---|
253 | If Token is NULL, then ASSERT().
|
---|
254 | If Module is NULL, then ASSERT().
|
---|
255 | If StartTimeStamp is NULL, then ASSERT().
|
---|
256 | If EndTimeStamp is NULL, then ASSERT().
|
---|
257 | If Identifier is NULL, then ASSERT().
|
---|
258 |
|
---|
259 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
|
---|
260 | 0, then the first performance measurement log entry is retrieved.
|
---|
261 | On exit, the key of the next performance of entry entry.
|
---|
262 | @param Handle Pointer to environment specific context used to identify the component
|
---|
263 | being measured.
|
---|
264 | @param Token Pointer to a Null-terminated ASCII string that identifies the component
|
---|
265 | being measured.
|
---|
266 | @param Module Pointer to a Null-terminated ASCII string that identifies the module
|
---|
267 | being measured.
|
---|
268 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
|
---|
269 | was started.
|
---|
270 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
|
---|
271 | was ended.
|
---|
272 | @param Identifier Pointer to the 32-bit identifier that was recorded.
|
---|
273 |
|
---|
274 | @return The key for the next performance log entry (in general case).
|
---|
275 |
|
---|
276 | **/
|
---|
277 | UINTN
|
---|
278 | EFIAPI
|
---|
279 | GetPerformanceMeasurementEx (
|
---|
280 | IN UINTN LogEntryKey,
|
---|
281 | OUT CONST VOID **Handle,
|
---|
282 | OUT CONST CHAR8 **Token,
|
---|
283 | OUT CONST CHAR8 **Module,
|
---|
284 | OUT UINT64 *StartTimeStamp,
|
---|
285 | OUT UINT64 *EndTimeStamp,
|
---|
286 | OUT UINT32 *Identifier
|
---|
287 | );
|
---|
288 |
|
---|
289 | /**
|
---|
290 | Returns TRUE if the performance measurement macros are enabled.
|
---|
291 |
|
---|
292 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
|
---|
293 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
|
---|
294 |
|
---|
295 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
|
---|
296 | PcdPerformanceLibraryPropertyMask is set.
|
---|
297 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
|
---|
298 | PcdPerformanceLibraryPropertyMask is clear.
|
---|
299 |
|
---|
300 | **/
|
---|
301 | BOOLEAN
|
---|
302 | EFIAPI
|
---|
303 | PerformanceMeasurementEnabled (
|
---|
304 | VOID
|
---|
305 | );
|
---|
306 |
|
---|
307 | /**
|
---|
308 | Check whether the specified performance measurement can be logged.
|
---|
309 |
|
---|
310 | This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set
|
---|
311 | and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
|
---|
312 |
|
---|
313 | @param Type - Type of the performance measurement entry.
|
---|
314 |
|
---|
315 | @retval TRUE The performance measurement can be logged.
|
---|
316 | @retval FALSE The performance measurement can NOT be logged.
|
---|
317 |
|
---|
318 | **/
|
---|
319 | BOOLEAN
|
---|
320 | EFIAPI
|
---|
321 | LogPerformanceMeasurementEnabled (
|
---|
322 | IN CONST UINTN Type
|
---|
323 | );
|
---|
324 |
|
---|
325 | /**
|
---|
326 | Create performance record with event description.
|
---|
327 |
|
---|
328 | @param CallerIdentifier - Image handle or pointer to caller ID GUID
|
---|
329 | @param Guid - Pointer to a GUID.
|
---|
330 | Used for event signal perf and callback perf to cache the event guid.
|
---|
331 | @param String - Pointer to a string describing the measurement
|
---|
332 | @param Address - Pointer to a location in memory relevant to the measurement.
|
---|
333 | @param Identifier - Performance identifier describing the type of measurement.
|
---|
334 |
|
---|
335 | @retval RETURN_SUCCESS - Successfully created performance record
|
---|
336 | @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records
|
---|
337 | @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL
|
---|
338 | pointer or invalid Identifier.
|
---|
339 |
|
---|
340 | **/
|
---|
341 | RETURN_STATUS
|
---|
342 | EFIAPI
|
---|
343 | LogPerformanceMeasurement (
|
---|
344 | IN CONST VOID *CallerIdentifier OPTIONAL,
|
---|
345 | IN CONST VOID *Guid OPTIONAL,
|
---|
346 | IN CONST CHAR8 *String OPTIONAL,
|
---|
347 | IN UINT64 Address OPTIONAL,
|
---|
348 | IN UINT32 Identifier
|
---|
349 | );
|
---|
350 |
|
---|
351 | /**
|
---|
352 | Begin Macro to measure the performance of StartImage in core.
|
---|
353 |
|
---|
354 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
355 | and the BIT1 (disable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
356 | then LogPerformanceMeasurement() is called.
|
---|
357 |
|
---|
358 | **/
|
---|
359 | #define PERF_START_IMAGE_BEGIN(ModuleHandle) \
|
---|
360 | do { \
|
---|
361 | if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
|
---|
362 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \
|
---|
363 | } \
|
---|
364 | } while (FALSE)
|
---|
365 |
|
---|
366 | /**
|
---|
367 | End Macro to measure the performance of StartImage in core.
|
---|
368 |
|
---|
369 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
370 | and the BIT1 (disable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
371 | then LogPerformanceMeasurement() is called.
|
---|
372 |
|
---|
373 | **/
|
---|
374 | #define PERF_START_IMAGE_END(ModuleHandle) \
|
---|
375 | do { \
|
---|
376 | if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
|
---|
377 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \
|
---|
378 | } \
|
---|
379 | } while (FALSE)
|
---|
380 |
|
---|
381 | /**
|
---|
382 | Begin Macro to measure the performance of LoadImage in core.
|
---|
383 |
|
---|
384 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
385 | and the BIT2 (disable PERF_CORE_LOAD_IMAGE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
386 | then LogPerformanceMeasurement() is called.
|
---|
387 |
|
---|
388 | **/
|
---|
389 | #define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \
|
---|
390 | do { \
|
---|
391 | if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
|
---|
392 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \
|
---|
393 | } \
|
---|
394 | } while (FALSE)
|
---|
395 |
|
---|
396 | /**
|
---|
397 | End Macro to measure the performance of LoadImage in core.
|
---|
398 |
|
---|
399 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
400 | and the BIT2 (disable PERF_CORE_LOAD_IMAGE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
401 | then LogPerformanceMeasurement() is called.
|
---|
402 |
|
---|
403 | **/
|
---|
404 | #define PERF_LOAD_IMAGE_END(ModuleHandle) \
|
---|
405 | do { \
|
---|
406 | if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
|
---|
407 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \
|
---|
408 | } \
|
---|
409 | } while (FALSE)
|
---|
410 |
|
---|
411 | /**
|
---|
412 | Start Macro to measure the performance of DriverBinding Support in core.
|
---|
413 |
|
---|
414 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
415 | and the BIT3 (disable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
416 | then LogPerformanceMeasurement() is called.
|
---|
417 |
|
---|
418 | **/
|
---|
419 | #define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \
|
---|
420 | do { \
|
---|
421 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
|
---|
422 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \
|
---|
423 | } \
|
---|
424 | } while (FALSE)
|
---|
425 |
|
---|
426 | /**
|
---|
427 | End Macro to measure the performance of DriverBinding Support in core.
|
---|
428 |
|
---|
429 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
430 | and the BIT3 (disable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
431 | then LogPerformanceMeasurement() is called.
|
---|
432 |
|
---|
433 | **/
|
---|
434 | #define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \
|
---|
435 | do { \
|
---|
436 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
|
---|
437 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \
|
---|
438 | } \
|
---|
439 | } while (FALSE)
|
---|
440 |
|
---|
441 | /**
|
---|
442 | Begin Macro to measure the performance of DriverBinding Start in core.
|
---|
443 |
|
---|
444 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
445 | and the BIT4 (disable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
446 | then LogPerformanceMeasurement() is called.
|
---|
447 |
|
---|
448 | **/
|
---|
449 | #define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \
|
---|
450 | do { \
|
---|
451 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
|
---|
452 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \
|
---|
453 | } \
|
---|
454 | } while (FALSE)
|
---|
455 |
|
---|
456 | /**
|
---|
457 | End Macro to measure the performance of DriverBinding Start in core.
|
---|
458 |
|
---|
459 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
460 | and the BIT4 (disable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
461 | then LogPerformanceMeasurement() is called.
|
---|
462 |
|
---|
463 | **/
|
---|
464 | #define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \
|
---|
465 | do { \
|
---|
466 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
|
---|
467 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \
|
---|
468 | } \
|
---|
469 | } while (FALSE)
|
---|
470 |
|
---|
471 | /**
|
---|
472 | Start Macro to measure the performance of DriverBinding Stop in core.
|
---|
473 |
|
---|
474 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
475 | and the BIT5 (disable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
476 | then LogPerformanceMeasurement() is called.
|
---|
477 |
|
---|
478 | **/
|
---|
479 | #define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \
|
---|
480 | do { \
|
---|
481 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
|
---|
482 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \
|
---|
483 | } \
|
---|
484 | } while (FALSE)
|
---|
485 |
|
---|
486 | /**
|
---|
487 | End Macro to measure the performance of DriverBinding Stop in core.
|
---|
488 |
|
---|
489 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
490 | and the BIT5 (disable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
491 | then LogPerformanceMeasurement() is called.
|
---|
492 |
|
---|
493 | **/
|
---|
494 | #define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \
|
---|
495 | do { \
|
---|
496 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
|
---|
497 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \
|
---|
498 | } \
|
---|
499 | } while (FALSE)
|
---|
500 |
|
---|
501 | /**
|
---|
502 | Macro to measure the time from power-on to this macro execution.
|
---|
503 | It can be used to log a meaningful thing which happens at a time point.
|
---|
504 |
|
---|
505 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
506 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
507 | then LogPerformanceMeasurement() is called.
|
---|
508 |
|
---|
509 | **/
|
---|
510 | #define PERF_EVENT(EventString) \
|
---|
511 | do { \
|
---|
512 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
513 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \
|
---|
514 | } \
|
---|
515 | } while (FALSE)
|
---|
516 |
|
---|
517 | /**
|
---|
518 | Begin Macro to measure the performance of evnent signal behavior in any module.
|
---|
519 | The event guid will be passed with this macro.
|
---|
520 |
|
---|
521 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
522 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
523 | then LogPerformanceMeasurement() is called.
|
---|
524 |
|
---|
525 | **/
|
---|
526 | #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
|
---|
527 | do { \
|
---|
528 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
529 | LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
|
---|
530 | } \
|
---|
531 | } while (FALSE)
|
---|
532 |
|
---|
533 | /**
|
---|
534 | End Macro to measure the performance of evnent signal behavior in any module.
|
---|
535 | The event guid will be passed with this macro.
|
---|
536 |
|
---|
537 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
538 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
539 | then LogPerformanceMeasurement() is called.
|
---|
540 |
|
---|
541 | **/
|
---|
542 | #define PERF_EVENT_SIGNAL_END(EventGuid) \
|
---|
543 | do { \
|
---|
544 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
545 | LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
|
---|
546 | } \
|
---|
547 | } while (FALSE)
|
---|
548 |
|
---|
549 | /**
|
---|
550 | Begin Macro to measure the performance of a callback function in any module.
|
---|
551 | The event guid which trigger the callback function will be passed with this macro.
|
---|
552 |
|
---|
553 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
554 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
555 | then LogPerformanceMeasurement() is called.
|
---|
556 |
|
---|
557 | **/
|
---|
558 | #define PERF_CALLBACK_BEGIN(TriggerGuid) \
|
---|
559 | do { \
|
---|
560 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
561 | LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
|
---|
562 | } \
|
---|
563 | } while (FALSE)
|
---|
564 |
|
---|
565 | /**
|
---|
566 | End Macro to measure the performance of a callback function in any module.
|
---|
567 | The event guid which trigger the callback function will be passed with this macro.
|
---|
568 |
|
---|
569 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
570 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
571 | then LogPerformanceMeasurement() is called.
|
---|
572 |
|
---|
573 | **/
|
---|
574 | #define PERF_CALLBACK_END(TriggerGuid) \
|
---|
575 | do { \
|
---|
576 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
577 | LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
|
---|
578 | } \
|
---|
579 | } while (FALSE)
|
---|
580 |
|
---|
581 | /**
|
---|
582 | Begin Macro to measure the performance of a general function in any module.
|
---|
583 |
|
---|
584 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
585 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
586 | then LogPerformanceMeasurement() is called.
|
---|
587 |
|
---|
588 | **/
|
---|
589 | #define PERF_FUNCTION_BEGIN() \
|
---|
590 | do { \
|
---|
591 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
592 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
|
---|
593 | } \
|
---|
594 | } while (FALSE)
|
---|
595 |
|
---|
596 | /**
|
---|
597 | End Macro to measure the performance of a general function in any module.
|
---|
598 |
|
---|
599 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
600 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
601 | then LogPerformanceMeasurement() is called.
|
---|
602 |
|
---|
603 | **/
|
---|
604 | #define PERF_FUNCTION_END() \
|
---|
605 | do { \
|
---|
606 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
607 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
|
---|
608 | } \
|
---|
609 | } while (FALSE)
|
---|
610 |
|
---|
611 | /**
|
---|
612 | Begin Macro to measure the performance of a behavior within one module.
|
---|
613 |
|
---|
614 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
615 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
616 | then LogPerformanceMeasurement() is called.
|
---|
617 |
|
---|
618 | **/
|
---|
619 | #define PERF_INMODULE_BEGIN(MeasurementString) \
|
---|
620 | do { \
|
---|
621 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
622 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \
|
---|
623 | } \
|
---|
624 | } while (FALSE)
|
---|
625 |
|
---|
626 | /**
|
---|
627 | End Macro to measure the performance of a behavior within one module.
|
---|
628 |
|
---|
629 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
630 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
631 | then LogPerformanceMeasurement() is called.
|
---|
632 |
|
---|
633 | **/
|
---|
634 | #define PERF_INMODULE_END(MeasurementString) \
|
---|
635 | do { \
|
---|
636 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
637 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \
|
---|
638 | } \
|
---|
639 | } while (FALSE)
|
---|
640 |
|
---|
641 | /**
|
---|
642 | Begin Macro to measure the performance of a behavior in different modules.
|
---|
643 | Such as the performance of PEI phase, DXE phase, BDS phase.
|
---|
644 |
|
---|
645 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
646 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
647 | then LogPerformanceMeasurement() is called.
|
---|
648 |
|
---|
649 | **/
|
---|
650 | #define PERF_CROSSMODULE_BEGIN(MeasurementString) \
|
---|
651 | do { \
|
---|
652 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
653 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \
|
---|
654 | } \
|
---|
655 | } while (FALSE)
|
---|
656 |
|
---|
657 | /**
|
---|
658 | End Macro to measure the performance of a behavior in different modules.
|
---|
659 | Such as the performance of PEI phase, DXE phase, BDS phase.
|
---|
660 |
|
---|
661 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
662 | and the BIT6 (disable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set,
|
---|
663 | then LogPerformanceMeasurement() is called.
|
---|
664 |
|
---|
665 | **/
|
---|
666 | #define PERF_CROSSMODULE_END(MeasurementString) \
|
---|
667 | do { \
|
---|
668 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
|
---|
669 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \
|
---|
670 | } \
|
---|
671 | } while (FALSE)
|
---|
672 |
|
---|
673 | /**
|
---|
674 | Macro that calls EndPerformanceMeasurement().
|
---|
675 |
|
---|
676 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
677 | then EndPerformanceMeasurement() is called.
|
---|
678 |
|
---|
679 | **/
|
---|
680 | #define PERF_END(Handle, Token, Module, TimeStamp) \
|
---|
681 | do { \
|
---|
682 | if (PerformanceMeasurementEnabled ()) { \
|
---|
683 | EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
|
---|
684 | } \
|
---|
685 | } while (FALSE)
|
---|
686 |
|
---|
687 | /**
|
---|
688 | Macro that calls StartPerformanceMeasurement().
|
---|
689 |
|
---|
690 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
691 | then StartPerformanceMeasurement() is called.
|
---|
692 |
|
---|
693 | **/
|
---|
694 | #define PERF_START(Handle, Token, Module, TimeStamp) \
|
---|
695 | do { \
|
---|
696 | if (PerformanceMeasurementEnabled ()) { \
|
---|
697 | StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
|
---|
698 | } \
|
---|
699 | } while (FALSE)
|
---|
700 |
|
---|
701 | /**
|
---|
702 | Macro that calls EndPerformanceMeasurementEx().
|
---|
703 |
|
---|
704 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
705 | then EndPerformanceMeasurementEx() is called.
|
---|
706 |
|
---|
707 | **/
|
---|
708 | #define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) \
|
---|
709 | do { \
|
---|
710 | if (PerformanceMeasurementEnabled ()) { \
|
---|
711 | EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
|
---|
712 | } \
|
---|
713 | } while (FALSE)
|
---|
714 |
|
---|
715 | /**
|
---|
716 | Macro that calls StartPerformanceMeasurementEx().
|
---|
717 |
|
---|
718 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
719 | then StartPerformanceMeasurementEx() is called.
|
---|
720 |
|
---|
721 | **/
|
---|
722 | #define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) \
|
---|
723 | do { \
|
---|
724 | if (PerformanceMeasurementEnabled ()) { \
|
---|
725 | StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
|
---|
726 | } \
|
---|
727 | } while (FALSE)
|
---|
728 |
|
---|
729 | /**
|
---|
730 | Macro that marks the beginning of performance measurement source code.
|
---|
731 |
|
---|
732 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
733 | then this macro marks the beginning of source code that is included in a module.
|
---|
734 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.
|
---|
735 |
|
---|
736 | **/
|
---|
737 | #define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal
|
---|
738 |
|
---|
739 | /**
|
---|
740 | Macro that marks the end of performance measurement source code.
|
---|
741 |
|
---|
742 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
743 | then this macro marks the end of source code that is included in a module.
|
---|
744 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.
|
---|
745 |
|
---|
746 | **/
|
---|
747 | #define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)
|
---|
748 |
|
---|
749 | /**
|
---|
750 | Macro that declares a section of performance measurement source code.
|
---|
751 |
|
---|
752 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
|
---|
753 | then the source code specified by Expression is included in a module.
|
---|
754 | Otherwise, the source specified by Expression is not included in a module.
|
---|
755 |
|
---|
756 | @param Expression Performance measurement source code to include in a module.
|
---|
757 |
|
---|
758 | **/
|
---|
759 | #define PERF_CODE(Expression) \
|
---|
760 | PERF_CODE_BEGIN (); \
|
---|
761 | Expression \
|
---|
762 | PERF_CODE_END ()
|
---|
763 |
|
---|
764 | #endif
|
---|