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