]>
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 | |
f85acc22 | 9 | Copyright (c) 2009 - 2014, 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 | |
257 | @param[in] Ticker The timer value for the END of Shell phase\r | |
258 | \r | |
c06ad33e | 259 | **/\r |
260 | VOID\r | |
261 | ProcessPhases(\r | |
262 | IN UINT64 Ticker\r | |
cbdf19a5 | 263 | );\r |
c06ad33e | 264 | \r |
265 | \r | |
f97c2415 ED |
266 | /** \r |
267 | Gather and print Handle data.\r | |
268 | \r | |
269 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
3e9de670 CS |
270 | \r |
271 | @retval EFI_SUCCESS The operation was successful.\r | |
272 | @retval EFI_ABORTED The user aborts the operation.\r | |
273 | @return Others from a call to gBS->LocateHandleBuffer().\r | |
c06ad33e | 274 | **/\r |
275 | EFI_STATUS\r | |
276 | ProcessHandles(\r | |
277 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 278 | );\r |
c06ad33e | 279 | \r |
280 | \r | |
f97c2415 ED |
281 | /** \r |
282 | Gather and print PEIM data.\r | |
283 | \r | |
284 | Only prints complete PEIM records\r | |
285 | \r | |
3e9de670 CS |
286 | @retval EFI_SUCCESS The operation was successful.\r |
287 | @retval EFI_ABORTED The user aborts the operation.\r | |
c06ad33e | 288 | **/\r |
3e9de670 | 289 | EFI_STATUS\r |
c06ad33e | 290 | ProcessPeims(\r |
291 | VOID\r | |
cbdf19a5 | 292 | );\r |
c06ad33e | 293 | \r |
f97c2415 ED |
294 | /** \r |
295 | Gather and print global data.\r | |
296 | \r | |
297 | Strips out incomplete or "Execution Phase" records\r | |
298 | Only prints records where Handle is NULL\r | |
299 | Increment TIndex for every record, even skipped ones, so that we have an\r | |
300 | indication of every measurement record taken.\r | |
301 | \r | |
3e9de670 CS |
302 | @retval EFI_SUCCESS The operation was successful.\r |
303 | @retval EFI_ABORTED The user aborts the operation.\r | |
c06ad33e | 304 | **/\r |
3e9de670 | 305 | EFI_STATUS\r |
c06ad33e | 306 | ProcessGlobal(\r |
307 | VOID\r | |
cbdf19a5 | 308 | );\r |
c06ad33e | 309 | \r |
f97c2415 ED |
310 | /** \r |
311 | Gather and print cumulative data.\r | |
312 | \r | |
313 | Traverse the measurement records and:<BR>\r | |
314 | For each record with a Token listed in the CumData array:<BR>\r | |
315 | - Update the instance count and the total, minimum, and maximum durations.\r | |
316 | Finally, print the gathered cumulative statistics.\r | |
d28f77df CS |
317 | \r |
318 | @param[in] CustomCumulativeData The pointer to the custom cumulative data.\r | |
f97c2415 | 319 | \r |
c06ad33e | 320 | **/\r |
321 | VOID\r | |
322 | ProcessCumulative(\r | |
d28f77df | 323 | IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r |
cbdf19a5 | 324 | );\r |
c06ad33e | 325 | \r |
f97c2415 ED |
326 | /** \r |
327 | Gather and print ALL Profiling Records.\r | |
328 | \r | |
329 | Displays all "interesting" Profile measurements in order.\r | |
330 | The number of records displayed is controlled by:\r | |
331 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
332 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
333 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
334 | displayed.\r | |
335 | \r | |
336 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
337 | The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r | |
338 | They must not be in use by a calling function.\r | |
339 | \r | |
340 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
341 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
342 | \r | |
c06ad33e | 343 | **/\r |
344 | VOID\r | |
345 | DumpAllProfile(\r | |
346 | IN UINTN Limit,\r | |
347 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 348 | );\r |
c06ad33e | 349 | \r |
f97c2415 ED |
350 | /** \r |
351 | Gather and print Raw Profile Records.\r | |
352 | \r | |
353 | All Profile measurements with a duration greater than or equal to\r | |
354 | mInterestThreshold are printed without interpretation.\r | |
355 | \r | |
356 | The number of records displayed is controlled by:\r | |
357 | - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
358 | - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
359 | - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
360 | displayed.\r | |
361 | \r | |
362 | @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
363 | \r | |
364 | @param[in] Limit The number of records to print. Zero is ALL.\r | |
365 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
366 | \r | |
c06ad33e | 367 | **/\r |
368 | VOID\r | |
369 | DumpRawProfile(\r | |
370 | IN UINTN Limit,\r | |
371 | IN BOOLEAN ExcludeFlag\r | |
cbdf19a5 | 372 | );\r |
a2daf8db SZ |
373 | \r |
374 | /**\r | |
375 | Wrap original FreePool to check NULL pointer first.\r | |
376 | \r | |
377 | @param[in] Buffer The pointer to the buffer to free.\r | |
378 | \r | |
379 | **/\r | |
380 | VOID\r | |
381 | SafeFreePool (\r | |
382 | IN VOID *Buffer\r | |
383 | );\r | |
384 | \r | |
9dd74618 | 385 | #endif\r |