]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
ShellPkg/dp: Convert from NULL class library to Dynamic Command
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / Dp.h
1 /** @file
2 Header file for 'dp' command functions.
3
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
9
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.
12
13 **/
14
15 #ifndef _DP_H_
16 #define _DP_H_
17
18
19 #include <Uefi.h>
20
21 #include <Guid/Performance.h>
22
23 #include <Protocol/HiiPackageList.h>
24 #include <Protocol/DevicePath.h>
25 #include <Protocol/LoadedImage.h>
26 #include <Protocol/UnicodeCollation.h>
27
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>
41
42 extern EFI_HANDLE mDpHiiHandle;
43
44 #define DP_MAJOR_VERSION 2
45 #define DP_MINOR_VERSION 4
46
47 /**
48 * The value assigned to DP_DEBUG controls which debug output
49 * is generated. Set it to ZERO to disable.
50 **/
51 #define DP_DEBUG 0
52
53 /**
54 * Set to 1 once Profiling has been implemented in order to enable
55 * profiling related options and report output.
56 **/
57 #define PROFILING_IMPLEMENTED 0
58
59 #define DEFAULT_THRESHOLD 1000 ///< One millisecond.
60 #define DEFAULT_DISPLAYCOUNT 50
61 #define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
62
63 #define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
64
65 /// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
66 #define WITHIN_LIMIT( C, L) ( ((L) == 0) || ((C) < (L)) )
67
68 /// Structure for storing Timer specific information.
69 typedef struct {
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.
74 } TIMER_INFO;
75
76 /** Initialize one PERF_CUM_DATA structure instance for token t.
77 *
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];
84 **/
85 #define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
86
87 typedef struct {
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.
93 } PERF_CUM_DATA;
94
95 typedef struct {
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.
103 } PERF_SUMMARY_DATA;
104
105 typedef struct {
106 CONST VOID *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;
113
114 typedef struct {
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.
120 } PROFILE_RECORD;
121
122 /**
123 Dump performance data.
124
125 @param[in] ImageHandle The image handle.
126 @param[in] SystemTable The system table.
127
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.
132 **/
133 SHELL_STATUS
134 RunDp (
135 IN EFI_HANDLE ImageHandle,
136 IN EFI_SYSTEM_TABLE *SystemTable
137 );
138
139 /**
140 Retrive HII package list from ImageHandle and publish to HII database.
141
142 @param ImageHandle The image handle of the process.
143
144 @return HII handle.
145 **/
146 EFI_HANDLE
147 InitializeHiiPackage (
148 EFI_HANDLE ImageHandle
149 );
150 #endif // _DP_H_