]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
ShellPkg: Clean up source files
[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
ba0014b9 47/**\r
d41bc92c 48 Calculate an event's duration in timer ticks.\r
ba0014b9 49\r
d41bc92c 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
ba0014b9 53\r
d41bc92c 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
ba0014b9 58\r
d41bc92c 59 The calculated duration, in ticks, is the absolute difference between\r
60 the measurement's ending and starting counts.\r
ba0014b9 61\r
d41bc92c 62 @param Measurement Pointer to a MEASUREMENT_RECORD structure containing\r
63 data for the current measurement.\r
ba0014b9 64\r
d41bc92c 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
ba0014b9 72/**\r
d41bc92c 73 Determine whether the Measurement record is for an EFI Phase.\r
ba0014b9 74\r
d41bc92c 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
ba0014b9 77\r
d41bc92c 78 @param[in] Measurement A pointer to the Measurement record to test.\r
ba0014b9 79\r
d41bc92c 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
ba0014b9 102/**\r
d41bc92c 103 Get the file name portion of the Pdb File Name.\r
ba0014b9 104\r
d41bc92c 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
ba0014b9 109\r
d41bc92c 110 @param[in] PdbFileName Pdb file name.\r
111 @param[out] UnicodeBuffer The resultant Unicode File Name.\r
ba0014b9 112\r
d41bc92c 113**/\r
114VOID\r
2c55a81a 115DpGetShortPdbFileName (\r
d41bc92c 116 IN CHAR8 *PdbFileName,\r
117 OUT CHAR16 *UnicodeBuffer\r
118 );\r
119\r
ba0014b9 120/**\r
d41bc92c 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
ba0014b9 129\r
d41bc92c 130 @param[in] Handle\r
ba0014b9 131\r
d41bc92c 132 @post The resulting Unicode name string is stored in the\r
133 mGaugeString global array.\r
ba0014b9 134\r
d41bc92c 135**/\r
136VOID\r
2c55a81a 137DpGetNameFromHandle (\r
d41bc92c 138 IN EFI_HANDLE Handle\r
139 );\r
140\r
ba0014b9 141/**\r
d41bc92c 142 Calculate the Duration in microseconds.\r
ba0014b9 143\r
d41bc92c 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
ba0014b9 147\r
d41bc92c 148 The time is calculated as (Duration * 1000) / Timer_Frequency.\r
ba0014b9 149\r
d41bc92c 150 @param[in] Duration The event duration in timer ticks.\r
ba0014b9 151\r
d41bc92c 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
ba0014b9 159/**\r
d41bc92c 160 Get index of Measurement Record's match in the CumData array.\r
ba0014b9 161\r
d41bc92c 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
ba0014b9 166\r
d41bc92c 167 @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.\r
ba0014b9 168\r
d41bc92c 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
ba0014b9 177/**\r
d41bc92c 178 Collect verbose statistics about the logged performance measurements.\r
ba0014b9 179\r
d41bc92c 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
ba0014b9 184\r
d41bc92c 185 @pre The SummaryData and CumData structures must be initialized\r
186 prior to calling this function.\r
ba0014b9 187\r
d41bc92c 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
ba0014b9 199/**\r
d41bc92c 200 Gather and print ALL Trace Records.\r
ba0014b9 201\r
d41bc92c 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
ba0014b9 208\r
d41bc92c 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
ba0014b9 212\r
d41bc92c 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
ba0014b9 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
ba0014b9 226/**\r
d41bc92c 227 Gather and print Raw Trace Records.\r
ba0014b9 228\r
d41bc92c 229 All Trace measurements with a duration greater than or equal to\r
230 mInterestThreshold are printed without interpretation.\r
ba0014b9 231\r
d41bc92c 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
ba0014b9 237\r
d41bc92c 238 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r
ba0014b9 239\r
d41bc92c 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
ba0014b9 251/**\r
d41bc92c 252 Gather and print Major Phase metrics.\r
ba0014b9 253\r
d41bc92c 254**/\r
255VOID\r
256ProcessPhases(\r
ef224032 257 VOID\r
d41bc92c 258 );\r
259\r
260\r
ba0014b9 261/**\r
d41bc92c 262 Gather and print Handle data.\r
ba0014b9 263\r
d41bc92c 264 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
ba0014b9 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
ba0014b9 276/**\r
d41bc92c 277 Gather and print PEIM data.\r
ba0014b9 278\r
d41bc92c 279 Only prints complete PEIM records\r
ba0014b9 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
ba0014b9 289/**\r
d41bc92c 290 Gather and print global data.\r
ba0014b9 291\r
d41bc92c 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
ba0014b9 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
ba0014b9 305/**\r
d41bc92c 306 Gather and print cumulative data.\r
ba0014b9 307\r
d41bc92c 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
ba0014b9 314\r
d41bc92c 315**/\r
316VOID\r
317ProcessCumulative(\r
a06795c6 318 IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r
d41bc92c 319 );\r
320\r
d41bc92c 321#endif\r