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