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