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