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