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