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