]>
Commit | Line | Data |
---|---|---|
c06ad33e | 1 | /** @file\r |
86da563d ED |
2 | Declarations of objects defined internally to the Dp Application.\r |
3 | \r | |
4 | Declarations of data and functions which are private to the Dp application.\r | |
5 | This file should never be referenced by anything other than components of the\r | |
6 | Dp application. In addition to global data, function declarations for\r | |
7 | DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\r | |
8 | \r | |
13935109 | 9 | Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r |
3e9de670 | 10 | (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r |
86da563d ED |
11 | This program and the accompanying materials\r |
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 | |
c06ad33e | 18 | **/\r |
9dd74618 ED |
19 | #ifndef _DP_INTELNAL_H_\r |
20 | #define _DP_INTELNAL_H_\r | |
a2daf8db SZ |
21 | \r |
22 | #define DP_GAUGE_STRING_LENGTH 36\r | |
23 | \r | |
c06ad33e | 24 | //\r |
25 | /// Module-Global Variables\r | |
9dd74618 | 26 | ///@{\r |
c06ad33e | 27 | extern EFI_HII_HANDLE gHiiHandle;\r |
28 | extern CHAR16 *mPrintTokenBuffer;\r | |
a2daf8db SZ |
29 | extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r |
30 | extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r | |
c06ad33e | 31 | extern UINT64 mInterestThreshold;\r |
0b84f444 | 32 | extern BOOLEAN mShowId;\r |
c06ad33e | 33 | \r |
aec905b7 | 34 | extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.\r |
c06ad33e | 35 | \r |
36 | /// Timer Specific Information.\r | |
37 | extern TIMER_INFO TimerInfo;\r | |
38 | \r | |
39 | /// Items for which to gather cumulative statistics.\r | |
40 | extern PERF_CUM_DATA CumData[];\r | |
41 | \r | |
42 | /// Number of items for which we are gathering cumulative statistics.\r | |
43 | extern UINT32 const NumCum;\r | |
44 | \r | |
9dd74618 | 45 | ///@}\r |
c06ad33e | 46 | \r |
f97c2415 ED |
47 | /** \r |
48 | Calculate an event's duration in timer ticks.\r | |
49 | \r | |
50 | Given the count direction and the event's start and end timer values,\r | |
51 | calculate the duration of the event in timer ticks. Information for\r | |
52 | the current measurement is pointed to by the parameter.\r | |
53 | \r | |
54 | If the measurement's start time is 1, it indicates that the developer\r | |
55 | is indicating that the measurement began at the release of reset.\r | |
56 | The start time is adjusted to the timer's starting count before performing\r | |
57 | the elapsed time calculation.\r | |
58 | \r | |
59 | The calculated duration, in ticks, is the absolute difference between\r | |
60 | the measurement's ending and starting counts.\r | |
61 | \r | |
62 | @param Measurement Pointer to a MEASUREMENT_RECORD structure containing\r | |
63 | data for the current measurement.\r | |
64 | \r | |
65 | @return The 64-bit duration of the event.\r | |
c06ad33e | 66 | **/\r |
67 | UINT64\r | |
68 | GetDuration (\r | |
69 | IN OUT MEASUREMENT_RECORD *Measurement\r | |
cbdf19a5 | 70 | );\r |
c06ad33e | 71 | \r |
f97c2415 ED |
72 | /** \r |
73 | Determine whether the Measurement record is for an EFI Phase.\r | |
74 | \r | |
75 | The Token and Module members of the measurement record are checked.\r | |
76 | Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r | |
77 | \r | |
78 | @param[in] Measurement A pointer to the Measurement record to test.\r | |
79 | \r | |
80 | @retval TRUE The measurement record is for an EFI Phase.\r | |
81 | @retval FALSE The measurement record is NOT for an EFI Phase.\r | |
c06ad33e | 82 | **/\r |
83 | BOOLEAN\r | |
84 | IsPhase(\r | |
85 | IN MEASUREMENT_RECORD *Measurement\r | |
cbdf19a5 | 86 | );\r |
c06ad33e | 87 | \r |
f97c2415 ED |
88 | /** \r |
89 | Get the file name portion of the Pdb File Name.\r | |
90 | \r | |
91 | The portion of the Pdb File Name between the last backslash and\r | |
92 | either a following period or the end of the string is converted\r | |
93 | to Unicode and copied into UnicodeBuffer. The name is truncated,\r | |
94 | if necessary, to ensure that UnicodeBuffer is not overrun.\r | |
95 | \r | |
96 | @param[in] PdbFileName Pdb file name.\r | |
97 | @param[out] UnicodeBuffer The resultant Unicode File Name.\r | |
98 | \r | |
c06ad33e | 99 | **/\r |
100 | VOID\r | |
101 | GetShortPdbFileName (\r | |
102 | IN CHAR8 *PdbFileName,\r | |
103 | OUT CHAR16 *UnicodeBuffer\r | |
cbdf19a5 | 104 | );\r |
c06ad33e | 105 | \r |
f97c2415 ED |
106 | /** \r |
107 | Get a human readable name for an image handle.\r | |
a2daf8db SZ |
108 | The following methods will be tried orderly:\r |
109 | 1. Image PDB\r | |
110 | 2. ComponentName2 protocol\r | |
111 | 3. FFS UI section\r | |
112 | 4. Image GUID\r | |
113 | 5. Image DevicePath\r | |
114 | 6. Unknown Driver Name\r | |
f97c2415 ED |
115 | \r |
116 | @param[in] Handle\r | |
117 | \r | |
118 | @post The resulting Unicode name string is stored in the\r | |
119 | mGaugeString global array.\r | |
120 | \r | |
c06ad33e | 121 | **/\r |
122 | VOID\r | |
123 | GetNameFromHandle (\r | |
124 | IN EFI_HANDLE Handle\r | |
cbdf19a5 | 125 | );\r |
c06ad33e | 126 | \r |
f97c2415 ED |
127 | /** \r |
128 | Calculate the Duration in microseconds.\r | |
129 | \r | |
130 | Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r | |
131 | multiplying the result by 1000, in order to maintain precision. Since Duration is\r | |
132 | a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r | |
133 | \r | |
134 | The time is calculated as (Duration * 1000) / Timer_Frequency.\r | |
135 | \r | |
136 | @param[in] Duration The event duration in timer ticks.\r | |
137 | \r | |
138 | @return A 64-bit value which is the Elapsed time in microseconds.\r | |
c06ad33e | 139 | **/\r |
140 | UINT64\r | |
141 | DurationInMicroSeconds (\r | |
142 | IN UINT64 Duration\r | |
cbdf19a5 | 143 | );\r |
c06ad33e | 144 | \r |
f97c2415 ED |
145 | /** \r |
146 | Formatted Print using a Hii Token to reference the localized format string.\r | |
147 | \r | |
148 | @param[in] Token A HII token associated with a localized Unicode string.\r | |
149 | @param[in] ... The variable argument list.\r | |
150 | \r | |
151 | @return The number of characters converted by UnicodeVSPrint().\r | |
152 | \r | |
c06ad33e | 153 | **/\r |
154 | UINTN\r | |
f85acc22 | 155 | EFIAPI\r |
c06ad33e | 156 | PrintToken (\r |
157 | IN UINT16 Token,\r | |
158 | ...\r | |
cbdf19a5 | 159 | );\r |
c06ad33e | 160 | \r |
f97c2415 ED |
161 | /** \r |
162 | Get index of Measurement Record's match in the CumData array.\r | |
163 | \r | |
164 | If the Measurement's Token value matches a Token in one of the CumData\r | |
165 | records, the index of the matching record is returned. The returned\r | |
166 | index is a signed value so that negative values can indicate that\r | |
167 | the Measurement didn't match any entry in the CumData array.\r | |
168 | \r | |
169 | @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.\r | |
170 | \r | |
171 | @retval <0 Token is not in the CumData array.\r | |
172 | @retval >=0 Return value is the index into CumData where Token is found.\r | |
c06ad33e | 173 | **/\r |
174 | INTN\r | |
175 | GetCumulativeItem(\r | |
176 | IN MEASUREMENT_RECORD *Measurement\r | |
cbdf19a5 | 177 | );\r |
c06ad33e | 178 | \r |
f97c2415 ED |
179 | /** \r |
180 | Collect verbose statistics about the logged performance measurements.\r | |
181 | \r | |
182 | General Summary information for all Trace measurements is gathered and\r | |
183 | stored within the SummaryData structure. This information is both\r | |
184 | used internally by subsequent reporting functions, and displayed\r | |
185 | at the end of verbose reports.\r | |
186 | \r | |
187 | @pre The SummaryData and CumData structures must be initialized\r | |
188 | prior to calling this function.\r | |
189 | \r | |
190 | @post The SummaryData and CumData structures contain statistics for the\r | |
191 | current performance logs.\r | |
d28f77df CS |
192 | \r |
193 | @param[in, out] CustomCumulativeData The pointer to the custom cumulative data.\r | |
194 | \r | |
c06ad33e | 195 | **/\r |
196 | VOID\r | |
197 | GatherStatistics(\r | |
d28f77df | 198 | IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r |
cbdf19a5 | 199 | );\r |
c06ad33e | 200 | \r |
f97c2415 ED |
201 | /** \r |
202 | Gather and print ALL Trace Records.\r | |
203 | \r | |
204 | Displays all "interesting" Trace measurements in order.<BR>\r | |
205 | The number of records displayed is controlled by:\r | |
206 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
207 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
208 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
209 | displayed.\r | |
210 | \r | |
211 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
212 | The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r | |
213 | They must not be in use by a calling function.\r | |
214 | \r | |
215 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
216 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
217 | \r | |
3e9de670 CS |
218 | @retval EFI_SUCCESS The operation was successful.\r |
219 | @retval EFI_ABORTED The user aborts the operation.\r | |
220 | @return Others from a call to gBS->LocateHandleBuffer().\r | |
c06ad33e | 221 | **/\r |
3e9de670 | 222 | EFI_STATUS\r |
c06ad33e | 223 | DumpAllTrace(\r |
224 | IN UINTN Limit,\r | |
225 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 226 | );\r |
c06ad33e | 227 | \r |
f97c2415 ED |
228 | /** \r |
229 | Gather and print Raw Trace Records.\r | |
230 | \r | |
231 | All Trace measurements with a duration greater than or equal to\r | |
232 | mInterestThreshold are printed without interpretation.\r | |
233 | \r | |
234 | The number of records displayed is controlled by:\r | |
235 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
236 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
237 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
238 | displayed.\r | |
239 | \r | |
240 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
241 | \r | |
242 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
243 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
3e9de670 CS |
244 | \r |
245 | @retval EFI_SUCCESS The operation was successful.\r | |
246 | @retval EFI_ABORTED The user aborts the operation.\r | |
c06ad33e | 247 | **/\r |
3e9de670 | 248 | EFI_STATUS\r |
c06ad33e | 249 | DumpRawTrace(\r |
250 | IN UINTN Limit,\r | |
251 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 252 | );\r |
c06ad33e | 253 | \r |
f97c2415 ED |
254 | /** \r |
255 | Gather and print Major Phase metrics.\r | |
256 | \r | |
c06ad33e | 257 | **/\r |
258 | VOID\r | |
259 | ProcessPhases(\r | |
13935109 | 260 | VOID\r |
cbdf19a5 | 261 | );\r |
c06ad33e | 262 | \r |
263 | \r | |
f97c2415 ED |
264 | /** \r |
265 | Gather and print Handle data.\r | |
266 | \r | |
267 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
3e9de670 CS |
268 | \r |
269 | @retval EFI_SUCCESS The operation was successful.\r | |
270 | @retval EFI_ABORTED The user aborts the operation.\r | |
271 | @return Others from a call to gBS->LocateHandleBuffer().\r | |
c06ad33e | 272 | **/\r |
273 | EFI_STATUS\r | |
274 | ProcessHandles(\r | |
275 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 276 | );\r |
c06ad33e | 277 | \r |
278 | \r | |
f97c2415 ED |
279 | /** \r |
280 | Gather and print PEIM data.\r | |
281 | \r | |
282 | Only prints complete PEIM records\r | |
283 | \r | |
3e9de670 CS |
284 | @retval EFI_SUCCESS The operation was successful.\r |
285 | @retval EFI_ABORTED The user aborts the operation.\r | |
c06ad33e | 286 | **/\r |
3e9de670 | 287 | EFI_STATUS\r |
c06ad33e | 288 | ProcessPeims(\r |
289 | VOID\r | |
cbdf19a5 | 290 | );\r |
c06ad33e | 291 | \r |
f97c2415 ED |
292 | /** \r |
293 | Gather and print global data.\r | |
294 | \r | |
295 | Strips out incomplete or "Execution Phase" records\r | |
296 | Only prints records where Handle is NULL\r | |
297 | Increment TIndex for every record, even skipped ones, so that we have an\r | |
298 | indication of every measurement record taken.\r | |
299 | \r | |
3e9de670 CS |
300 | @retval EFI_SUCCESS The operation was successful.\r |
301 | @retval EFI_ABORTED The user aborts the operation.\r | |
c06ad33e | 302 | **/\r |
3e9de670 | 303 | EFI_STATUS\r |
c06ad33e | 304 | ProcessGlobal(\r |
305 | VOID\r | |
cbdf19a5 | 306 | );\r |
c06ad33e | 307 | \r |
f97c2415 ED |
308 | /** \r |
309 | Gather and print cumulative data.\r | |
310 | \r | |
311 | Traverse the measurement records and:<BR>\r | |
312 | For each record with a Token listed in the CumData array:<BR>\r | |
313 | - Update the instance count and the total, minimum, and maximum durations.\r | |
314 | Finally, print the gathered cumulative statistics.\r | |
d28f77df CS |
315 | \r |
316 | @param[in] CustomCumulativeData The pointer to the custom cumulative data.\r | |
f97c2415 | 317 | \r |
c06ad33e | 318 | **/\r |
319 | VOID\r | |
320 | ProcessCumulative(\r | |
d28f77df | 321 | IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r |
cbdf19a5 | 322 | );\r |
c06ad33e | 323 | \r |
f97c2415 ED |
324 | /** \r |
325 | Gather and print ALL Profiling Records.\r | |
326 | \r | |
327 | Displays all "interesting" Profile measurements in order.\r | |
328 | The number of records displayed is controlled by:\r | |
329 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
330 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
331 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
332 | displayed.\r | |
333 | \r | |
334 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
335 | The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r | |
336 | They must not be in use by a calling function.\r | |
337 | \r | |
338 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
339 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
340 | \r | |
c06ad33e | 341 | **/\r |
342 | VOID\r | |
343 | DumpAllProfile(\r | |
344 | IN UINTN Limit,\r | |
345 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 346 | );\r |
c06ad33e | 347 | \r |
f97c2415 ED |
348 | /** \r |
349 | Gather and print Raw Profile Records.\r | |
350 | \r | |
351 | All Profile measurements with a duration greater than or equal to\r | |
352 | mInterestThreshold are printed without interpretation.\r | |
353 | \r | |
354 | The number of records displayed is controlled by:\r | |
355 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
356 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
357 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
358 | displayed.\r | |
359 | \r | |
360 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
361 | \r | |
362 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
363 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
364 | \r | |
c06ad33e | 365 | **/\r |
366 | VOID\r | |
367 | DumpRawProfile(\r | |
368 | IN UINTN Limit,\r | |
369 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 370 | );\r |
a2daf8db SZ |
371 | \r |
372 | /**\r | |
373 | Wrap original FreePool to check NULL pointer first.\r | |
374 | \r | |
375 | @param[in] Buffer The pointer to the buffer to free.\r | |
376 | \r | |
377 | **/\r | |
378 | VOID\r | |
379 | SafeFreePool (\r | |
380 | IN VOID *Buffer\r | |
381 | );\r | |
382 | \r | |
9dd74618 | 383 | #endif\r |