2 * Declarations of objects defined internally to the Dp Application.
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.
9 * Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
10 * This program and the accompanying materials
11 * are licensed and made available under the terms and conditions of the BSD License
12 * which accompanies this distribution. The full text of the license may be found at
13 * http://opensource.org/licenses/bsd-license.php
15 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef _DP_INTELNAL_H_
19 #define _DP_INTELNAL_H_
21 /// Module-Global Variables
23 extern EFI_HII_HANDLE gHiiHandle
;
24 extern CHAR16
*mPrintTokenBuffer
;
25 extern CHAR16 mGaugeString
[DXE_PERFORMANCE_STRING_SIZE
];
26 extern CHAR16 mUnicodeToken
[PERF_TOKEN_LENGTH
+ 1];
27 extern UINT64 mInterestThreshold
;
29 extern PERF_SUMMARY_DATA SummaryData
;; ///< Create the SummaryData structure and init. to ZERO.
31 /// Timer Specific Information.
32 extern TIMER_INFO TimerInfo
;
34 /// Items for which to gather cumulative statistics.
35 extern PERF_CUM_DATA CumData
[];
37 /// Number of items for which we are gathering cumulative statistics.
38 extern UINT32
const NumCum
;
42 /** Calculate an event's duration in timer ticks.
44 * Given the count direction and the event's start and end timer values,
45 * calculate the duration of the event in timer ticks.
47 * @pre The global TimerInfo structure must have already been initialized
48 * before this function is called.
50 * @param[in,out] Measurement Pointer to a structure containing data for the current measurement.
52 * @return The 64-bit duration of the event.
56 IN OUT MEASUREMENT_RECORD
*Measurement
59 /** Determine whether the Measurement record is for an EFI Phase.
61 * The Token and Module members of the measurement record are checked.
62 * Module must be empty and Token must be one of SEC, PEI, DXE, or BDS.
64 * @param[in] Measurement A pointer to the Measurement record to test.
66 * @retval TRUE The measurement record is for an EFI Phase.
67 * @retval FALSE The measurement record is NOT for an EFI Phase.
71 IN MEASUREMENT_RECORD
*Measurement
74 /** Get the file name portion of the Pdb File Name.
76 * The portion of the Pdb File Name between the last backslash and
77 * either a following period or the end of the string is converted
78 * to Unicode and copied into UnicodeBuffer. The name is truncated,
79 * if necessary, to ensure that UnicodeBuffer is not overrun.
81 * @param[in] PdbFileName Pdb file name.
82 * @param[out] UnicodeBuffer The resultant Unicode File Name.
87 IN CHAR8
*PdbFileName
,
88 OUT CHAR16
*UnicodeBuffer
91 /** Get a human readable name for an image handle.
95 * @post The resulting Unicode name string is stored in the
96 * mGaugeString global array.
104 /** Calculate the Duration in microseconds.
106 * Duration is multiplied by 1000, instead of Frequency being divided by 1000
107 * in order to maintain precision. Since Duration is
108 * a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.
110 * @param[in] Duration The event duration in timer ticks.
112 * @return A 64-bit value which is the Elapsed time in microseconds.
115 DurationInMicroSeconds (
119 /** Formatted Print using a Hii Token to reference the localized format string.
121 * @param[in] Token A HII token associated with a localized Unicode string.
123 * @return The number of characters converted by UnicodeVSPrint().
132 /** Get index of Measurement Record's match in the CumData array.
134 * @param[in] Measurement A pointer to a Measurement Record to match against the CumData array.
136 * @retval <0 Token is not in the CumData array.
137 * @retval >=0 Return value is the index into CumData where Token is found.
141 IN MEASUREMENT_RECORD
*Measurement
144 /** Collect verbose statistics about the logged performance measurements.
146 * General Summary information for all Trace measurements is gathered and
147 * stored within the SummaryData structure. This information is both
148 * used internally by subsequent reporting functions, and displayed
149 * at the end of verbose reports.
151 * @pre The SummaryData and CumData structures must be initialized
152 * prior to calling this function.
154 * @post The SummaryData and CumData structures contain statistics for the
155 * current performance logs.
162 /** Gather and print ALL Trace Records.
164 * Displays all "interesting" Trace measurements in order.
165 * The number of records displayed is controlled by:
166 * - records with a duration less than mInterestThreshold microseconds are not displayed.
167 * - No more than Limit records are displayed. A Limit of zero will not limit the output.
168 * - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
171 * @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
172 * The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
173 * They must not be in use by a calling function.
175 * @param[in] Limit The number of records to print. Zero is ALL.
176 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
182 IN BOOLEAN ExcludeFlag
185 /** Gather and print Raw Trace Records.
187 * All Trace measurements with a duration greater than or equal to
188 * mInterestThreshold are printed without interpretation.
190 * The number of records displayed is controlled by:
191 * - records with a duration less than mInterestThreshold microseconds are not displayed.
192 * - No more than Limit records are displayed. A Limit of zero will not limit the output.
193 * - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
196 * @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
198 * @param[in] Limit The number of records to print. Zero is ALL.
199 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
205 IN BOOLEAN ExcludeFlag
208 /** Gather and print Major Phase metrics.
210 * @param[in] Ticker The timer value for the END of Shell phase
219 /** Gather and print Handle data.
221 * @param[in] ExcludeFlag TRUE if the -x command line flag given. Elides accumulated trace records.
223 * @return Status from a call to gBS->LocateHandle().
227 IN BOOLEAN ExcludeFlag
231 /** Gather and print PEIM data.
233 * Only prints complete PEIM records
241 /** Gather and print global data.
243 * Strips out incomplete or "Execution Phase" records
244 * Only prints records where Handle is NULL
245 * Increment TIndex for every record, even skipped ones, so that we have an
246 * indication of every measurement record taken.
255 /** Gather and print cumulative data.
257 * Traverse the measurement records and:
258 * for each record with a Token listed in the CumData array,
259 * Update the instance count and the total, minimum, and maximum durations.
260 * Finally, print the gathered cumulative statistics.
268 /** Gather and print ALL Profile Records.
270 * @param[in] Limit The number of records to print. Zero is ALL.
271 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display
277 IN BOOLEAN ExcludeFlag
280 /** Gather and print Raw Profile Records.
282 * @param[in] Limit The number of records to print.
283 * @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display
289 IN BOOLEAN ExcludeFlag