]>
Commit | Line | Data |
---|---|---|
8dbae30d | 1 | /** @file\r |
857dfc45 | 2 | Performance library instance used in PEI phase.\r |
3 | \r | |
4 | This file implements all APIs in Performance Library class in MdePkg. It creates\r | |
5 | performance logging GUIDed HOB on the first performance logging and then logs the\r | |
6 | performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum\r | |
d1102dba | 7 | number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or\r |
7c50b343 | 8 | PcdMaxPeiPerformanceLogEntries16.\r |
a0afd019 | 9 | \r |
9169f676 | 10 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
7c50b343 | 11 | (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r |
9d510e61 | 12 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a0afd019 | 13 | \r |
8dbae30d | 14 | **/\r |
a0afd019 | 15 | \r |
a0afd019 | 16 | #include <PiPei.h>\r |
ed7748fe | 17 | \r |
9169f676 | 18 | #include <Guid/ExtendedFirmwarePerformance.h>\r |
6b4d58a1 | 19 | #include <Guid/PerformanceMeasurement.h>\r |
ed7748fe | 20 | \r |
a0afd019 | 21 | #include <Library/PerformanceLib.h>\r |
22 | #include <Library/DebugLib.h>\r | |
23 | #include <Library/HobLib.h>\r | |
24 | #include <Library/BaseLib.h>\r | |
25 | #include <Library/TimerLib.h>\r | |
26 | #include <Library/PcdLib.h>\r | |
27 | #include <Library/BaseMemoryLib.h>\r | |
28 | \r | |
1436aea4 MK |
29 | #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))\r |
30 | #define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)\r | |
6b4d58a1 BD |
31 | \r |
32 | /**\r | |
33 | Return the pointer to the FPDT record in the allocated memory.\r | |
34 | \r | |
35 | @param RecordSize The size of FPDT record.\r | |
36 | @param FpdtRecordPtr Pointer the FPDT record in the allocated memory.\r | |
37 | @param PeiPerformanceLogHeader Pointer to the header of the PEI Performance records in the GUID Hob.\r | |
38 | \r | |
39 | @retval EFI_SUCCESS Successfully get the pointer to the FPDT record.\r | |
40 | @retval EFI_OUT_OF_RESOURCES Ran out of space to store the records.\r | |
41 | **/\r | |
42 | EFI_STATUS\r | |
43 | GetFpdtRecordPtr (\r | |
44 | IN UINT8 RecordSize,\r | |
45 | IN OUT FPDT_RECORD_PTR *FpdtRecordPtr,\r | |
46 | IN OUT FPDT_PEI_EXT_PERF_HEADER **PeiPerformanceLogHeader\r | |
1436aea4 | 47 | )\r |
6b4d58a1 | 48 | {\r |
1436aea4 MK |
49 | UINT16 PeiPerformanceLogEntries;\r |
50 | UINTN PeiPerformanceSize;\r | |
51 | UINT8 *PeiFirmwarePerformance;\r | |
52 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
6b4d58a1 BD |
53 | \r |
54 | //\r | |
55 | // Get the number of PeiPerformanceLogEntries form PCD.\r | |
56 | //\r | |
1436aea4 MK |
57 | PeiPerformanceLogEntries = (UINT16)(PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?\r |
58 | PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :\r | |
59 | PcdGet8 (PcdMaxPeiPerformanceLogEntries));\r | |
6b4d58a1 BD |
60 | \r |
61 | //\r | |
62 | // Create GUID HOB Data.\r | |
63 | //\r | |
1436aea4 | 64 | GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);\r |
6b4d58a1 BD |
65 | PeiFirmwarePerformance = NULL;\r |
66 | while (GuidHob != NULL) {\r | |
67 | //\r | |
68 | // PEI Performance HOB was found, then return the existing one.\r | |
69 | //\r | |
1436aea4 | 70 | PeiFirmwarePerformance = (UINT8 *)GET_GUID_HOB_DATA (GuidHob);\r |
6b4d58a1 | 71 | *PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;\r |
1436aea4 | 72 | if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {\r |
6b4d58a1 BD |
73 | (*PeiPerformanceLogHeader)->HobIsFull = TRUE;\r |
74 | }\r | |
1436aea4 MK |
75 | \r |
76 | if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {\r | |
6b4d58a1 BD |
77 | FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + (*PeiPerformanceLogHeader)->SizeOfAllEntries);\r |
78 | break;\r | |
79 | }\r | |
1436aea4 | 80 | \r |
6b4d58a1 BD |
81 | //\r |
82 | // Previous HOB is used, then find next one.\r | |
83 | //\r | |
84 | GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));\r | |
85 | }\r | |
86 | \r | |
87 | if (GuidHob == NULL) {\r | |
88 | //\r | |
89 | // PEI Performance HOB was not found, then build one.\r | |
90 | //\r | |
1436aea4 MK |
91 | PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) +\r |
92 | PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;\r | |
93 | PeiFirmwarePerformance = (UINT8 *)BuildGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, PeiPerformanceSize);\r | |
6b4d58a1 BD |
94 | if (PeiFirmwarePerformance != NULL) {\r |
95 | ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize);\r | |
1436aea4 | 96 | (*PeiPerformanceLogHeader) = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;\r |
6b4d58a1 BD |
97 | FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER));\r |
98 | }\r | |
99 | }\r | |
100 | \r | |
101 | if (PeiFirmwarePerformance == NULL) {\r | |
102 | //\r | |
103 | // there is no enough resource to store performance data\r | |
104 | //\r | |
105 | return EFI_OUT_OF_RESOURCES;\r | |
106 | }\r | |
107 | \r | |
108 | return EFI_SUCCESS;\r | |
109 | }\r | |
a0afd019 | 110 | \r |
111 | /**\r | |
9169f676 | 112 | Check whether the Token is a known one which is uesed by core.\r |
a0afd019 | 113 | \r |
9169f676 | 114 | @param Token Pointer to a Null-terminated ASCII string\r |
a0afd019 | 115 | \r |
9169f676 DB |
116 | @retval TRUE Is a known one used by core.\r |
117 | @retval FALSE Not a known one.\r | |
a0afd019 | 118 | \r |
119 | **/\r | |
9169f676 DB |
120 | BOOLEAN\r |
121 | IsKnownTokens (\r | |
122 | IN CONST CHAR8 *Token\r | |
a0afd019 | 123 | )\r |
124 | {\r | |
c9faac27 DB |
125 | if (Token == NULL) {\r |
126 | return FALSE;\r | |
127 | }\r | |
128 | \r | |
1436aea4 MK |
129 | if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||\r |
130 | (AsciiStrCmp (Token, PEI_TOK) == 0) ||\r | |
131 | (AsciiStrCmp (Token, DXE_TOK) == 0) ||\r | |
132 | (AsciiStrCmp (Token, BDS_TOK) == 0) ||\r | |
133 | (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||\r | |
134 | (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||\r | |
135 | (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||\r | |
136 | (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||\r | |
137 | (AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||\r | |
138 | (AsciiStrCmp (Token, PEIM_TOK) == 0))\r | |
139 | {\r | |
9169f676 DB |
140 | return TRUE;\r |
141 | } else {\r | |
142 | return FALSE;\r | |
143 | }\r | |
144 | }\r | |
f0da4d7d | 145 | \r |
9169f676 DB |
146 | /**\r |
147 | Check whether the ID is a known one which map to the known Token.\r | |
a0afd019 | 148 | \r |
9169f676 | 149 | @param Identifier 32-bit identifier.\r |
a0afd019 | 150 | \r |
9169f676 DB |
151 | @retval TRUE Is a known one used by core.\r |
152 | @retval FALSE Not a known one.\r | |
f0da4d7d | 153 | \r |
9169f676 DB |
154 | **/\r |
155 | BOOLEAN\r | |
156 | IsKnownID (\r | |
1436aea4 | 157 | IN UINT32 Identifier\r |
9169f676 DB |
158 | )\r |
159 | {\r | |
1436aea4 MK |
160 | if ((Identifier == MODULE_START_ID) ||\r |
161 | (Identifier == MODULE_END_ID) ||\r | |
162 | (Identifier == MODULE_LOADIMAGE_START_ID) ||\r | |
163 | (Identifier == MODULE_LOADIMAGE_END_ID) ||\r | |
164 | (Identifier == MODULE_DB_START_ID) ||\r | |
165 | (Identifier == MODULE_DB_END_ID) ||\r | |
166 | (Identifier == MODULE_DB_SUPPORT_START_ID) ||\r | |
167 | (Identifier == MODULE_DB_SUPPORT_END_ID) ||\r | |
168 | (Identifier == MODULE_DB_STOP_START_ID) ||\r | |
169 | (Identifier == MODULE_DB_STOP_END_ID))\r | |
170 | {\r | |
9169f676 | 171 | return TRUE;\r |
a0afd019 | 172 | } else {\r |
9169f676 | 173 | return FALSE;\r |
a0afd019 | 174 | }\r |
a0afd019 | 175 | }\r |
176 | \r | |
177 | /**\r | |
6b4d58a1 | 178 | Get the FPDT record identifier.\r |
a0afd019 | 179 | \r |
6b4d58a1 BD |
180 | @param Attribute The attribute of the Record.\r |
181 | PerfStartEntry: Start Record.\r | |
182 | PerfEndEntry: End Record.\r | |
183 | @param Handle Pointer to environment specific context used to identify the component being measured.\r | |
184 | @param String Pointer to a Null-terminated ASCII string that identifies the component being measured.\r | |
185 | @param ProgressID On return, pointer to the ProgressID.\r | |
a0afd019 | 186 | \r |
6b4d58a1 BD |
187 | @retval EFI_SUCCESS Get record info successfully.\r |
188 | @retval EFI_INVALID_PARAMETER No matched FPDT record.\r | |
a0afd019 | 189 | \r |
190 | **/\r | |
9169f676 | 191 | EFI_STATUS\r |
6b4d58a1 | 192 | GetFpdtRecordId (\r |
1436aea4 MK |
193 | IN BOOLEAN Attribute,\r |
194 | IN CONST VOID *Handle,\r | |
195 | IN CONST CHAR8 *String,\r | |
196 | OUT UINT16 *ProgressID\r | |
a0afd019 | 197 | )\r |
198 | {\r | |
9169f676 DB |
199 | //\r |
200 | // Get the ProgressID based on the Token.\r | |
201 | // When PcdEdkiiFpdtStringRecordEnableOnly is TRUE, all records are with type of FPDT_DYNAMIC_STRING_EVENT_TYPE.\r | |
202 | //\r | |
6b4d58a1 | 203 | if (String != NULL) {\r |
1436aea4 MK |
204 | if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {\r |
205 | // "LoadImage:"\r | |
6b4d58a1 BD |
206 | if (Attribute == PerfStartEntry) {\r |
207 | *ProgressID = MODULE_LOADIMAGE_START_ID;\r | |
9169f676 | 208 | } else {\r |
6b4d58a1 | 209 | *ProgressID = MODULE_LOADIMAGE_END_ID;\r |
9169f676 | 210 | }\r |
1436aea4 MK |
211 | } else if ((AsciiStrCmp (String, SEC_TOK) == 0) || // "SEC"\r |
212 | (AsciiStrCmp (String, PEI_TOK) == 0)) // "PEI"\r | |
213 | {\r | |
6b4d58a1 BD |
214 | if (Attribute == PerfStartEntry) {\r |
215 | *ProgressID = PERF_CROSSMODULE_START_ID;\r | |
9169f676 | 216 | } else {\r |
6b4d58a1 | 217 | *ProgressID = PERF_CROSSMODULE_END_ID;\r |
9169f676 | 218 | }\r |
1436aea4 MK |
219 | } else if (AsciiStrCmp (String, PEIM_TOK) == 0) {\r |
220 | // "PEIM"\r | |
6b4d58a1 BD |
221 | if (Attribute == PerfStartEntry) {\r |
222 | *ProgressID = MODULE_START_ID;\r | |
9169f676 | 223 | } else {\r |
6b4d58a1 | 224 | *ProgressID = MODULE_END_ID;\r |
9169f676 | 225 | }\r |
1436aea4 MK |
226 | } else {\r |
227 | // Pref used in Modules.\r | |
6b4d58a1 BD |
228 | if (Attribute == PerfStartEntry) {\r |
229 | *ProgressID = PERF_INMODULE_START_ID;\r | |
9169f676 | 230 | } else {\r |
6b4d58a1 | 231 | *ProgressID = PERF_INMODULE_END_ID;\r |
9169f676 DB |
232 | }\r |
233 | }\r | |
1436aea4 MK |
234 | } else if (Handle != NULL) {\r |
235 | // Pref used in Modules.\r | |
6b4d58a1 BD |
236 | if (Attribute == PerfStartEntry) {\r |
237 | *ProgressID = PERF_INMODULE_START_ID;\r | |
9169f676 | 238 | } else {\r |
6b4d58a1 | 239 | *ProgressID = PERF_INMODULE_END_ID;\r |
9169f676 DB |
240 | }\r |
241 | } else {\r | |
6b4d58a1 | 242 | return EFI_INVALID_PARAMETER;\r |
a0afd019 | 243 | }\r |
9169f676 | 244 | \r |
6b4d58a1 BD |
245 | return EFI_SUCCESS;\r |
246 | }\r | |
9169f676 | 247 | \r |
6b4d58a1 BD |
248 | /**\r |
249 | Copies the string from Source into Destination and updates Length with the\r | |
250 | size of the string.\r | |
9169f676 | 251 | \r |
6b4d58a1 BD |
252 | @param Destination - destination of the string copy\r |
253 | @param Source - pointer to the source string which will get copied\r | |
254 | @param Length - pointer to a length variable to be updated\r | |
9169f676 | 255 | \r |
6b4d58a1 BD |
256 | **/\r |
257 | VOID\r | |
258 | CopyStringIntoPerfRecordAndUpdateLength (\r | |
1436aea4 | 259 | IN OUT CHAR8 *Destination,\r |
6b4d58a1 | 260 | IN CONST CHAR8 *Source,\r |
1436aea4 | 261 | IN OUT UINT8 *Length\r |
6b4d58a1 BD |
262 | )\r |
263 | {\r | |
264 | UINTN StringLen;\r | |
265 | UINTN DestMax;\r | |
266 | \r | |
267 | ASSERT (Source != NULL);\r | |
268 | \r | |
269 | if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
270 | DestMax = STRING_SIZE;\r | |
271 | } else {\r | |
272 | DestMax = AsciiStrSize (Source);\r | |
273 | if (DestMax > STRING_SIZE) {\r | |
274 | DestMax = STRING_SIZE;\r | |
a0afd019 | 275 | }\r |
276 | }\r | |
1436aea4 | 277 | \r |
6b4d58a1 BD |
278 | StringLen = AsciiStrLen (Source);\r |
279 | if (StringLen >= DestMax) {\r | |
280 | StringLen = DestMax -1;\r | |
281 | }\r | |
282 | \r | |
1436aea4 | 283 | AsciiStrnCpyS (Destination, DestMax, Source, StringLen);\r |
6b4d58a1 BD |
284 | *Length += (UINT8)DestMax;\r |
285 | \r | |
286 | return;\r | |
a0afd019 | 287 | }\r |
288 | \r | |
289 | /**\r | |
9169f676 | 290 | Convert PEI performance log to FPDT String boot record.\r |
a0afd019 | 291 | \r |
6b4d58a1 BD |
292 | @param CallerIdentifier - Image handle or pointer to caller ID GUID.\r |
293 | @param Guid - Pointer to a GUID.\r | |
294 | @param String - Pointer to a string describing the measurement.\r | |
295 | @param Ticker - 64-bit time stamp.\r | |
296 | @param Address - Pointer to a location in memory relevant to the measurement.\r | |
297 | @param PerfId - Performance identifier describing the type of measurement.\r | |
298 | @param Attribute - The attribute of the measurement. According to attribute can create a start\r | |
299 | record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,\r | |
300 | or a general record for other Perf macros.\r | |
301 | \r | |
302 | @retval EFI_SUCCESS - Successfully created performance record.\r | |
303 | @retval EFI_OUT_OF_RESOURCES - Ran out of space to store the records.\r | |
304 | @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r | |
305 | pointer or invalid PerfId.\r | |
a0afd019 | 306 | \r |
307 | **/\r | |
9169f676 | 308 | EFI_STATUS\r |
6b4d58a1 | 309 | InsertFpdtRecord (\r |
e3917e22 MK |
310 | IN CONST VOID *CallerIdentifier OPTIONAL,\r |
311 | IN CONST VOID *Guid OPTIONAL,\r | |
312 | IN CONST CHAR8 *String OPTIONAL,\r | |
6b4d58a1 | 313 | IN UINT64 Ticker,\r |
e3917e22 | 314 | IN UINT64 Address OPTIONAL,\r |
6b4d58a1 BD |
315 | IN UINT16 PerfId,\r |
316 | IN PERF_MEASUREMENT_ATTRIBUTE Attribute\r | |
a0afd019 | 317 | )\r |
318 | {\r | |
1436aea4 MK |
319 | FPDT_RECORD_PTR FpdtRecordPtr;\r |
320 | CONST VOID *ModuleGuid;\r | |
321 | CONST CHAR8 *StringPtr;\r | |
322 | EFI_STATUS Status;\r | |
323 | UINT64 TimeStamp;\r | |
324 | FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;\r | |
325 | \r | |
326 | StringPtr = NULL;\r | |
9169f676 | 327 | FpdtRecordPtr.RecordHeader = NULL;\r |
1436aea4 | 328 | PeiPerformanceLogHeader = NULL;\r |
9169f676 DB |
329 | \r |
330 | //\r | |
6b4d58a1 BD |
331 | // 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_EX/PERF_END_EX.\r |
332 | // notes: For other Perf macros (Attribute == PerfEntry), their Id is known.\r | |
9169f676 | 333 | //\r |
6b4d58a1 | 334 | if (Attribute != PerfEntry) {\r |
9169f676 | 335 | //\r |
6b4d58a1 BD |
336 | // If PERF_START_EX()/PERF_END_EX() have specified the ProgressID,it has high priority.\r |
337 | // !!! Note: If the Perf is not the known Token used in the core but have same\r | |
338 | // ID with the core Token, this case will not be supported.\r | |
339 | // And in currtnt usage mode, for the unkown ID, there is a general rule:\r | |
340 | // If it is start pref: the lower 4 bits of the ID should be 0.\r | |
341 | // If it is end pref: the lower 4 bits of the ID should not be 0.\r | |
342 | // If input ID doesn't follow the rule, we will adjust it.\r | |
9169f676 | 343 | //\r |
6b4d58a1 BD |
344 | if ((PerfId != 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String))) {\r |
345 | return EFI_UNSUPPORTED;\r | |
346 | } else if ((PerfId != 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens (String))) {\r | |
1436aea4 | 347 | if ((Attribute == PerfStartEntry) && ((PerfId & 0x000F) != 0)) {\r |
6b4d58a1 BD |
348 | PerfId &= 0xFFF0;\r |
349 | } else if ((Attribute == PerfEndEntry) && ((PerfId & 0x000F) == 0)) {\r | |
350 | PerfId += 1;\r | |
351 | }\r | |
352 | } else if (PerfId == 0) {\r | |
353 | Status = GetFpdtRecordId (Attribute, CallerIdentifier, String, &PerfId);\r | |
354 | if (EFI_ERROR (Status)) {\r | |
355 | return Status;\r | |
356 | }\r | |
9169f676 | 357 | }\r |
a0afd019 | 358 | }\r |
a0afd019 | 359 | \r |
6b4d58a1 BD |
360 | //\r |
361 | // 2. Get the buffer to store the FPDT record.\r | |
362 | //\r | |
363 | Status = GetFpdtRecordPtr (PEI_MAX_RECORD_SIZE, &FpdtRecordPtr, &PeiPerformanceLogHeader);\r | |
364 | if (EFI_ERROR (Status)) {\r | |
365 | return Status;\r | |
9169f676 DB |
366 | }\r |
367 | \r | |
368 | //\r | |
6b4d58a1 | 369 | // 3 Get the TimeStamp.\r |
9169f676 DB |
370 | //\r |
371 | if (Ticker == 0) {\r | |
372 | Ticker = GetPerformanceCounter ();\r | |
373 | TimeStamp = GetTimeInNanoSecond (Ticker);\r | |
374 | } else if (Ticker == 1) {\r | |
375 | TimeStamp = 0;\r | |
376 | } else {\r | |
377 | TimeStamp = GetTimeInNanoSecond (Ticker);\r | |
a0afd019 | 378 | }\r |
9169f676 DB |
379 | \r |
380 | //\r | |
6b4d58a1 | 381 | // 4.Get the ModuleGuid.\r |
9169f676 | 382 | //\r |
6b4d58a1 BD |
383 | if (CallerIdentifier != NULL) {\r |
384 | ModuleGuid = CallerIdentifier;\r | |
9169f676 DB |
385 | } else {\r |
386 | ModuleGuid = &gEfiCallerIdGuid;\r | |
a0afd019 | 387 | }\r |
388 | \r | |
6b4d58a1 BD |
389 | //\r |
390 | // 5. Fill in the FPDT record according to different Performance Identifier.\r | |
391 | //\r | |
392 | switch (PerfId) {\r | |
1436aea4 MK |
393 | case MODULE_START_ID:\r |
394 | case MODULE_END_ID:\r | |
395 | StringPtr = PEIM_TOK;\r | |
396 | if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
397 | FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;\r | |
398 | FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);\r | |
399 | FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
400 | FpdtRecordPtr.GuidEvent->ProgressID = PerfId;\r | |
401 | FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;\r | |
402 | CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUID));\r | |
6b4d58a1 | 403 | }\r |
1436aea4 MK |
404 | \r |
405 | break;\r | |
406 | \r | |
407 | case MODULE_LOADIMAGE_START_ID:\r | |
408 | case MODULE_LOADIMAGE_END_ID:\r | |
409 | StringPtr = LOAD_IMAGE_TOK;\r | |
410 | if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
411 | FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;\r | |
412 | FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);\r | |
413 | FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
414 | FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;\r | |
415 | FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;\r | |
416 | if (PerfId == MODULE_LOADIMAGE_START_ID) {\r | |
417 | PeiPerformanceLogHeader->LoadImageCount++;\r | |
418 | }\r | |
419 | \r | |
420 | FpdtRecordPtr.GuidQwordEvent->Qword = PeiPerformanceLogHeader->LoadImageCount;\r | |
421 | CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EFI_GUID));\r | |
422 | }\r | |
423 | \r | |
424 | break;\r | |
425 | \r | |
426 | case PERF_EVENTSIGNAL_START_ID:\r | |
427 | case PERF_EVENTSIGNAL_END_ID:\r | |
428 | case PERF_CALLBACK_START_ID:\r | |
429 | case PERF_CALLBACK_END_ID:\r | |
430 | if ((String == NULL) || (Guid == NULL)) {\r | |
431 | return EFI_INVALID_PARAMETER;\r | |
432 | }\r | |
433 | \r | |
6b4d58a1 | 434 | StringPtr = String;\r |
1436aea4 MK |
435 | if (AsciiStrLen (String) == 0) {\r |
436 | StringPtr = "unknown name";\r | |
437 | }\r | |
438 | \r | |
439 | if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
440 | FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;\r | |
441 | FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);\r | |
442 | FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
443 | FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;\r | |
444 | FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;\r | |
445 | CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));\r | |
446 | CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));\r | |
447 | CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);\r | |
448 | }\r | |
449 | \r | |
450 | break;\r | |
451 | \r | |
452 | case PERF_EVENT_ID:\r | |
453 | case PERF_FUNCTION_START_ID:\r | |
454 | case PERF_FUNCTION_END_ID:\r | |
455 | case PERF_INMODULE_START_ID:\r | |
456 | case PERF_INMODULE_END_ID:\r | |
457 | case PERF_CROSSMODULE_START_ID:\r | |
458 | case PERF_CROSSMODULE_END_ID:\r | |
459 | if ((String != NULL) && (AsciiStrLen (String) != 0)) {\r | |
460 | StringPtr = String;\r | |
461 | } else {\r | |
462 | StringPtr = "unknown name";\r | |
463 | }\r | |
464 | \r | |
465 | if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
466 | FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;\r | |
467 | FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);\r | |
468 | FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
469 | FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;\r | |
470 | FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;\r | |
471 | CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));\r | |
472 | CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);\r | |
473 | }\r | |
474 | \r | |
475 | break;\r | |
476 | \r | |
477 | default:\r | |
478 | if (Attribute != PerfEntry) {\r | |
479 | if ((String != NULL) && (AsciiStrLen (String) != 0)) {\r | |
480 | StringPtr = String;\r | |
481 | } else {\r | |
482 | StringPtr = "unknown name";\r | |
483 | }\r | |
484 | \r | |
485 | if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
486 | FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;\r | |
487 | FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);\r | |
488 | FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
489 | FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;\r | |
490 | FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;\r | |
491 | CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));\r | |
492 | CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);\r | |
493 | }\r | |
494 | } else {\r | |
495 | return EFI_INVALID_PARAMETER;\r | |
496 | }\r | |
497 | \r | |
498 | break;\r | |
6b4d58a1 BD |
499 | }\r |
500 | \r | |
501 | //\r | |
502 | // 5.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.\r | |
503 | //\r | |
504 | if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {\r | |
1436aea4 MK |
505 | FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;\r |
506 | FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);\r | |
507 | FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;\r | |
508 | FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;\r | |
509 | FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;\r | |
6b4d58a1 BD |
510 | if (Guid != NULL) {\r |
511 | //\r | |
512 | // Cache the event guid in string event record.\r | |
513 | //\r | |
514 | CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (EFI_GUID));\r | |
515 | } else {\r | |
516 | CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));\r | |
517 | }\r | |
1436aea4 | 518 | \r |
6b4d58a1 | 519 | CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);\r |
a0afd019 | 520 | }\r |
a0afd019 | 521 | \r |
6b4d58a1 BD |
522 | //\r |
523 | // 6. Update the length of the used buffer after fill in the record.\r | |
524 | //\r | |
525 | PeiPerformanceLogHeader->SizeOfAllEntries += FpdtRecordPtr.RecordHeader->Length;\r | |
526 | \r | |
9169f676 | 527 | return EFI_SUCCESS;\r |
a0afd019 | 528 | }\r |
529 | \r | |
530 | /**\r | |
9169f676 DB |
531 | Creates a record for the beginning of a performance measurement.\r |
532 | \r | |
533 | If TimeStamp is zero, then this function reads the current time stamp\r | |
534 | and adds that time stamp value to the record as the start time.\r | |
535 | \r | |
536 | If TimeStamp is one, then this function reads 0 as the start time.\r | |
a0afd019 | 537 | \r |
9169f676 DB |
538 | If TimeStamp is other value, then TimeStamp is added to the record as the start time.\r |
539 | \r | |
540 | @param Handle Pointer to environment specific context used\r | |
541 | to identify the component being measured.\r | |
542 | @param Token Pointer to a Null-terminated ASCII string\r | |
543 | that identifies the component being measured.\r | |
544 | @param Module Pointer to a Null-terminated ASCII string\r | |
545 | that identifies the module being measured.\r | |
546 | @param TimeStamp 64-bit time stamp.\r | |
547 | @param Identifier 32-bit identifier. If the value is 0, the created record\r | |
548 | is same as the one created by StartPerformanceMeasurement.\r | |
549 | \r | |
550 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
551 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
552 | \r | |
553 | **/\r | |
554 | RETURN_STATUS\r | |
555 | EFIAPI\r | |
556 | StartPerformanceMeasurementEx (\r | |
e3917e22 MK |
557 | IN CONST VOID *Handle OPTIONAL,\r |
558 | IN CONST CHAR8 *Token OPTIONAL,\r | |
559 | IN CONST CHAR8 *Module OPTIONAL,\r | |
9169f676 DB |
560 | IN UINT64 TimeStamp,\r |
561 | IN UINT32 Identifier\r | |
562 | )\r | |
563 | {\r | |
1436aea4 | 564 | CONST CHAR8 *String;\r |
6b4d58a1 BD |
565 | \r |
566 | if (Token != NULL) {\r | |
567 | String = Token;\r | |
568 | } else if (Module != NULL) {\r | |
569 | String = Module;\r | |
570 | } else {\r | |
571 | String = NULL;\r | |
572 | }\r | |
573 | \r | |
574 | return (RETURN_STATUS)InsertFpdtRecord (Handle, NULL, String, TimeStamp, 0, (UINT16)Identifier, PerfStartEntry);\r | |
9169f676 DB |
575 | }\r |
576 | \r | |
577 | /**\r | |
578 | \r | |
579 | Creates a record for the end of a performance measurement.\r | |
580 | \r | |
581 | If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.\r | |
582 | If the TimeStamp is zero, then this function reads the current time stamp and adds that time stamp value to the record as the end time.\r | |
583 | If the TimeStamp is one, then this function reads 0 as the end time.\r | |
a0afd019 | 584 | \r |
585 | @param Handle Pointer to environment specific context used\r | |
586 | to identify the component being measured.\r | |
587 | @param Token Pointer to a Null-terminated ASCII string\r | |
588 | that identifies the component being measured.\r | |
589 | @param Module Pointer to a Null-terminated ASCII string\r | |
590 | that identifies the module being measured.\r | |
591 | @param TimeStamp 64-bit time stamp.\r | |
f0da4d7d SZ |
592 | @param Identifier 32-bit identifier. If the value is 0, the found record\r |
593 | is same as the one found by EndPerformanceMeasurement.\r | |
a0afd019 | 594 | \r |
595 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
596 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
597 | \r | |
598 | **/\r | |
599 | RETURN_STATUS\r | |
600 | EFIAPI\r | |
f0da4d7d | 601 | EndPerformanceMeasurementEx (\r |
e3917e22 MK |
602 | IN CONST VOID *Handle OPTIONAL,\r |
603 | IN CONST CHAR8 *Token OPTIONAL,\r | |
604 | IN CONST CHAR8 *Module OPTIONAL,\r | |
f0da4d7d SZ |
605 | IN UINT64 TimeStamp,\r |
606 | IN UINT32 Identifier\r | |
a0afd019 | 607 | )\r |
608 | {\r | |
1436aea4 | 609 | CONST CHAR8 *String;\r |
6b4d58a1 BD |
610 | \r |
611 | if (Token != NULL) {\r | |
612 | String = Token;\r | |
613 | } else if (Module != NULL) {\r | |
614 | String = Module;\r | |
615 | } else {\r | |
616 | String = NULL;\r | |
617 | }\r | |
618 | \r | |
619 | return (RETURN_STATUS)InsertFpdtRecord (Handle, NULL, String, TimeStamp, 0, (UINT16)Identifier, PerfEndEntry);\r | |
a0afd019 | 620 | }\r |
621 | \r | |
622 | /**\r | |
623 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r | |
f0da4d7d SZ |
624 | It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r |
625 | and then assign the Identifier with 0.\r | |
a0afd019 | 626 | \r |
627 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r | |
628 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
629 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
630 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
631 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
632 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
633 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
634 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
635 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
f0da4d7d | 636 | the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r |
a0afd019 | 637 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r |
638 | If Handle is NULL, then ASSERT().\r | |
639 | If Token is NULL, then ASSERT().\r | |
640 | If Module is NULL, then ASSERT().\r | |
641 | If StartTimeStamp is NULL, then ASSERT().\r | |
642 | If EndTimeStamp is NULL, then ASSERT().\r | |
f0da4d7d | 643 | If Identifier is NULL, then ASSERT().\r |
a0afd019 | 644 | \r |
9169f676 DB |
645 | !!!NOT Support yet!!!\r |
646 | \r | |
a0afd019 | 647 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r |
648 | 0, then the first performance measurement log entry is retrieved.\r | |
f0da4d7d | 649 | On exit, the key of the next performance of entry entry.\r |
a0afd019 | 650 | @param Handle Pointer to environment specific context used to identify the component\r |
651 | being measured.\r | |
652 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r | |
653 | being measured.\r | |
654 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r | |
655 | being measured.\r | |
656 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
657 | was started.\r | |
658 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
659 | was ended.\r | |
f0da4d7d | 660 | @param Identifier Pointer to the 32-bit identifier that was recorded.\r |
a0afd019 | 661 | \r |
662 | @return The key for the next performance log entry (in general case).\r | |
663 | \r | |
664 | **/\r | |
665 | UINTN\r | |
666 | EFIAPI\r | |
f0da4d7d | 667 | GetPerformanceMeasurementEx (\r |
1436aea4 MK |
668 | IN UINTN LogEntryKey,\r |
669 | OUT CONST VOID **Handle,\r | |
670 | OUT CONST CHAR8 **Token,\r | |
671 | OUT CONST CHAR8 **Module,\r | |
672 | OUT UINT64 *StartTimeStamp,\r | |
673 | OUT UINT64 *EndTimeStamp,\r | |
674 | OUT UINT32 *Identifier\r | |
a0afd019 | 675 | )\r |
676 | {\r | |
9169f676 | 677 | return 0;\r |
a0afd019 | 678 | }\r |
679 | \r | |
f0da4d7d SZ |
680 | /**\r |
681 | Creates a record for the beginning of a performance measurement.\r | |
682 | \r | |
f0da4d7d SZ |
683 | If TimeStamp is zero, then this function reads the current time stamp\r |
684 | and adds that time stamp value to the record as the start time.\r | |
685 | \r | |
9169f676 DB |
686 | If TimeStamp is one, then this function reads 0 as the start time.\r |
687 | \r | |
688 | If TimeStamp is other value, then TimeStamp is added to the record as the start time.\r | |
689 | \r | |
690 | \r | |
f0da4d7d SZ |
691 | @param Handle Pointer to environment specific context used\r |
692 | to identify the component being measured.\r | |
693 | @param Token Pointer to a Null-terminated ASCII string\r | |
694 | that identifies the component being measured.\r | |
695 | @param Module Pointer to a Null-terminated ASCII string\r | |
696 | that identifies the module being measured.\r | |
697 | @param TimeStamp 64-bit time stamp.\r | |
698 | \r | |
699 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
700 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
701 | \r | |
702 | **/\r | |
703 | RETURN_STATUS\r | |
704 | EFIAPI\r | |
705 | StartPerformanceMeasurement (\r | |
e3917e22 MK |
706 | IN CONST VOID *Handle OPTIONAL,\r |
707 | IN CONST CHAR8 *Token OPTIONAL,\r | |
708 | IN CONST CHAR8 *Module OPTIONAL,\r | |
f0da4d7d SZ |
709 | IN UINT64 TimeStamp\r |
710 | )\r | |
711 | {\r | |
6b4d58a1 | 712 | return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r |
f0da4d7d SZ |
713 | }\r |
714 | \r | |
715 | /**\r | |
f0da4d7d | 716 | \r |
9169f676 DB |
717 | Creates a record for the end of a performance measurement.\r |
718 | \r | |
719 | If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.\r | |
720 | If the TimeStamp is zero, then this function reads the current time stamp and adds that time stamp value to the record as the end time.\r | |
721 | If the TimeStamp is one, then this function reads 0 as the end time.\r | |
f0da4d7d SZ |
722 | \r |
723 | @param Handle Pointer to environment specific context used\r | |
724 | to identify the component being measured.\r | |
725 | @param Token Pointer to a Null-terminated ASCII string\r | |
726 | that identifies the component being measured.\r | |
727 | @param Module Pointer to a Null-terminated ASCII string\r | |
728 | that identifies the module being measured.\r | |
729 | @param TimeStamp 64-bit time stamp.\r | |
730 | \r | |
731 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
732 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
733 | \r | |
734 | **/\r | |
735 | RETURN_STATUS\r | |
736 | EFIAPI\r | |
737 | EndPerformanceMeasurement (\r | |
e3917e22 MK |
738 | IN CONST VOID *Handle OPTIONAL,\r |
739 | IN CONST CHAR8 *Token OPTIONAL,\r | |
740 | IN CONST CHAR8 *Module OPTIONAL,\r | |
f0da4d7d SZ |
741 | IN UINT64 TimeStamp\r |
742 | )\r | |
743 | {\r | |
6b4d58a1 | 744 | return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);\r |
f0da4d7d SZ |
745 | }\r |
746 | \r | |
747 | /**\r | |
748 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r | |
749 | It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r | |
750 | and then eliminate the Identifier.\r | |
751 | \r | |
752 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r | |
753 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
754 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
755 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
756 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
757 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
758 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
759 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
760 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
761 | the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r | |
762 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
763 | If Handle is NULL, then ASSERT().\r | |
764 | If Token is NULL, then ASSERT().\r | |
765 | If Module is NULL, then ASSERT().\r | |
766 | If StartTimeStamp is NULL, then ASSERT().\r | |
767 | If EndTimeStamp is NULL, then ASSERT().\r | |
768 | \r | |
9169f676 DB |
769 | NOT Support yet.\r |
770 | \r | |
f0da4d7d SZ |
771 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r |
772 | 0, then the first performance measurement log entry is retrieved.\r | |
773 | On exit, the key of the next performance of entry entry.\r | |
774 | @param Handle Pointer to environment specific context used to identify the component\r | |
775 | being measured.\r | |
776 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r | |
777 | being measured.\r | |
778 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r | |
779 | being measured.\r | |
780 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
781 | was started.\r | |
782 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
783 | was ended.\r | |
784 | \r | |
785 | @return The key for the next performance log entry (in general case).\r | |
786 | \r | |
787 | **/\r | |
788 | UINTN\r | |
789 | EFIAPI\r | |
790 | GetPerformanceMeasurement (\r | |
1436aea4 MK |
791 | IN UINTN LogEntryKey,\r |
792 | OUT CONST VOID **Handle,\r | |
793 | OUT CONST CHAR8 **Token,\r | |
794 | OUT CONST CHAR8 **Module,\r | |
795 | OUT UINT64 *StartTimeStamp,\r | |
796 | OUT UINT64 *EndTimeStamp\r | |
f0da4d7d SZ |
797 | )\r |
798 | {\r | |
9169f676 | 799 | return 0;\r |
f0da4d7d SZ |
800 | }\r |
801 | \r | |
a0afd019 | 802 | /**\r |
803 | Returns TRUE if the performance measurement macros are enabled.\r | |
804 | \r | |
805 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
806 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r | |
807 | \r | |
808 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
809 | PcdPerformanceLibraryPropertyMask is set.\r | |
810 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
811 | PcdPerformanceLibraryPropertyMask is clear.\r | |
812 | \r | |
813 | **/\r | |
814 | BOOLEAN\r | |
815 | EFIAPI\r | |
816 | PerformanceMeasurementEnabled (\r | |
817 | VOID\r | |
818 | )\r | |
819 | {\r | |
1436aea4 | 820 | return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r |
a0afd019 | 821 | }\r |
6b4d58a1 BD |
822 | \r |
823 | /**\r | |
824 | Create performance record with event description and a timestamp.\r | |
825 | \r | |
826 | @param CallerIdentifier - Image handle or pointer to caller ID GUID\r | |
827 | @param Guid - Pointer to a GUID\r | |
828 | @param String - Pointer to a string describing the measurement\r | |
829 | @param Address - Pointer to a location in memory relevant to the measurement\r | |
830 | @param Identifier - Performance identifier describing the type of measurement\r | |
831 | \r | |
832 | @retval RETURN_SUCCESS - Successfully created performance record\r | |
833 | @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records\r | |
834 | @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r | |
835 | pointer or invalid PerfId\r | |
836 | \r | |
837 | **/\r | |
838 | RETURN_STATUS\r | |
839 | EFIAPI\r | |
840 | LogPerformanceMeasurement (\r | |
841 | IN CONST VOID *CallerIdentifier,\r | |
e3917e22 MK |
842 | IN CONST VOID *Guid OPTIONAL,\r |
843 | IN CONST CHAR8 *String OPTIONAL,\r | |
844 | IN UINT64 Address OPTIONAL,\r | |
6b4d58a1 BD |
845 | IN UINT32 Identifier\r |
846 | )\r | |
847 | {\r | |
848 | return (RETURN_STATUS)InsertFpdtRecord (CallerIdentifier, Guid, String, 0, Address, (UINT16)Identifier, PerfEntry);\r | |
849 | }\r | |
850 | \r | |
851 | /**\r | |
852 | Check whether the specified performance measurement can be logged.\r | |
853 | \r | |
854 | This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set\r | |
855 | and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.\r | |
856 | \r | |
857 | @param Type - Type of the performance measurement entry.\r | |
858 | \r | |
859 | @retval TRUE The performance measurement can be logged.\r | |
860 | @retval FALSE The performance measurement can NOT be logged.\r | |
861 | \r | |
862 | **/\r | |
863 | BOOLEAN\r | |
864 | EFIAPI\r | |
865 | LogPerformanceMeasurementEnabled (\r | |
1436aea4 | 866 | IN CONST UINTN Type\r |
6b4d58a1 BD |
867 | )\r |
868 | {\r | |
869 | //\r | |
870 | // When Performance measurement is enabled and the type is not filtered, the performance can be logged.\r | |
871 | //\r | |
1436aea4 | 872 | if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {\r |
6b4d58a1 BD |
873 | return TRUE;\r |
874 | }\r | |
1436aea4 | 875 | \r |
6b4d58a1 BD |
876 | return FALSE;\r |
877 | }\r |