]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/PerformanceLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Library / PerformanceLib.h
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 /**
309 Check whether the specified performance measurement can be logged.
310
311 This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set
312 and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
313
314 @param Type - Type of the performance measurement entry.
315
316 @retval TRUE The performance measurement can be logged.
317 @retval FALSE The performance measurement can NOT be logged.
318
319 **/
320 BOOLEAN
321 EFIAPI
322 LogPerformanceMeasurementEnabled (
323 IN CONST UINTN Type
324 );
325
326 /**
327 Create performance record with event description.
328
329 @param CallerIdentifier - Image handle or pointer to caller ID GUID
330 @param Guid - Pointer to a GUID.
331 Used for event signal perf and callback perf to cache the event guid.
332 @param String - Pointer to a string describing the measurement
333 @param Address - Pointer to a location in memory relevant to the measurement.
334 @param Identifier - Performance identifier describing the type of measurement.
335
336 @retval RETURN_SUCCESS - Successfully created performance record
337 @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records
338 @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL
339 pointer or invalid Identifier.
340
341 **/
342 RETURN_STATUS
343 EFIAPI
344 LogPerformanceMeasurement (
345 IN CONST VOID *CallerIdentifier, OPTIONAL
346 IN CONST VOID *Guid, OPTIONAL
347 IN CONST CHAR8 *String, OPTIONAL
348 IN UINT64 Address, OPTIONAL
349 IN UINT32 Identifier
350 );
351
352 /**
353 Begin Macro to measure the performance of StartImage in core.
354
355 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
356 and the BIT1(dsiable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryPropertyMask is not set.
357 then LogPerformanceMeasurement() is called.
358
359 **/
360 #define PERF_START_IMAGE_BEGIN(ModuleHandle) \
361 do { \
362 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
363 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \
364 } \
365 } while (FALSE)
366
367 /**
368 End Macro to measure the performance of StartImage in core.
369
370 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
371 and the BIT1 (dsiable PERF_CORE_START_IMAGE)of PcdPerformanceLibraryPropertyMask is not set.
372 then LogPerformanceMeasurement() is called.
373
374 **/
375 #define PERF_START_IMAGE_END(ModuleHandle) \
376 do { \
377 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
378 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \
379 } \
380 } while (FALSE)
381
382 /**
383 Begin Macro to measure the performance of LoadImage in core.
384
385 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
386 and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.
387 then LogPerformanceMeasurement() is called.
388
389 **/
390 #define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \
391 do { \
392 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
393 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \
394 } \
395 } while (FALSE)
396
397 /**
398 End Macro to measure the performance of LoadImage in core.
399
400 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
401 and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.
402 then LogPerformanceMeasurement() is called.
403
404 **/
405 #define PERF_LOAD_IMAGE_END(ModuleHandle) \
406 do { \
407 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
408 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \
409 } \
410 } while (FALSE)
411
412 /**
413 Start Macro to measure the performance of DriverBinding Support in core.
414
415 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
416 and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.
417 then LogPerformanceMeasurement() is called.
418
419 **/
420 #define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \
421 do { \
422 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
423 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \
424 } \
425 } while (FALSE)
426
427 /**
428 End Macro to measure the performance of DriverBinding Support in core.
429
430 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
431 and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.
432 then LogPerformanceMeasurement() is called.
433
434 **/
435 #define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \
436 do { \
437 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
438 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \
439 } \
440 } while (FALSE)
441
442 /**
443 Begin Macro to measure the performance of DriverBinding Start in core.
444
445 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
446 and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.
447 then LogPerformanceMeasurement() is called.
448
449 **/
450 #define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \
451 do { \
452 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
453 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \
454 } \
455 } while (FALSE)
456
457 /**
458 End Macro to measure the performance of DriverBinding Start in core.
459
460 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
461 and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.
462 then LogPerformanceMeasurement() is called.
463
464 **/
465 #define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \
466 do { \
467 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
468 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \
469 } \
470 } while (FALSE)
471
472 /**
473 Start Macro to measure the performance of DriverBinding Stop in core.
474
475 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
476 and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.
477 then LogPerformanceMeasurement() is called.
478
479 **/
480 #define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \
481 do { \
482 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
483 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \
484 } \
485 } while (FALSE)
486
487 /**
488 End Macro to measure the performance of DriverBinding Stop in core.
489
490 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
491 and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.
492 then LogPerformanceMeasurement() is called.
493
494 **/
495 #define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \
496 do { \
497 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
498 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \
499 } \
500 } while (FALSE)
501
502 /**
503 Macro to measure the time from power-on to this macro execution.
504 It can be used to log a meaningful thing which happens at a time point.
505
506 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
507 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
508 then LogPerformanceMeasurement() is called.
509
510 **/
511 #define PERF_EVENT(EventString) \
512 do { \
513 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
514 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \
515 } \
516 } while (FALSE)
517
518 /**
519 Begin Macro to measure the perofrmance of evnent signal behavior in any module.
520 The event guid will be passed with this macro.
521
522 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
523 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
524 then LogPerformanceMeasurement() is called.
525
526 **/
527 #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
528 do { \
529 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
530 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
531 } \
532 } while (FALSE)
533
534 /**
535 End Macro to measure the perofrmance of evnent signal behavior in any module.
536 The event guid will be passed with this macro.
537
538 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
539 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
540 then LogPerformanceMeasurement() is called.
541
542 **/
543 #define PERF_EVENT_SIGNAL_END(EventGuid) \
544 do { \
545 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
546 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
547 } \
548 } while (FALSE)
549
550 /**
551 Begin Macro to measure the perofrmance of a callback function in any module.
552 The event guid which trigger the callback function will be passed with this macro.
553
554 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
555 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
556 then LogPerformanceMeasurement() is called.
557
558 **/
559 #define PERF_CALLBACK_BEGIN(TriggerGuid) \
560 do { \
561 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
562 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
563 } \
564 } while (FALSE)
565
566 /**
567 End Macro to measure the perofrmance of a callback function in any module.
568 The event guid which trigger the callback function will be passed with this macro.
569
570 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
571 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
572 then LogPerformanceMeasurement() is called.
573
574 **/
575 #define PERF_CALLBACK_END(TriggerGuid) \
576 do { \
577 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
578 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
579 } \
580 } while (FALSE)
581
582 /**
583 Begin Macro to measure the perofrmance of a general function in any module.
584
585 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
586 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
587 then LogPerformanceMeasurement() is called.
588
589 **/
590 #define PERF_FUNCTION_BEGIN() \
591 do { \
592 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
593 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
594 } \
595 } while (FALSE)
596
597 /**
598 End Macro to measure the perofrmance of a general function in any module.
599
600 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
601 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
602 then LogPerformanceMeasurement() is called.
603
604 **/
605 #define PERF_FUNCTION_END() \
606 do { \
607 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
608 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
609 } \
610 } while (FALSE)
611
612 /**
613 Begin Macro to measure the perofrmance of a behavior within one module.
614
615 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
616 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
617 then LogPerformanceMeasurement() is called.
618
619 **/
620 #define PERF_INMODULE_BEGIN(MeasurementString) \
621 do { \
622 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
623 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \
624 } \
625 } while (FALSE)
626
627 /**
628 End Macro to measure the perofrmance of a behavior within one module.
629
630 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
631 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
632 then LogPerformanceMeasurement() is called.
633
634 **/
635 #define PERF_INMODULE_END(MeasurementString) \
636 do { \
637 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
638 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \
639 } \
640 } while (FALSE)
641
642 /**
643 Begin Macro to measure the perofrmance of a behavior in different modules.
644 Such as the performance of PEI phase, DXE phase, BDS phase.
645
646 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
647 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
648 then LogPerformanceMeasurement() is called.
649
650 **/
651 #define PERF_CROSSMODULE_BEGIN(MeasurementString) \
652 do { \
653 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
654 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \
655 } \
656 } while (FALSE)
657
658 /**
659 End Macro to measure the perofrmance of a behavior in different modules.
660 Such as the performance of PEI phase, DXE phase, BDS phase.
661
662 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
663 and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.
664 then LogPerformanceMeasurement() is called.
665
666 **/
667 #define PERF_CROSSMODULE_END(MeasurementString) \
668 do { \
669 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
670 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \
671 } \
672 } while (FALSE)
673
674 /**
675 Macro that calls EndPerformanceMeasurement().
676
677 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
678 then EndPerformanceMeasurement() is called.
679
680 **/
681 #define PERF_END(Handle, Token, Module, TimeStamp) \
682 do { \
683 if (PerformanceMeasurementEnabled ()) { \
684 EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
685 } \
686 } while (FALSE)
687
688 /**
689 Macro that calls StartPerformanceMeasurement().
690
691 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
692 then StartPerformanceMeasurement() is called.
693
694 **/
695 #define PERF_START(Handle, Token, Module, TimeStamp) \
696 do { \
697 if (PerformanceMeasurementEnabled ()) { \
698 StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
699 } \
700 } while (FALSE)
701
702 /**
703 Macro that calls EndPerformanceMeasurementEx().
704
705 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
706 then EndPerformanceMeasurementEx() is called.
707
708 **/
709 #define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) \
710 do { \
711 if (PerformanceMeasurementEnabled ()) { \
712 EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
713 } \
714 } while (FALSE)
715
716 /**
717 Macro that calls StartPerformanceMeasurementEx().
718
719 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
720 then StartPerformanceMeasurementEx() is called.
721
722 **/
723 #define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) \
724 do { \
725 if (PerformanceMeasurementEnabled ()) { \
726 StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
727 } \
728 } while (FALSE)
729
730 /**
731 Macro that marks the beginning of performance measurement source code.
732
733 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
734 then this macro marks the beginning of source code that is included in a module.
735 Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.
736
737 **/
738 #define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal
739
740 /**
741 Macro that marks the end of performance measurement source code.
742
743 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
744 then this macro marks the end of source code that is included in a module.
745 Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.
746
747 **/
748 #define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)
749
750 /**
751 Macro that declares a section of performance measurement source code.
752
753 If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,
754 then the source code specified by Expression is included in a module.
755 Otherwise, the source specified by Expression is not included in a module.
756
757 @param Expression Performance measurement source code to include in a module.
758
759 **/
760 #define PERF_CODE(Expression) \
761 PERF_CODE_BEGIN (); \
762 Expression \
763 PERF_CODE_END ()
764
765
766 #endif