]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/Performance.h
Add performance library instances for SMM performance measurement.
[mirror_edk2.git] / MdeModulePkg / Include / Guid / Performance.h
1 /** @file
2 This file defines performance-related definitions, including the format of:
3 * performance GUID HOB.
4 * performance protocol interfaces.
5 * performance variables.
6
7 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __PERFORMANCE_DATA_H__
19 #define __PERFORMANCE_DATA_H__
20
21 //
22 // PEI_PERFORMANCE_STRING_SIZE must be a multiple of 8.
23 //
24 #define PEI_PERFORMANCE_STRING_SIZE 8
25 #define PEI_PERFORMANCE_STRING_LENGTH (PEI_PERFORMANCE_STRING_SIZE - 1)
26
27 typedef struct {
28 EFI_PHYSICAL_ADDRESS Handle;
29 CHAR8 Token[PEI_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
30 CHAR8 Module[PEI_PERFORMANCE_STRING_SIZE]; ///< Module string name.
31 UINT64 StartTimeStamp; ///< Start time point.
32 UINT64 EndTimeStamp; ///< End time point.
33 } PEI_PERFORMANCE_LOG_ENTRY;
34
35 //
36 // The header must be aligned at 8 bytes.
37 //
38 typedef struct {
39 UINT32 NumberOfEntries; ///< The number of all performance log entries.
40 UINT32 Reserved;
41 } PEI_PERFORMANCE_LOG_HEADER;
42
43
44 //
45 // The data structure for performance data in ACPI memory.
46 //
47 #define PERFORMANCE_SIGNATURE SIGNATURE_32 ('P', 'e', 'r', 'f')
48 #define PERF_TOKEN_SIZE 28
49 #define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)
50 #define PERF_PEI_ENTRY_MAX_NUM 50
51
52 typedef struct {
53 CHAR8 Token[PERF_TOKEN_SIZE];
54 UINT32 Duration;
55 } PERF_DATA;
56
57 typedef struct {
58 UINT64 BootToOs;
59 UINT64 S3Resume;
60 UINT32 S3EntryNum;
61 PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM];
62 UINT64 CpuFreq;
63 UINT64 BDSRaw;
64 UINT32 Count;
65 UINT32 Signiture;
66 } PERF_HEADER;
67
68 #define PERFORMANCE_PROTOCOL_GUID \
69 { 0x76b6bdfa, 0x2acd, 0x4462, {0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
70
71 //
72 // Forward reference for pure ANSI compatibility
73 //
74 typedef struct _PERFORMANCE_PROTOCOL PERFORMANCE_PROTOCOL;
75
76 //
77 // DXE_PERFORMANCE_STRING_SIZE must be a multiple of 8.
78 //
79 #define DXE_PERFORMANCE_STRING_SIZE 32
80 #define DXE_PERFORMANCE_STRING_LENGTH (DXE_PERFORMANCE_STRING_SIZE - 1)
81
82 //
83 // The default guage entries number for DXE phase.
84 //
85 #define INIT_DXE_GAUGE_DATA_ENTRIES 800
86
87 typedef struct {
88 EFI_PHYSICAL_ADDRESS Handle;
89 CHAR8 Token[DXE_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
90 CHAR8 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
91 UINT64 StartTimeStamp; ///< Start time point.
92 UINT64 EndTimeStamp; ///< End time point.
93 } GAUGE_DATA_ENTRY;
94
95 //
96 // The header must be aligned at 8 bytes
97 //
98 typedef struct {
99 UINT32 NumberOfEntries; ///< The number of all performance gauge entries.
100 UINT32 Reserved;
101 } GAUGE_DATA_HEADER;
102
103 //
104 // SMM Performance Protocol definitions
105 //
106
107 #define SMM_PERFORMANCE_PROTOCOL_GUID \
108 { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
109
110 //
111 // SMM_PERFORMANCE_STRING_SIZE.
112 //
113 #define SMM_PERFORMANCE_STRING_SIZE 32
114 #define SMM_PERFORMANCE_STRING_LENGTH (SMM_PERFORMANCE_STRING_SIZE - 1)
115
116 //
117 // The default guage entries number for SMM phase.
118 //
119 #define INIT_SMM_GAUGE_DATA_ENTRIES 200
120
121 typedef struct {
122 UINTN Function;
123 EFI_STATUS ReturnStatus;
124 UINTN NumberOfEntries;
125 UINTN LogEntryKey;
126 GAUGE_DATA_ENTRY *GaugeData;
127 } SMM_PERF_COMMUNICATE;
128
129 #define SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER 1
130 #define SMM_PERF_FUNCTION_GET_GAUGE_DATA 2
131
132 /**
133 Adds a record at the end of the performance measurement log
134 that records the start time of a performance measurement.
135
136 The added record contains the Handle, Token, and Module.
137 The end time of the new record is not recorded, so it is set to zero.
138 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
139 If TimeStamp is zero, the start time in the record is filled in with the value
140 read from the current time stamp.
141
142 @param Handle The pointer to environment specific context used
143 to identify the component being measured.
144 @param Token The pointer to a Null-terminated ASCII string
145 that identifies the component being measured.
146 @param Module The pointer to a Null-terminated ASCII string
147 that identifies the module being measured.
148 @param TimeStamp The 64-bit time stamp.
149
150 @retval EFI_SUCCESS The data was read correctly from the device.
151 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
152
153 **/
154 typedef
155 EFI_STATUS
156 (EFIAPI * PERFORMANCE_START_GAUGE)(
157 IN CONST VOID *Handle, OPTIONAL
158 IN CONST CHAR8 *Token, OPTIONAL
159 IN CONST CHAR8 *Module, OPTIONAL
160 IN UINT64 TimeStamp
161 );
162
163 /**
164 Searches the performance measurement log from the beginning of the log
165 for the first matching record that contains a zero end time and fills in a valid end time.
166
167 Searches the performance measurement log from the beginning of the log
168 for the first record that matches Handle, Token, and Module, and has an end time value of zero.
169 If the record can not be found then return EFI_NOT_FOUND.
170 If the record is found and TimeStamp is not zero,
171 then the end time in the record is filled in with the value specified by TimeStamp.
172 If the record is found and TimeStamp is zero, then the end time in the matching record
173 is filled in with the current time stamp value.
174
175 @param Handle The pointer to environment specific context used
176 to identify the component being measured.
177 @param Token The pointer to a Null-terminated ASCII string
178 that identifies the component being measured.
179 @param Module The pointer to a Null-terminated ASCII string
180 that identifies the module being measured.
181 @param TimeStamp The 64-bit time stamp.
182
183 @retval EFI_SUCCESS The end of the measurement was recorded.
184 @retval EFI_NOT_FOUND The specified measurement record could not be found.
185
186 **/
187 typedef
188 EFI_STATUS
189 (EFIAPI * PERFORMANCE_END_GAUGE)(
190 IN CONST VOID *Handle, OPTIONAL
191 IN CONST CHAR8 *Token, OPTIONAL
192 IN CONST CHAR8 *Module, OPTIONAL
193 IN UINT64 TimeStamp
194 );
195
196 /**
197 Retrieves a previously logged performance measurement.
198
199 Retrieves the performance log entry from the performance log specified by LogEntryKey.
200 If it stands for a valid entry, then EFI_SUCCESS is returned and
201 GaugeDataEntry stores the pointer to that entry.
202
203 @param LogEntryKey The key for the previous performance measurement log entry.
204 If 0, then the first performance measurement log entry is retrieved.
205 @param GaugeDataEntry Out parameter for the indirect pointer to the gauge data entry specified by LogEntryKey.
206
207 @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
208 @retval EFI_NOT_FOUND There is no entry after the measurement referred to by LogEntryKey.
209 @retval EFI_INVALID_PARAMETER The LogEntryKey is not a valid entry, or GaugeDataEntry is NULL.
210
211 **/
212 typedef
213 EFI_STATUS
214 (EFIAPI * PERFORMANCE_GET_GAUGE)(
215 IN UINTN LogEntryKey,
216 OUT GAUGE_DATA_ENTRY **GaugeDataEntry
217 );
218
219 struct _PERFORMANCE_PROTOCOL {
220 PERFORMANCE_START_GAUGE StartGauge;
221 PERFORMANCE_END_GAUGE EndGauge;
222 PERFORMANCE_GET_GAUGE GetGauge;
223 };
224
225 extern EFI_GUID gPerformanceProtocolGuid;
226 extern EFI_GUID gSmmPerformanceProtocolGuid;
227
228 #endif