]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to log the execution times and retrieve them later.\r |
fb3df220 | 3 | \r |
9df063a0 HT |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
50a64e5b | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
fb3df220 | 9 | \r |
50a64e5b | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
fb3df220 | 12 | \r |
fb3df220 | 13 | **/\r |
14 | \r | |
15 | #ifndef __PERFORMANCE_LIB_H__\r | |
16 | #define __PERFORMANCE_LIB_H__\r | |
17 | \r | |
fc30687f | 18 | ///\r |
19 | /// Performance library propery mask bits\r | |
20 | ///\r | |
fb3df220 | 21 | #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001\r |
22 | \r | |
23 | /**\r | |
24 | Creates a record for the beginning of a performance measurement. \r | |
25 | \r | |
26 | Creates a record that contains the Handle, Token, and Module.\r | |
27 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
28 | If TimeStamp is zero, then this function reads the current time stamp\r | |
29 | and adds that time stamp value to the record as the start time.\r | |
30 | \r | |
31 | @param Handle Pointer to environment specific context used\r | |
32 | to identify the component being measured.\r | |
33 | @param Token Pointer to a Null-terminated ASCII string\r | |
34 | that identifies the component being measured.\r | |
35 | @param Module Pointer to a Null-terminated ASCII string\r | |
36 | that identifies the module being measured.\r | |
37 | @param TimeStamp 64-bit time stamp.\r | |
38 | \r | |
39 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
40 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
8404146c | 41 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
fb3df220 | 42 | \r |
43 | **/\r | |
44 | RETURN_STATUS\r | |
45 | EFIAPI\r | |
46 | StartPerformanceMeasurement (\r | |
47 | IN CONST VOID *Handle, OPTIONAL\r | |
48 | IN CONST CHAR8 *Token, OPTIONAL\r | |
49 | IN CONST CHAR8 *Module, OPTIONAL\r | |
50 | IN UINT64 TimeStamp\r | |
51 | );\r | |
52 | \r | |
53 | /**\r | |
54 | Fills in the end time of a performance measurement. \r | |
55 | \r | |
56 | Looks up the record that matches Handle, Token, and Module.\r | |
57 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
58 | If the record is found and TimeStamp is not zero,\r | |
59 | then TimeStamp is added to the record as the end time.\r | |
60 | If the record is found and TimeStamp is zero, then this function reads\r | |
61 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
62 | If this function is called multiple times for the same record, then the end time is overwritten.\r | |
63 | \r | |
64 | @param Handle Pointer to environment specific context used\r | |
65 | to identify the component being measured.\r | |
66 | @param Token Pointer to a Null-terminated ASCII string\r | |
67 | that identifies the component being measured.\r | |
68 | @param Module Pointer to a Null-terminated ASCII string\r | |
69 | that identifies the module being measured.\r | |
70 | @param TimeStamp 64-bit time stamp.\r | |
71 | \r | |
72 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
73 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
8404146c | 74 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
fb3df220 | 75 | \r |
76 | **/\r | |
77 | RETURN_STATUS\r | |
78 | EFIAPI\r | |
79 | EndPerformanceMeasurement (\r | |
80 | IN CONST VOID *Handle, OPTIONAL\r | |
81 | IN CONST CHAR8 *Token, OPTIONAL\r | |
82 | IN CONST CHAR8 *Module, OPTIONAL\r | |
83 | IN UINT64 TimeStamp\r | |
84 | );\r | |
85 | \r | |
86 | /**\r | |
87 | Attempts to retrieve a performance measurement log entry from the performance measurement log. \r | |
88 | \r | |
89 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r | |
90 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
91 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
92 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
93 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
94 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
95 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
96 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
97 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
98 | the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r | |
99 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
100 | If Handle is NULL, then ASSERT().\r | |
101 | If Token is NULL, then ASSERT().\r | |
102 | If Module is NULL, then ASSERT().\r | |
103 | If StartTimeStamp is NULL, then ASSERT().\r | |
104 | If EndTimeStamp is NULL, then ASSERT().\r | |
105 | \r | |
106 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r | |
107 | 0, then the first performance measurement log entry is retrieved.\r | |
108 | On exit, the key of the next performance lof entry entry.\r | |
109 | @param Handle Pointer to environment specific context used to identify the component\r | |
110 | being measured. \r | |
111 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r | |
112 | being measured. \r | |
113 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r | |
114 | being measured.\r | |
115 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
116 | was started.\r | |
117 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
118 | was ended.\r | |
119 | \r | |
120 | @return The key for the next performance log entry (in general case).\r | |
121 | \r | |
122 | **/\r | |
123 | UINTN\r | |
124 | EFIAPI\r | |
125 | GetPerformanceMeasurement (\r | |
126 | IN UINTN LogEntryKey, \r | |
127 | OUT CONST VOID **Handle,\r | |
128 | OUT CONST CHAR8 **Token,\r | |
129 | OUT CONST CHAR8 **Module,\r | |
130 | OUT UINT64 *StartTimeStamp,\r | |
131 | OUT UINT64 *EndTimeStamp\r | |
132 | );\r | |
133 | \r | |
134 | /**\r | |
135 | Returns TRUE if the performance measurement macros are enabled. \r | |
136 | \r | |
137 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
138 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r | |
139 | \r | |
140 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
141 | PcdPerformanceLibraryPropertyMask is set.\r | |
142 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
143 | PcdPerformanceLibraryPropertyMask is clear.\r | |
144 | \r | |
145 | **/\r | |
146 | BOOLEAN\r | |
147 | EFIAPI\r | |
148 | PerformanceMeasurementEnabled (\r | |
149 | VOID\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Macro that calls EndPerformanceMeasurement().\r | |
154 | \r | |
155 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
156 | then EndPerformanceMeasurement() is called.\r | |
157 | \r | |
158 | **/\r | |
159 | #define PERF_END(Handle, Token, Module, TimeStamp) \\r | |
160 | do { \\r | |
161 | if (PerformanceMeasurementEnabled ()) { \\r | |
162 | EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
163 | } \\r | |
164 | } while (FALSE)\r | |
165 | \r | |
166 | /**\r | |
167 | Macro that calls StartPerformanceMeasurement().\r | |
168 | \r | |
169 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
170 | then StartPerformanceMeasurement() is called.\r | |
171 | \r | |
172 | **/\r | |
173 | #define PERF_START(Handle, Token, Module, TimeStamp) \\r | |
174 | do { \\r | |
175 | if (PerformanceMeasurementEnabled ()) { \\r | |
176 | StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
177 | } \\r | |
178 | } while (FALSE)\r | |
179 | \r | |
180 | /**\r | |
181 | Macro that marks the beginning of performance measurement source code.\r | |
182 | \r | |
183 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
184 | then this macro marks the beginning of source code that is included in a module.\r | |
185 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
186 | \r | |
187 | **/\r | |
188 | #define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal\r | |
189 | \r | |
190 | /**\r | |
191 | Macro that marks the end of performance measurement source code.\r | |
192 | \r | |
193 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
194 | then this macro marks the end of source code that is included in a module.\r | |
195 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
196 | \r | |
197 | **/\r | |
198 | #define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)\r | |
199 | \r | |
200 | /**\r | |
201 | Macro that declares a section of performance measurement source code.\r | |
202 | \r | |
203 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
204 | then the source code specified by Expression is included in a module.\r | |
205 | Otherwise, the source specified by Expression is not included in a module.\r | |
206 | \r | |
207 | @param Expression Performance measurement source code to include in a module.\r | |
208 | \r | |
209 | **/\r | |
210 | #define PERF_CODE(Expression) \\r | |
211 | PERF_CODE_BEGIN (); \\r | |
212 | Expression \\r | |
213 | PERF_CODE_END ()\r | |
214 | \r | |
215 | \r | |
216 | #endif\r |