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