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