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