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