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