]>
Commit | Line | Data |
---|---|---|
c06ad33e | 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 | |
92ea1df8 | 9 | * Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r |
c06ad33e | 10 | * This program and the accompanying materials\r |
11 | * are licensed and made available under the terms and conditions of the BSD License\r | |
12 | * which accompanies this distribution. The full text of the license may be found at\r | |
13 | * http://opensource.org/licenses/bsd-license.php\r | |
14 | *\r | |
15 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
16 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
17 | **/\r | |
18 | \r | |
19 | //\r | |
20 | /// Module-Global Variables\r | |
21 | /// @{\r | |
22 | extern EFI_HII_HANDLE gHiiHandle;\r | |
23 | extern CHAR16 *mPrintTokenBuffer;\r | |
24 | extern CHAR16 mGaugeString[DXE_PERFORMANCE_STRING_SIZE];\r | |
25 | extern CHAR16 mUnicodeToken[PERF_TOKEN_LENGTH + 1];\r | |
26 | extern UINT64 mInterestThreshold;\r | |
27 | \r | |
28 | extern PERF_SUMMARY_DATA SummaryData;; ///< Create the SummaryData structure and init. to ZERO.\r | |
29 | \r | |
30 | /// Timer Specific Information.\r | |
31 | extern TIMER_INFO TimerInfo;\r | |
32 | \r | |
33 | /// Items for which to gather cumulative statistics.\r | |
34 | extern PERF_CUM_DATA CumData[];\r | |
35 | \r | |
36 | /// Number of items for which we are gathering cumulative statistics.\r | |
37 | extern UINT32 const NumCum;\r | |
38 | \r | |
39 | /// @}\r | |
40 | \r | |
41 | /** Calculate an event's duration in timer ticks.\r | |
42 | *\r | |
43 | * Given the count direction and the event's start and end timer values,\r | |
44 | * calculate the duration of the event in timer ticks.\r | |
45 | *\r | |
46 | * @pre The global TimerInfo structure must have already been initialized\r | |
47 | * before this function is called.\r | |
48 | *\r | |
49 | * @param[in,out] Measurement Pointer to a structure containing data for the current measurement.\r | |
50 | *\r | |
51 | * @return The 64-bit duration of the event.\r | |
52 | **/\r | |
53 | UINT64\r | |
54 | GetDuration (\r | |
55 | IN OUT MEASUREMENT_RECORD *Measurement\r | |
56 | );\r | |
57 | \r | |
58 | /** Determine whether the Measurement record is for an EFI Phase.\r | |
59 | *\r | |
60 | * The Token and Module members of the measurement record are checked.\r | |
61 | * Module must be empty and Token must be one of SEC, PEI, DXE, or BDS.\r | |
62 | *\r | |
63 | * @param[in] Measurement A pointer to the Measurement record to test.\r | |
64 | *\r | |
65 | * @retval TRUE The measurement record is for an EFI Phase.\r | |
66 | * @retval FALSE The measurement record is NOT for an EFI Phase.\r | |
67 | **/\r | |
68 | BOOLEAN\r | |
69 | IsPhase(\r | |
70 | IN MEASUREMENT_RECORD *Measurement\r | |
71 | );\r | |
72 | \r | |
73 | /** Get the file name portion of the Pdb File Name.\r | |
74 | *\r | |
75 | * The portion of the Pdb File Name between the last backslash and\r | |
76 | * either a following period or the end of the string is converted\r | |
77 | * to Unicode and copied into UnicodeBuffer. The name is truncated,\r | |
78 | * if necessary, to ensure that UnicodeBuffer is not overrun.\r | |
79 | *\r | |
80 | * @param[in] PdbFileName Pdb file name.\r | |
81 | * @param[out] UnicodeBuffer The resultant Unicode File Name.\r | |
82 | *\r | |
83 | **/\r | |
84 | VOID\r | |
85 | GetShortPdbFileName (\r | |
86 | IN CHAR8 *PdbFileName,\r | |
87 | OUT CHAR16 *UnicodeBuffer\r | |
88 | );\r | |
89 | \r | |
90 | /** Get a human readable name for an image handle.\r | |
91 | *\r | |
92 | * @param[in] Handle\r | |
93 | *\r | |
94 | * @post The resulting Unicode name string is stored in the\r | |
95 | * mGaugeString global array.\r | |
96 | *\r | |
97 | **/\r | |
98 | VOID\r | |
99 | GetNameFromHandle (\r | |
100 | IN EFI_HANDLE Handle\r | |
101 | );\r | |
102 | \r | |
103 | /** Calculate the Duration in microseconds.\r | |
104 | *\r | |
105 | * Duration is multiplied by 1000, instead of Frequency being divided by 1000\r | |
106 | * in order to maintain precision. Since Duration is\r | |
107 | * a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r | |
108 | *\r | |
109 | * @param[in] Duration The event duration in timer ticks.\r | |
110 | *\r | |
111 | * @return A 64-bit value which is the Elapsed time in microseconds.\r | |
112 | **/\r | |
113 | UINT64\r | |
114 | DurationInMicroSeconds (\r | |
115 | IN UINT64 Duration\r | |
116 | );\r | |
117 | \r | |
118 | /** Formatted Print using a Hii Token to reference the localized format string.\r | |
119 | *\r | |
120 | * @param[in] Token A HII token associated with a localized Unicode string.\r | |
121 | *\r | |
122 | * @return The number of characters converted by UnicodeVSPrint().\r | |
123 | *\r | |
124 | **/\r | |
125 | UINTN\r | |
126 | PrintToken (\r | |
127 | IN UINT16 Token,\r | |
128 | ...\r | |
129 | );\r | |
130 | \r | |
131 | /** Get index of Measurement Record's match in the CumData array.\r | |
132 | *\r | |
133 | * @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.\r | |
134 | *\r | |
135 | * @retval <0 Token is not in the CumData array.\r | |
136 | * @retval >=0 Return value is the index into CumData where Token is found.\r | |
137 | **/\r | |
138 | INTN\r | |
139 | GetCumulativeItem(\r | |
140 | IN MEASUREMENT_RECORD *Measurement\r | |
141 | );\r | |
142 | \r | |
143 | /** Collect verbose statistics about the logged performance measurements.\r | |
144 | *\r | |
145 | * General Summary information for all Trace measurements is gathered and\r | |
146 | * stored within the SummaryData structure. This information is both\r | |
147 | * used internally by subsequent reporting functions, and displayed\r | |
148 | * at the end of verbose reports.\r | |
149 | *\r | |
150 | * @pre The SummaryData and CumData structures must be initialized\r | |
151 | * prior to calling this function.\r | |
152 | *\r | |
153 | * @post The SummaryData and CumData structures contain statistics for the\r | |
154 | * current performance logs.\r | |
155 | **/\r | |
156 | VOID\r | |
157 | GatherStatistics(\r | |
158 | VOID\r | |
159 | );\r | |
160 | \r | |
161 | /** Gather and print ALL Trace Records.\r | |
162 | *\r | |
163 | * Displays all "interesting" Trace measurements in order.\r | |
164 | * The number of records displayed is controlled by:\r | |
165 | * - records with a duration less than mInterestThreshold microseconds are not displayed.\r | |
166 | * - No more than Limit records are displayed. A Limit of zero will not limit the output.\r | |
167 | * - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r | |
168 | * displayed.\r | |
169 | *\r | |
170 | * @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r | |
171 | * The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r | |
172 | * They must not be in use by a calling function.\r | |
173 | *\r | |
174 | * @param[in] Limit The number of records to print. Zero is ALL.\r | |
175 | * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
176 | *\r | |
177 | **/\r | |
178 | VOID\r | |
179 | DumpAllTrace(\r | |
180 | IN UINTN Limit,\r | |
181 | IN BOOLEAN ExcludeFlag\r | |
182 | );\r | |
183 | \r | |
184 | /** Gather and print Raw Trace Records.\r | |
185 | *\r | |
186 | * All Trace measurements with a duration greater than or equal to\r | |
187 | * mInterestThreshold are printed without interpretation.\r | |
188 | *\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 | *\r | |
197 | * @param[in] Limit The number of records to print. Zero is ALL.\r | |
198 | * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r | |
199 | *\r | |
200 | **/\r | |
201 | VOID\r | |
202 | DumpRawTrace(\r | |
203 | IN UINTN Limit,\r | |
204 | IN BOOLEAN ExcludeFlag\r | |
205 | );\r | |
206 | \r | |
207 | /** Gather and print Major Phase metrics.\r | |
208 | *\r | |
209 | * @param[in] Ticker The timer value for the END of Shell phase\r | |
210 | *\r | |
211 | **/\r | |
212 | VOID\r | |
213 | ProcessPhases(\r | |
214 | IN UINT64 Ticker\r | |
215 | );\r | |
216 | \r | |
217 | \r | |
218 | /** Gather and print Handle data.\r | |
219 | *\r | |
220 | * @param[in] ExcludeFlag TRUE if the -x command line flag given. Elides accumulated trace records.\r | |
221 | *\r | |
222 | * @return Status from a call to gBS->LocateHandle().\r | |
223 | **/\r | |
224 | EFI_STATUS\r | |
225 | ProcessHandles(\r | |
226 | IN BOOLEAN ExcludeFlag\r | |
227 | );\r | |
228 | \r | |
229 | \r | |
230 | /** Gather and print PEIM data.\r | |
231 | *\r | |
232 | * Only prints complete PEIM records\r | |
233 | *\r | |
234 | **/\r | |
235 | VOID\r | |
236 | ProcessPeims(\r | |
237 | VOID\r | |
238 | );\r | |
239 | \r | |
240 | /** Gather and print global data.\r | |
241 | *\r | |
242 | * Strips out incomplete or "Execution Phase" records\r | |
243 | * Only prints records where Handle is NULL\r | |
244 | * Increment TIndex for every record, even skipped ones, so that we have an\r | |
245 | * indication of every measurement record taken.\r | |
246 | *\r | |
247 | *\r | |
248 | **/\r | |
249 | VOID\r | |
250 | ProcessGlobal(\r | |
251 | VOID\r | |
252 | );\r | |
253 | \r | |
254 | /** Gather and print cumulative data.\r | |
255 | *\r | |
256 | * Traverse the measurement records and:\r | |
257 | * for each record with a Token listed in the CumData array,\r | |
258 | * Update the instance count and the total, minimum, and maximum durations.\r | |
259 | * Finally, print the gathered cumulative statistics.\r | |
260 | *\r | |
261 | **/\r | |
262 | VOID\r | |
263 | ProcessCumulative(\r | |
264 | VOID\r | |
265 | );\r | |
266 | \r | |
267 | /** Gather and print ALL Profile Records.\r | |
268 | *\r | |
269 | * @param[in] Limit The number of records to print. Zero is ALL.\r | |
270 | * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display\r | |
271 | *\r | |
272 | **/\r | |
273 | VOID\r | |
274 | DumpAllProfile(\r | |
275 | IN UINTN Limit,\r | |
276 | IN BOOLEAN ExcludeFlag\r | |
277 | );\r | |
278 | \r | |
279 | /** Gather and print Raw Profile Records.\r | |
280 | *\r | |
281 | * @param[in] Limit The number of records to print.\r | |
282 | * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display\r | |
283 | *\r | |
284 | **/\r | |
285 | VOID\r | |
286 | DumpRawProfile(\r | |
287 | IN UINTN Limit,\r | |
288 | IN BOOLEAN ExcludeFlag\r | |
289 | );\r |