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