]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
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 | |
9 | Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r | |
10 | (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r | |
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 | |
18 | **/\r | |
19 | #ifndef _DP_INTELNAL_H_\r | |
20 | #define _DP_INTELNAL_H_\r | |
21 | \r | |
22 | #define DP_GAUGE_STRING_LENGTH 36\r | |
23 | \r | |
24 | //\r | |
25 | /// Module-Global Variables\r | |
26 | ///@{\r | |
27 | extern EFI_HII_HANDLE gHiiHandle;\r | |
28 | extern CHAR16 *mPrintTokenBuffer;\r | |
29 | extern CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r | |
30 | extern CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r | |
31 | extern UINT64 mInterestThreshold;\r | |
32 | extern BOOLEAN mShowId;\r | |
33 | \r | |
34 | extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.\r | |
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 | |
45 | ///@}\r | |
46 | \r | |
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 | |
66 | **/\r | |
67 | UINT64\r | |
68 | GetDuration (\r | |
69 | IN OUT MEASUREMENT_RECORD *Measurement\r | |
70 | );\r | |
71 | \r | |
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 | |
82 | **/\r | |
83 | BOOLEAN\r | |
84 | IsPhase(\r | |
85 | IN MEASUREMENT_RECORD *Measurement\r | |
86 | );\r | |
87 | \r | |
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 | |
99 | **/\r | |
100 | VOID\r | |
101 | GetShortPdbFileName (\r | |
102 | IN CHAR8 *PdbFileName,\r | |
103 | OUT CHAR16 *UnicodeBuffer\r | |
104 | );\r | |
105 | \r | |
106 | /** \r | |
107 | Get a human readable name for an image handle.\r | |
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 | |
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 | |
121 | **/\r | |
122 | VOID\r | |
123 | GetNameFromHandle (\r | |
124 | IN EFI_HANDLE Handle\r | |
125 | );\r | |
126 | \r | |
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 | |
139 | **/\r | |
140 | UINT64\r | |
141 | DurationInMicroSeconds (\r | |
142 | IN UINT64 Duration\r | |
143 | );\r | |
144 | \r | |
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 | |
153 | **/\r | |
154 | UINTN\r | |
155 | EFIAPI\r | |
156 | PrintToken (\r | |
157 | IN UINT16 Token,\r | |
158 | ...\r | |
159 | );\r | |
160 | \r | |
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 | |
173 | **/\r | |
174 | INTN\r | |
175 | GetCumulativeItem(\r | |
176 | IN MEASUREMENT_RECORD *Measurement\r | |
177 | );\r | |
178 | \r | |
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 | |
192 | \r | |
193 | @param[in, out] CustomCumulativeData The pointer to the custom cumulative data.\r | |
194 | \r | |
195 | **/\r | |
196 | VOID\r | |
197 | GatherStatistics(\r | |
198 | IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r | |
199 | );\r | |
200 | \r | |
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 | |
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 | |
221 | **/\r | |
222 | EFI_STATUS\r | |
223 | DumpAllTrace(\r | |
224 | IN UINTN Limit,\r | |
225 | IN BOOLEAN ExcludeFlag\r | |
226 | );\r | |
227 | \r | |
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 | |
244 | \r | |
245 | @retval EFI_SUCCESS The operation was successful.\r | |
246 | @retval EFI_ABORTED The user aborts the operation.\r | |
247 | **/\r | |
248 | EFI_STATUS\r | |
249 | DumpRawTrace(\r | |
250 | IN UINTN Limit,\r | |
251 | IN BOOLEAN ExcludeFlag\r | |
252 | );\r | |
253 | \r | |
254 | /** \r | |
255 | Gather and print Major Phase metrics.\r | |
256 | \r | |
257 | **/\r | |
258 | VOID\r | |
259 | ProcessPhases(\r | |
260 | VOID\r | |
261 | );\r | |
262 | \r | |
263 | \r | |
264 | /** \r | |
265 | Gather and print Handle data.\r | |
266 | \r | |
267 | @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
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 | |
272 | **/\r | |
273 | EFI_STATUS\r | |
274 | ProcessHandles(\r | |
275 | IN BOOLEAN ExcludeFlag\r | |
276 | );\r | |
277 | \r | |
278 | \r | |
279 | /** \r | |
280 | Gather and print PEIM data.\r | |
281 | \r | |
282 | Only prints complete PEIM records\r | |
283 | \r | |
284 | @retval EFI_SUCCESS The operation was successful.\r | |
285 | @retval EFI_ABORTED The user aborts the operation.\r | |
286 | **/\r | |
287 | EFI_STATUS\r | |
288 | ProcessPeims(\r | |
289 | VOID\r | |
290 | );\r | |
291 | \r | |
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 | |
300 | @retval EFI_SUCCESS The operation was successful.\r | |
301 | @retval EFI_ABORTED The user aborts the operation.\r | |
302 | **/\r | |
303 | EFI_STATUS\r | |
304 | ProcessGlobal(\r | |
305 | VOID\r | |
306 | );\r | |
307 | \r | |
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 | |
315 | \r | |
316 | @param[in] CustomCumulativeData The pointer to the custom cumulative data.\r | |
317 | \r | |
318 | **/\r | |
319 | VOID\r | |
320 | ProcessCumulative(\r | |
321 | IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r | |
322 | );\r | |
323 | \r | |
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 | |
341 | **/\r | |
342 | VOID\r | |
343 | DumpAllProfile(\r | |
344 | IN UINTN Limit,\r | |
345 | IN BOOLEAN ExcludeFlag\r | |
346 | );\r | |
347 | \r | |
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 | |
365 | **/\r | |
366 | VOID\r | |
367 | DumpRawProfile(\r | |
368 | IN UINTN Limit,\r | |
369 | IN BOOLEAN ExcludeFlag\r | |
370 | );\r | |
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 | |
383 | #endif\r |