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