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