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