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