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