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