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