]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/Performance.h
IntelSiliconPkg: Clean up source files
[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 - 2018, 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 #define PERFORMANCE_PROPERTY_REVISION 0x1
22
23 typedef struct {
24 UINT32 Revision;
25 UINT32 Reserved;
26 UINT64 Frequency;
27 UINT64 TimerStartValue;
28 UINT64 TimerEndValue;
29 } PERFORMANCE_PROPERTY;
30
31 //
32 // PEI_PERFORMANCE_STRING_SIZE must be a multiple of 8.
33 //
34 #define PEI_PERFORMANCE_STRING_SIZE 8
35 #define PEI_PERFORMANCE_STRING_LENGTH (PEI_PERFORMANCE_STRING_SIZE - 1)
36
37 typedef struct {
38 EFI_PHYSICAL_ADDRESS Handle;
39 CHAR8 Token[PEI_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
40 CHAR8 Module[PEI_PERFORMANCE_STRING_SIZE]; ///< Module string name.
41 UINT64 StartTimeStamp; ///< Start time point.
42 UINT64 EndTimeStamp; ///< End time point.
43 } PEI_PERFORMANCE_LOG_ENTRY;
44
45 //
46 // The header must be aligned at 8 bytes.
47 //
48 typedef struct {
49 UINT32 NumberOfEntries; ///< The number of all performance log entries.
50 UINT32 Reserved;
51 } PEI_PERFORMANCE_LOG_HEADER;
52
53
54 #define PERFORMANCE_PROTOCOL_GUID \
55 { 0x76b6bdfa, 0x2acd, 0x4462, { 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
56
57 #define PERFORMANCE_EX_PROTOCOL_GUID \
58 { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1, 0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
59
60 //
61 // Forward reference for pure ANSI compatibility
62 //
63 typedef struct _PERFORMANCE_PROTOCOL PERFORMANCE_PROTOCOL;
64 typedef struct _PERFORMANCE_EX_PROTOCOL PERFORMANCE_EX_PROTOCOL;
65
66 //
67 // DXE_PERFORMANCE_STRING_SIZE must be a multiple of 8.
68 //
69 #define DXE_PERFORMANCE_STRING_SIZE 32
70 #define DXE_PERFORMANCE_STRING_LENGTH (DXE_PERFORMANCE_STRING_SIZE - 1)
71
72 //
73 // The default guage entries number for DXE phase.
74 //
75 #define INIT_DXE_GAUGE_DATA_ENTRIES 800
76
77 typedef struct {
78 EFI_PHYSICAL_ADDRESS Handle;
79 CHAR8 Token[DXE_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
80 CHAR8 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
81 UINT64 StartTimeStamp; ///< Start time point.
82 UINT64 EndTimeStamp; ///< End time point.
83 } GAUGE_DATA_ENTRY;
84
85 typedef struct {
86 EFI_PHYSICAL_ADDRESS Handle;
87 CHAR8 Token[DXE_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
88 CHAR8 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
89 UINT64 StartTimeStamp; ///< Start time point.
90 UINT64 EndTimeStamp; ///< End time point.
91 UINT32 Identifier; ///< Identifier.
92 } GAUGE_DATA_ENTRY_EX;
93
94 //
95 // The header must be aligned at 8 bytes
96 //
97 typedef struct {
98 UINT32 NumberOfEntries; ///< The number of all performance gauge entries.
99 UINT32 Reserved;
100 } GAUGE_DATA_HEADER;
101
102 //
103 // SMM Performance Protocol definitions
104 //
105
106 #define SMM_PERFORMANCE_PROTOCOL_GUID \
107 { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
108
109 #define SMM_PERFORMANCE_EX_PROTOCOL_GUID \
110 { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 0x47, 0x6, 0x30, 0xe3, 0xe, 0xe5 } }
111
112 //
113 // SMM_PERFORMANCE_STRING_SIZE.
114 //
115 #define SMM_PERFORMANCE_STRING_SIZE 32
116 #define SMM_PERFORMANCE_STRING_LENGTH (SMM_PERFORMANCE_STRING_SIZE - 1)
117
118 //
119 // The default guage entries number for SMM phase.
120 //
121 #define INIT_SMM_GAUGE_DATA_ENTRIES 200
122
123 typedef struct {
124 UINTN Function;
125 EFI_STATUS ReturnStatus;
126 UINTN NumberOfEntries;
127 UINTN LogEntryKey;
128 GAUGE_DATA_ENTRY *GaugeData;
129 } SMM_PERF_COMMUNICATE;
130
131 typedef struct {
132 UINTN Function;
133 EFI_STATUS ReturnStatus;
134 UINTN NumberOfEntries;
135 UINTN LogEntryKey;
136 GAUGE_DATA_ENTRY_EX *GaugeDataEx;
137 } SMM_PERF_COMMUNICATE_EX;
138
139 #define SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER 1
140 #define SMM_PERF_FUNCTION_GET_GAUGE_DATA 2
141
142 /**
143 Adds a record at the end of the performance measurement log
144 that records the start time of a performance measurement.
145
146 The added record contains the Handle, Token, and Module.
147 The end time of the new record is not recorded, so it is set to zero.
148 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
149 If TimeStamp is zero, the start time in the record is filled in with the value
150 read from the current time stamp.
151
152 @param Handle The pointer to environment specific context used
153 to identify the component being measured.
154 @param Token The pointer to a Null-terminated ASCII string
155 that identifies the component being measured.
156 @param Module The pointer to a Null-terminated ASCII string
157 that identifies the module being measured.
158 @param TimeStamp The 64-bit time stamp.
159
160 @retval EFI_SUCCESS The data was read correctly from the device.
161 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
162
163 **/
164 typedef
165 EFI_STATUS
166 (EFIAPI * PERFORMANCE_START_GAUGE)(
167 IN CONST VOID *Handle, OPTIONAL
168 IN CONST CHAR8 *Token, OPTIONAL
169 IN CONST CHAR8 *Module, OPTIONAL
170 IN UINT64 TimeStamp
171 );
172
173 /**
174 Searches the performance measurement log from the beginning of the log
175 for the first matching record that contains a zero end time and fills in a valid end time.
176
177 Searches the performance measurement log from the beginning of the log
178 for the first record that matches Handle, Token, and Module, and has an end time value of zero.
179 If the record can not be found then return EFI_NOT_FOUND.
180 If the record is found and TimeStamp is not zero,
181 then the end time in the record is filled in with the value specified by TimeStamp.
182 If the record is found and TimeStamp is zero, then the end time in the matching record
183 is filled in with the current time stamp value.
184
185 @param Handle The pointer to environment specific context used
186 to identify the component being measured.
187 @param Token The pointer to a Null-terminated ASCII string
188 that identifies the component being measured.
189 @param Module The pointer to a Null-terminated ASCII string
190 that identifies the module being measured.
191 @param TimeStamp The 64-bit time stamp.
192
193 @retval EFI_SUCCESS The end of the measurement was recorded.
194 @retval EFI_NOT_FOUND The specified measurement record could not be found.
195
196 **/
197 typedef
198 EFI_STATUS
199 (EFIAPI * PERFORMANCE_END_GAUGE)(
200 IN CONST VOID *Handle, OPTIONAL
201 IN CONST CHAR8 *Token, OPTIONAL
202 IN CONST CHAR8 *Module, OPTIONAL
203 IN UINT64 TimeStamp
204 );
205
206 /**
207 Retrieves a previously logged performance measurement.
208 It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
209 and then eliminate the Identifier.
210
211 Retrieves the performance log entry from the performance log specified by LogEntryKey.
212 If it stands for a valid entry, then EFI_SUCCESS is returned and
213 GaugeDataEntry stores the pointer to that entry.
214
215 @param LogEntryKey The key for the previous performance measurement log entry.
216 If 0, then the first performance measurement log entry is retrieved.
217 @param GaugeDataEntry Out parameter for the indirect pointer to the gauge data entry specified by LogEntryKey.
218
219 @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
220 @retval EFI_NOT_FOUND There is no entry after the measurement referred to by LogEntryKey.
221 @retval EFI_INVALID_PARAMETER The LogEntryKey is not a valid entry, or GaugeDataEntry is NULL.
222
223 **/
224 typedef
225 EFI_STATUS
226 (EFIAPI * PERFORMANCE_GET_GAUGE)(
227 IN UINTN LogEntryKey,
228 OUT GAUGE_DATA_ENTRY **GaugeDataEntry
229 );
230
231 /**
232 Adds a record at the end of the performance measurement log
233 that records the start time of a performance measurement.
234
235 The added record contains the Handle, Token, Module and Identifier.
236 The end time of the new record is not recorded, so it is set to zero.
237 If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
238 If TimeStamp is zero, the start time in the record is filled in with the value
239 read from the current time stamp.
240
241 @param Handle The pointer to environment specific context used
242 to identify the component being measured.
243 @param Token The pointer to a Null-terminated ASCII string
244 that identifies the component being measured.
245 @param Module The pointer to a Null-terminated ASCII string
246 that identifies the module being measured.
247 @param TimeStamp The 64-bit time stamp.
248 @param Identifier 32-bit identifier. If the value is 0, the created record
249 is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.
250
251 @retval EFI_SUCCESS The data was read correctly from the device.
252 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
253
254 **/
255 typedef
256 EFI_STATUS
257 (EFIAPI * PERFORMANCE_START_GAUGE_EX)(
258 IN CONST VOID *Handle, OPTIONAL
259 IN CONST CHAR8 *Token, OPTIONAL
260 IN CONST CHAR8 *Module, OPTIONAL
261 IN UINT64 TimeStamp,
262 IN UINT32 Identifier
263 );
264
265 /**
266 Searches the performance measurement log from the beginning of the log
267 for the first matching record that contains a zero end time and fills in a valid end time.
268
269 Searches the performance measurement log from the beginning of the log
270 for the first record that matches Handle, Token, Module and Identifier, and has an end time value of zero.
271 If the record can not be found then return EFI_NOT_FOUND.
272 If the record is found and TimeStamp is not zero,
273 then the end time in the record is filled in with the value specified by TimeStamp.
274 If the record is found and TimeStamp is zero, then the end time in the matching record
275 is filled in with the current time stamp value.
276
277 @param Handle The pointer to environment specific context used
278 to identify the component being measured.
279 @param Token The pointer to a Null-terminated ASCII string
280 that identifies the component being measured.
281 @param Module The pointer to a Null-terminated ASCII string
282 that identifies the module being measured.
283 @param TimeStamp The 64-bit time stamp.
284 @param Identifier 32-bit identifier. If the value is 0, the found record
285 is same as the one found by EndGauge of PERFORMANCE_PROTOCOL.
286
287 @retval EFI_SUCCESS The end of the measurement was recorded.
288 @retval EFI_NOT_FOUND The specified measurement record could not be found.
289
290 **/
291 typedef
292 EFI_STATUS
293 (EFIAPI * PERFORMANCE_END_GAUGE_EX)(
294 IN CONST VOID *Handle, OPTIONAL
295 IN CONST CHAR8 *Token, OPTIONAL
296 IN CONST CHAR8 *Module, OPTIONAL
297 IN UINT64 TimeStamp,
298 IN UINT32 Identifier
299 );
300
301 /**
302 Retrieves a previously logged performance measurement.
303 It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
304 and then assign the Identifier with 0.
305
306 Retrieves the performance log entry from the performance log specified by LogEntryKey.
307 If it stands for a valid entry, then EFI_SUCCESS is returned and
308 GaugeDataEntryEx stores the pointer to that entry.
309
310 @param LogEntryKey The key for the previous performance measurement log entry.
311 If 0, then the first performance measurement log entry is retrieved.
312 @param GaugeDataEntryEx Out parameter for the indirect pointer to the extented gauge data entry specified by LogEntryKey.
313
314 @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
315 @retval EFI_NOT_FOUND There is no entry after the measurement referred to by LogEntryKey.
316 @retval EFI_INVALID_PARAMETER The LogEntryKey is not a valid entry, or GaugeDataEntryEx is NULL.
317
318 **/
319 typedef
320 EFI_STATUS
321 (EFIAPI * PERFORMANCE_GET_GAUGE_EX)(
322 IN UINTN LogEntryKey,
323 OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
324 );
325
326 struct _PERFORMANCE_PROTOCOL {
327 PERFORMANCE_START_GAUGE StartGauge;
328 PERFORMANCE_END_GAUGE EndGauge;
329 PERFORMANCE_GET_GAUGE GetGauge;
330 };
331
332 struct _PERFORMANCE_EX_PROTOCOL {
333 PERFORMANCE_START_GAUGE_EX StartGaugeEx;
334 PERFORMANCE_END_GAUGE_EX EndGaugeEx;
335 PERFORMANCE_GET_GAUGE_EX GetGaugeEx;
336 };
337
338 extern EFI_GUID gPerformanceProtocolGuid;
339 extern EFI_GUID gSmmPerformanceProtocolGuid;
340 extern EFI_GUID gPerformanceExProtocolGuid;
341 extern EFI_GUID gSmmPerformanceExProtocolGuid;
342
343 #endif