]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
ShellPkg/dp: Update dp tool to parse new Perf record
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / DpInternal.h
CommitLineData
d41bc92c 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
115eae65 9 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
196ccda0 10 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
d41bc92c 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
18**/\r
19#ifndef _DP_INTELNAL_H_\r
20#define _DP_INTELNAL_H_\r
21\r
22#define DP_GAUGE_STRING_LENGTH 36\r
23\r
24//\r
25/// Module-Global Variables\r
26///@{\r
92034c4c 27extern EFI_HII_HANDLE mDpHiiHandle;\r
d41bc92c 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
115eae65
DB
32extern UINT8 *mBootPerformanceTable;\r
33extern UINTN mBootPerformanceTableLength;\r
34extern MEASUREMENT_RECORD *mMeasurementList;\r
35extern UINTN mMeasurementNum;\r
d41bc92c 36\r
37extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData structure and init. to ZERO.\r
38\r
d41bc92c 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
45///@}\r
46\r
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
66**/\r
67UINT64\r
68GetDuration (\r
69 IN OUT MEASUREMENT_RECORD *Measurement\r
70 );\r
71\r
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
82**/\r
83BOOLEAN\r
84IsPhase(\r
85 IN MEASUREMENT_RECORD *Measurement\r
86 );\r
87\r
f45dd2dd
BD
88/**\r
89 Determine whether the Measurement record is for core code.\r
90\r
91 @param[in] Measurement A pointer to the Measurement record to test.\r
92\r
93 @retval TRUE The measurement record is used for core.\r
94 @retval FALSE The measurement record is NOT used for core.\r
95\r
96**/\r
97BOOLEAN\r
98IsCorePerf(\r
99 IN MEASUREMENT_RECORD *Measurement\r
100 );\r
101\r
d41bc92c 102/** \r
103 Get the file name portion of the Pdb File Name.\r
104 \r
105 The portion of the Pdb File Name between the last backslash and\r
106 either a following period or the end of the string is converted\r
107 to Unicode and copied into UnicodeBuffer. The name is truncated,\r
108 if necessary, to ensure that UnicodeBuffer is not overrun.\r
109 \r
110 @param[in] PdbFileName Pdb file name.\r
111 @param[out] UnicodeBuffer The resultant Unicode File Name.\r
112 \r
113**/\r
114VOID\r
2c55a81a 115DpGetShortPdbFileName (\r
d41bc92c 116 IN CHAR8 *PdbFileName,\r
117 OUT CHAR16 *UnicodeBuffer\r
118 );\r
119\r
120/** \r
121 Get a human readable name for an image handle.\r
122 The following methods will be tried orderly:\r
123 1. Image PDB\r
124 2. ComponentName2 protocol\r
125 3. FFS UI section\r
126 4. Image GUID\r
127 5. Image DevicePath\r
128 6. Unknown Driver Name\r
129 \r
130 @param[in] Handle\r
131 \r
132 @post The resulting Unicode name string is stored in the\r
133 mGaugeString global array.\r
134 \r
135**/\r
136VOID\r
2c55a81a 137DpGetNameFromHandle (\r
d41bc92c 138 IN EFI_HANDLE Handle\r
139 );\r
140\r
141/** \r
142 Calculate the Duration in microseconds.\r
143 \r
144 Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
145 multiplying the result by 1000, in order to maintain precision. Since Duration is\r
146 a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
147 \r
148 The time is calculated as (Duration * 1000) / Timer_Frequency.\r
149 \r
150 @param[in] Duration The event duration in timer ticks.\r
151 \r
152 @return A 64-bit value which is the Elapsed time in microseconds.\r
153**/\r
154UINT64\r
155DurationInMicroSeconds (\r
156 IN UINT64 Duration\r
157 );\r
158\r
159/** \r
160 Get index of Measurement Record's match in the CumData array.\r
161 \r
162 If the Measurement's Token value matches a Token in one of the CumData\r
163 records, the index of the matching record is returned. The returned\r
164 index is a signed value so that negative values can indicate that\r
165 the Measurement didn't match any entry in the CumData array.\r
166 \r
167 @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.\r
168 \r
169 @retval <0 Token is not in the CumData array.\r
170 @retval >=0 Return value is the index into CumData where Token is found.\r
171**/\r
172INTN\r
173GetCumulativeItem(\r
174 IN MEASUREMENT_RECORD *Measurement\r
175 );\r
176\r
177/** \r
178 Collect verbose statistics about the logged performance measurements.\r
179 \r
180 General Summary information for all Trace measurements is gathered and\r
181 stored within the SummaryData structure. This information is both\r
182 used internally by subsequent reporting functions, and displayed\r
183 at the end of verbose reports.\r
184 \r
185 @pre The SummaryData and CumData structures must be initialized\r
186 prior to calling this function.\r
187 \r
188 @post The SummaryData and CumData structures contain statistics for the\r
189 current performance logs.\r
a06795c6
CS
190\r
191 @param[in, out] CustomCumulativeData The pointer to the custom cumulative data.\r
192\r
d41bc92c 193**/\r
194VOID\r
195GatherStatistics(\r
a06795c6 196 IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r
d41bc92c 197 );\r
198\r
199/** \r
200 Gather and print ALL Trace Records.\r
201 \r
202 Displays all "interesting" Trace measurements in order.<BR>\r
203 The number of records displayed is controlled by:\r
204 - records with a duration less than mInterestThreshold microseconds are not displayed.\r
205 - No more than Limit records are displayed. A Limit of zero will not limit the output.\r
206 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
207 displayed.\r
208 \r
209 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r
210 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r
211 They must not be in use by a calling function.\r
212 \r
213 @param[in] Limit The number of records to print. Zero is ALL.\r
214 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
215 \r
196ccda0
CS
216 @retval EFI_SUCCESS The operation was successful.\r
217 @retval EFI_ABORTED The user aborts the operation.\r
218 @return Others from a call to gBS->LocateHandleBuffer().\r
d41bc92c 219**/\r
196ccda0 220EFI_STATUS\r
d41bc92c 221DumpAllTrace(\r
222 IN UINTN Limit,\r
223 IN BOOLEAN ExcludeFlag\r
224 );\r
225\r
226/** \r
227 Gather and print Raw Trace Records.\r
228 \r
229 All Trace measurements with a duration greater than or equal to\r
230 mInterestThreshold are printed without interpretation.\r
231 \r
232 The number of records displayed is controlled by:\r
233 - records with a duration less than mInterestThreshold microseconds are not displayed.\r
234 - No more than Limit records are displayed. A Limit of zero will not limit the output.\r
235 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
236 displayed.\r
237 \r
238 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r
239 \r
240 @param[in] Limit The number of records to print. Zero is ALL.\r
241 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
196ccda0
CS
242 @retval EFI_SUCCESS The operation was successful.\r
243 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 244**/\r
196ccda0 245EFI_STATUS\r
d41bc92c 246DumpRawTrace(\r
247 IN UINTN Limit,\r
248 IN BOOLEAN ExcludeFlag\r
249 );\r
250\r
251/** \r
252 Gather and print Major Phase metrics.\r
253 \r
d41bc92c 254**/\r
255VOID\r
256ProcessPhases(\r
ef224032 257 VOID\r
d41bc92c 258 );\r
259\r
260\r
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
196ccda0
CS
266 @retval EFI_SUCCESS The operation was successful.\r
267 @retval EFI_ABORTED The user aborts the operation.\r
268 @return Others from a call to gBS->LocateHandleBuffer().\r
d41bc92c 269**/\r
270EFI_STATUS\r
271ProcessHandles(\r
272 IN BOOLEAN ExcludeFlag\r
273 );\r
274\r
275\r
276/** \r
277 Gather and print PEIM data.\r
278 \r
279 Only prints complete PEIM records\r
280 \r
196ccda0
CS
281 @retval EFI_SUCCESS The operation was successful.\r
282 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 283**/\r
196ccda0 284EFI_STATUS\r
d41bc92c 285ProcessPeims(\r
286 VOID\r
287 );\r
288\r
289/** \r
290 Gather and print global data.\r
291 \r
292 Strips out incomplete or "Execution Phase" records\r
293 Only prints records where Handle is NULL\r
294 Increment TIndex for every record, even skipped ones, so that we have an\r
295 indication of every measurement record taken.\r
296 \r
196ccda0
CS
297 @retval EFI_SUCCESS The operation was successful.\r
298 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 299**/\r
196ccda0 300EFI_STATUS\r
d41bc92c 301ProcessGlobal(\r
302 VOID\r
303 );\r
304\r
305/** \r
306 Gather and print cumulative data.\r
307 \r
308 Traverse the measurement records and:<BR>\r
309 For each record with a Token listed in the CumData array:<BR>\r
310 - Update the instance count and the total, minimum, and maximum durations.\r
311 Finally, print the gathered cumulative statistics.\r
a06795c6
CS
312\r
313 @param[in] CustomCumulativeData The pointer to the custom cumulative data.\r
d41bc92c 314 \r
315**/\r
316VOID\r
317ProcessCumulative(\r
a06795c6 318 IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r
d41bc92c 319 );\r
320\r
d41bc92c 321#endif\r