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