2 Header file for 'dp' command functions.
4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Guid/Performance.h>
23 #include <Protocol/HiiPackageList.h>
24 #include <Protocol/DevicePath.h>
25 #include <Protocol/LoadedImage.h>
26 #include <Protocol/UnicodeCollation.h>
28 #include <Library/BaseLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/ShellLib.h>
33 #include <Library/UefiLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/PcdLib.h>
37 #include <Library/SortLib.h>
38 #include <Library/HiiLib.h>
39 #include <Library/FileHandleLib.h>
40 #include <Library/UefiHiiServicesLib.h>
42 extern EFI_HANDLE mDpHiiHandle
;
44 #define DP_MAJOR_VERSION 2
45 #define DP_MINOR_VERSION 4
48 * The value assigned to DP_DEBUG controls which debug output
49 * is generated. Set it to ZERO to disable.
54 * Set to 1 once Profiling has been implemented in order to enable
55 * profiling related options and report output.
57 #define PROFILING_IMPLEMENTED 0
59 #define DEFAULT_THRESHOLD 1000 ///< One millisecond.
60 #define DEFAULT_DISPLAYCOUNT 50
61 #define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
63 #define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
65 /// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
66 #define WITHIN_LIMIT( C, L) ( ((L) == 0) || ((C) < (L)) )
68 /// Structure for storing Timer specific information.
70 UINT64 StartCount
; ///< Value timer is initialized with.
71 UINT64 EndCount
; ///< Value timer has just before it wraps.
72 UINT32 Frequency
; ///< Timer count frequency in KHz.
73 BOOLEAN CountUp
; ///< TRUE if the counter counts up.
76 /** Initialize one PERF_CUM_DATA structure instance for token t.
78 * This parameterized macro takes a single argument, t, which is expected
79 * to resolve to a pointer to an ASCII string literal. This parameter may
80 * take any one of the following forms:
81 * - PERF_INIT_CUM_DATA("Token") A string literal
82 * - PERF_INIT_CUM_DATA(pointer) A pointer -- CHAR8 *pointer;
83 * - PERF_INIT_CUM_DATA(array) Address of an array -- CHAR8 array[N];
85 #define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
88 UINT64 Duration
; ///< Cumulative duration for this item.
89 UINT64 MinDur
; ///< Smallest duration encountered.
90 UINT64 MaxDur
; ///< Largest duration encountered.
91 CHAR8
*Name
; ///< ASCII name of this item.
92 UINT32 Count
; ///< Total number of measurements accumulated.
96 UINT32 NumTrace
; ///< Number of recorded TRACE performance measurements.
97 UINT32 NumProfile
; ///< Number of recorded PROFILE performance measurements.
98 UINT32 NumIncomplete
; ///< Number of measurements with no END value.
99 UINT32 NumSummary
; ///< Number of summary section measurements.
100 UINT32 NumHandles
; ///< Number of measurements with handles.
101 UINT32 NumPEIMs
; ///< Number of measurements of PEIMs.
102 UINT32 NumGlobal
; ///< Number of measurements with END value and NULL handle.
107 CONST CHAR8
*Token
; ///< Measured token string name.
108 CONST CHAR8
*Module
; ///< Module string name.
109 UINT64 StartTimeStamp
; ///< Start time point.
110 UINT64 EndTimeStamp
; ///< End time point.
111 UINT32 Identifier
; ///< Identifier.
112 } MEASUREMENT_RECORD
;
115 CHAR8
*Name
; ///< Measured token string name.
116 UINT64 CumulativeTime
; ///< Accumulated Elapsed Time.
117 UINT64 MinTime
; ///< Minimum Elapsed Time.
118 UINT64 MaxTime
; ///< Maximum Elapsed Time.
119 UINT32 Count
; ///< Number of measurements accumulated.
123 Dump performance data.
125 @param[in] ImageHandle The image handle.
126 @param[in] SystemTable The system table.
128 @retval SHELL_SUCCESS Command completed successfully.
129 @retval SHELL_INVALID_PARAMETER Command usage error.
130 @retval SHELL_ABORTED The user aborts the operation.
131 @retval value Unknown error.
135 IN EFI_HANDLE ImageHandle
,
136 IN EFI_SYSTEM_TABLE
*SystemTable
140 Retrive HII package list from ImageHandle and publish to HII database.
142 @param ImageHandle The image handle of the process.
147 InitializeHiiPackage (
148 EFI_HANDLE ImageHandle