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