]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
[mirror_edk2.git] / MdeModulePkg / Library / PeiPerformanceLib / PeiPerformanceLib.c
1 /** @file
2 Performance library instance used in PEI phase.
3
4 This file implements all APIs in Performance Library class in MdePkg. It creates
5 performance logging GUIDed HOB on the first performance logging and then logs the
6 performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum
7 number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or
8 PcdMaxPeiPerformanceLogEntries16.
9
10 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
11 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
12 This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
16
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19
20 **/
21
22
23 #include <PiPei.h>
24
25 #include <Guid/ExtendedFirmwarePerformance.h>
26
27 #include <Library/PerformanceLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/HobLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/TimerLib.h>
32 #include <Library/PcdLib.h>
33 #include <Library/BaseMemoryLib.h>
34
35 #define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
36 #define MAX_RECORD_SIZE (sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE)
37
38 /**
39 Check whether the Token is a known one which is uesed by core.
40
41 @param Token Pointer to a Null-terminated ASCII string
42
43 @retval TRUE Is a known one used by core.
44 @retval FALSE Not a known one.
45
46 **/
47 BOOLEAN
48 IsKnownTokens (
49 IN CONST CHAR8 *Token
50 )
51 {
52 if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
53 AsciiStrCmp (Token, PEI_TOK) == 0 ||
54 AsciiStrCmp (Token, DXE_TOK) == 0 ||
55 AsciiStrCmp (Token, BDS_TOK) == 0 ||
56 AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
57 AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 ||
58 AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 ||
59 AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 ||
60 AsciiStrCmp (Token, START_IMAGE_TOK) == 0 ||
61 AsciiStrCmp (Token, PEIM_TOK) == 0) {
62 return TRUE;
63 } else {
64 return FALSE;
65 }
66 }
67
68 /**
69 Check whether the ID is a known one which map to the known Token.
70
71 @param Identifier 32-bit identifier.
72
73 @retval TRUE Is a known one used by core.
74 @retval FALSE Not a known one.
75
76 **/
77 BOOLEAN
78 IsKnownID (
79 IN UINT32 Identifier
80 )
81 {
82 if (Identifier == MODULE_START_ID ||
83 Identifier == MODULE_END_ID ||
84 Identifier == MODULE_LOADIMAGE_START_ID ||
85 Identifier == MODULE_LOADIMAGE_END_ID ||
86 Identifier == MODULE_DB_START_ID ||
87 Identifier == MODULE_DB_END_ID ||
88 Identifier == MODULE_DB_SUPPORT_START_ID ||
89 Identifier == MODULE_DB_SUPPORT_END_ID ||
90 Identifier == MODULE_DB_STOP_START_ID ||
91 Identifier == MODULE_DB_STOP_END_ID) {
92 return TRUE;
93 } else {
94 return FALSE;
95 }
96 }
97
98 /**
99 Get the FPDT record info.
100
101 @param IsStart TRUE if the performance log is start log.
102 @param Handle Pointer to environment specific context used
103 to identify the component being measured.
104 @param Token Pointer to a Null-terminated ASCII string
105 that identifies the component being measured.
106 @param Module Pointer to a Null-terminated ASCII string
107 that identifies the module being measured.
108 @param RecordInfo On return, pointer to the info of the record.
109
110 @retval EFI_SUCCESS Get record info successfully.
111 @retval EFI_UNSUPPORTED No matched FPDT record.
112
113 **/
114 EFI_STATUS
115 GetFpdtRecordInfo (
116 IN BOOLEAN IsStart,
117 IN CONST VOID *Handle,
118 IN CONST CHAR8 *Token,
119 IN CONST CHAR8 *Module,
120 OUT FPDT_BASIC_RECORD_INFO *RecordInfo
121 )
122 {
123 UINTN StringSize;
124 UINT16 RecordType;
125
126 RecordType = FPDT_DYNAMIC_STRING_EVENT_TYPE;
127
128 //
129 // Get the ProgressID based on the Token.
130 // When PcdEdkiiFpdtStringRecordEnableOnly is TRUE, all records are with type of FPDT_DYNAMIC_STRING_EVENT_TYPE.
131 //
132 if (Token != NULL) {
133 if (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) { // "LoadImage:"
134 if (IsStart) {
135 RecordInfo->ProgressID = MODULE_LOADIMAGE_START_ID;
136 } else {
137 RecordInfo->ProgressID = MODULE_LOADIMAGE_END_ID;
138 }
139 if(!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
140 RecordType = FPDT_GUID_QWORD_EVENT_TYPE;
141 }
142 } else if (AsciiStrCmp (Token, SEC_TOK) == 0 || // "SEC"
143 AsciiStrCmp (Token, PEI_TOK) == 0) { // "PEI"
144 if (IsStart) {
145 RecordInfo->ProgressID = PERF_CROSSMODULE_START_ID;
146 } else {
147 RecordInfo->ProgressID = PERF_CROSSMODULE_END_ID;
148 }
149 } else if (AsciiStrCmp (Token, PEIM_TOK) == 0) { // "PEIM"
150 if (IsStart) {
151 RecordInfo->ProgressID = MODULE_START_ID;
152 } else {
153 RecordInfo->ProgressID = MODULE_END_ID;
154 }
155 if(!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
156 RecordType = FPDT_GUID_EVENT_TYPE;
157 }
158 } else { //Pref used in Modules.
159 if (IsStart) {
160 RecordInfo->ProgressID = PERF_INMODULE_START_ID;
161 } else {
162 RecordInfo->ProgressID = PERF_INMODULE_END_ID;
163 }
164 }
165 } else if (Module != NULL || Handle != NULL) { //Pref used in Modules.
166 if (IsStart) {
167 RecordInfo->ProgressID = PERF_INMODULE_START_ID;
168 } else {
169 RecordInfo->ProgressID = PERF_INMODULE_END_ID;
170 }
171 } else {
172 return EFI_UNSUPPORTED;
173 }
174
175 //
176 // Get the Guid and string.
177 //
178 if(PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
179 RecordInfo->RecordSize = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE;
180 } else {
181 switch (RecordType) {
182 case FPDT_GUID_EVENT_TYPE:
183 RecordInfo->RecordSize = sizeof (FPDT_GUID_EVENT_RECORD);
184 break;
185
186 case FPDT_GUID_QWORD_EVENT_TYPE:
187 RecordInfo->RecordSize = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
188 break;
189
190 case FPDT_DYNAMIC_STRING_EVENT_TYPE:
191 if (Token != NULL) {
192 StringSize = AsciiStrSize (Token);
193 } else if (Module != NULL) {
194 StringSize = AsciiStrSize (Module);
195 } else {
196 StringSize = STRING_SIZE;
197 }
198 RecordInfo->RecordSize = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + StringSize);
199 break;
200
201 default:
202 //
203 // Other type is unsupported in PEI phase yet, return EFI_UNSUPPORTED
204 //
205 return EFI_UNSUPPORTED;
206 }
207 }
208 RecordInfo->Type = RecordType;
209 return EFI_SUCCESS;
210 }
211
212 /**
213 Convert PEI performance log to FPDT String boot record.
214
215 @param IsStart TRUE if the performance log is start log.
216 @param Handle Pointer to environment specific context used
217 to identify the component being measured.
218 @param Token Pointer to a Null-terminated ASCII string
219 that identifies the component being measured.
220 @param Module Pointer to a Null-terminated ASCII string
221 that identifies the module being measured.
222 @param Ticker 64-bit time stamp.
223 @param Identifier 32-bit identifier. If the value is 0, the created record
224 is same as the one created by StartGauge of PERFORMANCE_PROTOCOL.
225
226 @retval EFI_SUCCESS Add FPDT boot record.
227 @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
228 @retval EFI_UNSUPPORTED No matched FPDT record.
229
230 **/
231 EFI_STATUS
232 InsertPeiFpdtMeasurement (
233 IN BOOLEAN IsStart,
234 IN CONST VOID *Handle, OPTIONAL
235 IN CONST CHAR8 *Token, OPTIONAL
236 IN CONST CHAR8 *Module, OPTIONAL
237 IN UINT64 Ticker,
238 IN UINT32 Identifier
239 )
240 {
241 EFI_HOB_GUID_TYPE *GuidHob;
242 UINTN PeiPerformanceSize;
243 UINT8 *PeiFirmwarePerformance;
244 FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
245 FPDT_RECORD_PTR FpdtRecordPtr;
246 FPDT_BASIC_RECORD_INFO RecordInfo;
247 CONST VOID *ModuleGuid;
248 UINTN DestMax;
249 UINTN StrLength;
250 CONST CHAR8 *StringPtr;
251 EFI_STATUS Status;
252 UINT16 PeiPerformanceLogEntries;
253 UINT64 TimeStamp;
254
255 StringPtr = NULL;
256 FpdtRecordPtr.RecordHeader = NULL;
257 PeiPerformanceLogHeader = NULL;
258
259 //
260 // Get record info (type, size, ProgressID and Module Guid).
261 //
262 Status = GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInfo);
263 if (EFI_ERROR (Status)) {
264 return Status;
265 }
266
267 //
268 // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority.
269 // !!! Note: If the Pref is not the known Token used in the core but have same
270 // ID with the core Token, this case will not be supported.
271 // And in currtnt usage mode, for the unkown ID, there is a general rule:
272 // If it is start pref: the lower 4 bits of the ID should be 0.
273 // If it is end pref: the lower 4 bits of the ID should not be 0.
274 // If input ID doesn't follow the rule, we will adjust it.
275 //
276 if ((Identifier != 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (Token))) {
277 return EFI_UNSUPPORTED;
278 } else if ((Identifier != 0) && (!IsKnownID (Identifier)) && (!IsKnownTokens (Token))) {
279 if (IsStart && ((Identifier & 0x000F) != 0)) {
280 Identifier &= 0xFFF0;
281 } else if ((!IsStart) && ((Identifier & 0x000F) == 0)) {
282 Identifier += 1;
283 }
284 RecordInfo.ProgressID = (UINT16)Identifier;
285 }
286
287 //
288 // Get the number of PeiPerformanceLogEntries form PCD.
289 //
290 PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
291 PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :
292 PcdGet8 (PcdMaxPeiPerformanceLogEntries));
293
294 //
295 // Create GUID HOB Data.
296 //
297 GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
298 PeiFirmwarePerformance = NULL;
299 while (GuidHob != NULL) {
300 //
301 // PEI Performance HOB was found, then return the existing one.
302 //
303 PeiFirmwarePerformance = (UINT8*)GET_GUID_HOB_DATA (GuidHob);
304 PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
305 if (!PeiPerformanceLogHeader->HobIsFull && PeiPerformanceLogHeader->SizeOfAllEntries + RecordInfo.RecordSize > PeiPerformanceLogEntries * MAX_RECORD_SIZE) {
306 PeiPerformanceLogHeader->HobIsFull = TRUE;
307 }
308 if (!PeiPerformanceLogHeader->HobIsFull && PeiPerformanceLogHeader->SizeOfAllEntries + RecordInfo.RecordSize <= PeiPerformanceLogEntries * MAX_RECORD_SIZE) {
309 FpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + PeiPerformanceLogHeader->SizeOfAllEntries);
310 break;
311 }
312 //
313 // Previous HOB is used, then find next one.
314 //
315 GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
316 }
317
318 if (GuidHob == NULL) {
319 //
320 // PEI Performance HOB was not found, then build one.
321 //
322 PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
323 MAX_RECORD_SIZE * PeiPerformanceLogEntries;
324 PeiFirmwarePerformance = (UINT8*)BuildGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, PeiPerformanceSize);
325 if (PeiFirmwarePerformance != NULL) {
326 ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize);
327 }
328 PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
329 FpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER));
330 }
331
332 if (PeiFirmwarePerformance == NULL) {
333 //
334 // there is no enough resource to store performance data
335 //
336 return EFI_OUT_OF_RESOURCES;
337 }
338
339 //
340 // Get the TimeStamp.
341 //
342 if (Ticker == 0) {
343 Ticker = GetPerformanceCounter ();
344 TimeStamp = GetTimeInNanoSecond (Ticker);
345 } else if (Ticker == 1) {
346 TimeStamp = 0;
347 } else {
348 TimeStamp = GetTimeInNanoSecond (Ticker);
349 }
350
351 //
352 // Get the ModuleGuid.
353 //
354 if (Handle != NULL) {
355 ModuleGuid = Handle;
356 } else {
357 ModuleGuid = &gEfiCallerIdGuid;
358 }
359
360 switch (RecordInfo.Type) {
361 case FPDT_GUID_EVENT_TYPE:
362 FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
363 FpdtRecordPtr.GuidEvent->Header.Length = RecordInfo.RecordSize;;
364 FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
365 FpdtRecordPtr.GuidEvent->ProgressID = RecordInfo.ProgressID;
366 FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
367 CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
368 PeiPerformanceLogHeader->SizeOfAllEntries += RecordInfo.RecordSize;
369 break;
370
371 case FPDT_GUID_QWORD_EVENT_TYPE:
372 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
373 FpdtRecordPtr.GuidQwordEvent->Header.Length = RecordInfo.RecordSize;;
374 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
375 FpdtRecordPtr.GuidQwordEvent->ProgressID = RecordInfo.ProgressID;
376 FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
377 PeiPerformanceLogHeader->LoadImageCount++;
378 FpdtRecordPtr.GuidQwordEvent->Qword = PeiPerformanceLogHeader->LoadImageCount;
379 CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
380 PeiPerformanceLogHeader->SizeOfAllEntries += RecordInfo.RecordSize;
381 break;
382
383 case FPDT_DYNAMIC_STRING_EVENT_TYPE:
384 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
385 FpdtRecordPtr.DynamicStringEvent->Header.Length = RecordInfo.RecordSize;
386 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
387 FpdtRecordPtr.DynamicStringEvent->ProgressID = RecordInfo.ProgressID;
388 FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
389 CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
390 PeiPerformanceLogHeader->SizeOfAllEntries += RecordInfo.RecordSize;
391
392 if (Token != NULL) {
393 StringPtr = Token;
394 } else if (Module != NULL) {
395 StringPtr = Module;
396 }
397 if (StringPtr != NULL && AsciiStrLen (StringPtr) != 0) {
398 DestMax = (RecordInfo.RecordSize - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)) / sizeof (CHAR8);
399 StrLength = AsciiStrLen (StringPtr);
400 if (StrLength >= DestMax) {
401 StrLength = DestMax -1;
402 }
403 AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StrLength);
404 } else {
405 AsciiStrCpyS (FpdtRecordPtr.DynamicStringEvent->String, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, "unknown name");
406 }
407 break;
408
409 default:
410 //
411 // Record is not supported in current PEI phase, return EFI_ABORTED
412 //
413 return EFI_UNSUPPORTED;
414 }
415
416 return EFI_SUCCESS;
417 }
418
419 /**
420 Creates a record for the beginning of a performance measurement.
421
422 If TimeStamp is zero, then this function reads the current time stamp
423 and adds that time stamp value to the record as the start time.
424
425 If TimeStamp is one, then this function reads 0 as the start time.
426
427 If TimeStamp is other value, then TimeStamp is added to the record as the start time.
428
429 @param Handle Pointer to environment specific context used
430 to identify the component being measured.
431 @param Token Pointer to a Null-terminated ASCII string
432 that identifies the component being measured.
433 @param Module Pointer to a Null-terminated ASCII string
434 that identifies the module being measured.
435 @param TimeStamp 64-bit time stamp.
436 @param Identifier 32-bit identifier. If the value is 0, the created record
437 is same as the one created by StartPerformanceMeasurement.
438
439 @retval RETURN_SUCCESS The start of the measurement was recorded.
440 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
441
442 **/
443 RETURN_STATUS
444 EFIAPI
445 StartPerformanceMeasurementEx (
446 IN CONST VOID *Handle, OPTIONAL
447 IN CONST CHAR8 *Token, OPTIONAL
448 IN CONST CHAR8 *Module, OPTIONAL
449 IN UINT64 TimeStamp,
450 IN UINT32 Identifier
451 )
452 {
453 return InsertPeiFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Identifier);
454 }
455
456 /**
457
458 Creates a record for the end of a performance measurement.
459
460 If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.
461 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.
462 If the TimeStamp is one, then this function reads 0 as the end time.
463
464 @param Handle Pointer to environment specific context used
465 to identify the component being measured.
466 @param Token Pointer to a Null-terminated ASCII string
467 that identifies the component being measured.
468 @param Module Pointer to a Null-terminated ASCII string
469 that identifies the module being measured.
470 @param TimeStamp 64-bit time stamp.
471 @param Identifier 32-bit identifier. If the value is 0, the found record
472 is same as the one found by EndPerformanceMeasurement.
473
474 @retval RETURN_SUCCESS The end of the measurement was recorded.
475 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
476
477 **/
478 RETURN_STATUS
479 EFIAPI
480 EndPerformanceMeasurementEx (
481 IN CONST VOID *Handle, OPTIONAL
482 IN CONST CHAR8 *Token, OPTIONAL
483 IN CONST CHAR8 *Module, OPTIONAL
484 IN UINT64 TimeStamp,
485 IN UINT32 Identifier
486 )
487 {
488 return InsertPeiFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, Identifier);
489 }
490
491 /**
492 Attempts to retrieve a performance measurement log entry from the performance measurement log.
493 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
494 and then assign the Identifier with 0.
495
496 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
497 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
498 and the key for the second entry in the log is returned. If the performance log is empty,
499 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
500 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
501 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
502 retrieved and an implementation specific non-zero key value that specifies the end of the performance
503 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
504 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
505 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
506 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
507 If Handle is NULL, then ASSERT().
508 If Token is NULL, then ASSERT().
509 If Module is NULL, then ASSERT().
510 If StartTimeStamp is NULL, then ASSERT().
511 If EndTimeStamp is NULL, then ASSERT().
512 If Identifier is NULL, then ASSERT().
513
514 !!!NOT Support yet!!!
515
516 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
517 0, then the first performance measurement log entry is retrieved.
518 On exit, the key of the next performance of entry entry.
519 @param Handle Pointer to environment specific context used to identify the component
520 being measured.
521 @param Token Pointer to a Null-terminated ASCII string that identifies the component
522 being measured.
523 @param Module Pointer to a Null-terminated ASCII string that identifies the module
524 being measured.
525 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
526 was started.
527 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
528 was ended.
529 @param Identifier Pointer to the 32-bit identifier that was recorded.
530
531 @return The key for the next performance log entry (in general case).
532
533 **/
534 UINTN
535 EFIAPI
536 GetPerformanceMeasurementEx (
537 IN UINTN LogEntryKey,
538 OUT CONST VOID **Handle,
539 OUT CONST CHAR8 **Token,
540 OUT CONST CHAR8 **Module,
541 OUT UINT64 *StartTimeStamp,
542 OUT UINT64 *EndTimeStamp,
543 OUT UINT32 *Identifier
544 )
545 {
546 return 0;
547 }
548
549 /**
550 Creates a record for the beginning of a performance measurement.
551
552 If TimeStamp is zero, then this function reads the current time stamp
553 and adds that time stamp value to the record as the start time.
554
555 If TimeStamp is one, then this function reads 0 as the start time.
556
557 If TimeStamp is other value, then TimeStamp is added to the record as the start time.
558
559
560 @param Handle Pointer to environment specific context used
561 to identify the component being measured.
562 @param Token Pointer to a Null-terminated ASCII string
563 that identifies the component being measured.
564 @param Module Pointer to a Null-terminated ASCII string
565 that identifies the module being measured.
566 @param TimeStamp 64-bit time stamp.
567
568 @retval RETURN_SUCCESS The start of the measurement was recorded.
569 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
570
571 **/
572 RETURN_STATUS
573 EFIAPI
574 StartPerformanceMeasurement (
575 IN CONST VOID *Handle, OPTIONAL
576 IN CONST CHAR8 *Token, OPTIONAL
577 IN CONST CHAR8 *Module, OPTIONAL
578 IN UINT64 TimeStamp
579 )
580 {
581 return InsertPeiFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, 0);
582 }
583
584 /**
585
586 Creates a record for the end of a performance measurement.
587
588 If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.
589 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.
590 If the TimeStamp is one, then this function reads 0 as the end time.
591
592 @param Handle Pointer to environment specific context used
593 to identify the component being measured.
594 @param Token Pointer to a Null-terminated ASCII string
595 that identifies the component being measured.
596 @param Module Pointer to a Null-terminated ASCII string
597 that identifies the module being measured.
598 @param TimeStamp 64-bit time stamp.
599
600 @retval RETURN_SUCCESS The end of the measurement was recorded.
601 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
602
603 **/
604 RETURN_STATUS
605 EFIAPI
606 EndPerformanceMeasurement (
607 IN CONST VOID *Handle, OPTIONAL
608 IN CONST CHAR8 *Token, OPTIONAL
609 IN CONST CHAR8 *Module, OPTIONAL
610 IN UINT64 TimeStamp
611 )
612 {
613 return InsertPeiFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, 0);
614 }
615
616 /**
617 Attempts to retrieve a performance measurement log entry from the performance measurement log.
618 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
619 and then eliminate the Identifier.
620
621 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
622 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
623 and the key for the second entry in the log is returned. If the performance log is empty,
624 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
625 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
626 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
627 retrieved and an implementation specific non-zero key value that specifies the end of the performance
628 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
629 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
630 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
631 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
632 If Handle is NULL, then ASSERT().
633 If Token is NULL, then ASSERT().
634 If Module is NULL, then ASSERT().
635 If StartTimeStamp is NULL, then ASSERT().
636 If EndTimeStamp is NULL, then ASSERT().
637
638 NOT Support yet.
639
640 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
641 0, then the first performance measurement log entry is retrieved.
642 On exit, the key of the next performance of entry entry.
643 @param Handle Pointer to environment specific context used to identify the component
644 being measured.
645 @param Token Pointer to a Null-terminated ASCII string that identifies the component
646 being measured.
647 @param Module Pointer to a Null-terminated ASCII string that identifies the module
648 being measured.
649 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
650 was started.
651 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
652 was ended.
653
654 @return The key for the next performance log entry (in general case).
655
656 **/
657 UINTN
658 EFIAPI
659 GetPerformanceMeasurement (
660 IN UINTN LogEntryKey,
661 OUT CONST VOID **Handle,
662 OUT CONST CHAR8 **Token,
663 OUT CONST CHAR8 **Module,
664 OUT UINT64 *StartTimeStamp,
665 OUT UINT64 *EndTimeStamp
666 )
667 {
668 return 0;
669 }
670
671 /**
672 Returns TRUE if the performance measurement macros are enabled.
673
674 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
675 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
676
677 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
678 PcdPerformanceLibraryPropertyMask is set.
679 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
680 PcdPerformanceLibraryPropertyMask is clear.
681
682 **/
683 BOOLEAN
684 EFIAPI
685 PerformanceMeasurementEnabled (
686 VOID
687 )
688 {
689 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
690 }