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