29#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
30#define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)
49 UINT16 PeiPerformanceLogEntries;
50 UINTN PeiPerformanceSize;
51 UINT8 *PeiFirmwarePerformance;
57 PeiPerformanceLogEntries = (UINT16)(
PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
58 PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :
59 PcdGet8 (PcdMaxPeiPerformanceLogEntries));
65 PeiFirmwarePerformance =
NULL;
66 while (GuidHob !=
NULL) {
70 PeiFirmwarePerformance = (UINT8 *)GET_GUID_HOB_DATA (GuidHob);
72 if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {
73 (*PeiPerformanceLogHeader)->HobIsFull =
TRUE;
76 if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {
84 GuidHob =
GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
87 if (GuidHob ==
NULL) {
92 PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
93 PeiFirmwarePerformance = (UINT8 *)
BuildGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, PeiPerformanceSize);
94 if (PeiFirmwarePerformance !=
NULL) {
95 ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize);
101 if (PeiFirmwarePerformance ==
NULL) {
105 return EFI_OUT_OF_RESOURCES;
160 if ((Identifier == MODULE_START_ID) ||
161 (Identifier == MODULE_END_ID) ||
162 (Identifier == MODULE_LOADIMAGE_START_ID) ||
163 (Identifier == MODULE_LOADIMAGE_END_ID) ||
164 (Identifier == MODULE_DB_START_ID) ||
165 (Identifier == MODULE_DB_END_ID) ||
166 (Identifier == MODULE_DB_SUPPORT_START_ID) ||
167 (Identifier == MODULE_DB_SUPPORT_END_ID) ||
168 (Identifier == MODULE_DB_STOP_START_ID) ||
169 (Identifier == MODULE_DB_STOP_END_ID))
193 IN BOOLEAN Attribute,
196 OUT UINT16 *ProgressID
203 if (String !=
NULL) {
206 if (Attribute == PerfStartEntry) {
207 *ProgressID = MODULE_LOADIMAGE_START_ID;
209 *ProgressID = MODULE_LOADIMAGE_END_ID;
214 if (Attribute == PerfStartEntry) {
215 *ProgressID = PERF_CROSSMODULE_START_ID;
217 *ProgressID = PERF_CROSSMODULE_END_ID;
221 if (Attribute == PerfStartEntry) {
222 *ProgressID = MODULE_START_ID;
224 *ProgressID = MODULE_END_ID;
228 if (Attribute == PerfStartEntry) {
229 *ProgressID = PERF_INMODULE_START_ID;
231 *ProgressID = PERF_INMODULE_END_ID;
234 }
else if (Handle !=
NULL) {
236 if (Attribute == PerfStartEntry) {
237 *ProgressID = PERF_INMODULE_START_ID;
239 *ProgressID = PERF_INMODULE_END_ID;
242 return EFI_INVALID_PARAMETER;
259 IN OUT CHAR8 *Destination,
267 ASSERT (Source !=
NULL);
269 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
270 DestMax = STRING_SIZE;
273 if (DestMax > STRING_SIZE) {
274 DestMax = STRING_SIZE;
279 if (StringLen >= DestMax) {
280 StringLen = DestMax -1;
284 *Length += (UINT8)DestMax;
310 IN CONST VOID *CallerIdentifier OPTIONAL,
312 IN CONST CHAR8 *String OPTIONAL,
314 IN UINT64 Address OPTIONAL,
316 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
320 CONST VOID *ModuleGuid;
321 CONST CHAR8 *StringPtr;
327 FpdtRecordPtr.RecordHeader =
NULL;
328 PeiPerformanceLogHeader =
NULL;
334 if (Attribute != PerfEntry) {
345 return EFI_UNSUPPORTED;
347 if ((Attribute == PerfStartEntry) && ((PerfId & 0x000F) != 0)) {
349 }
else if ((Attribute == PerfEndEntry) && ((PerfId & 0x000F) == 0)) {
352 }
else if (PerfId == 0) {
353 Status =
GetFpdtRecordId (Attribute, CallerIdentifier, String, &PerfId);
354 if (EFI_ERROR (Status)) {
363 Status =
GetFpdtRecordPtr (PEI_MAX_RECORD_SIZE, &FpdtRecordPtr, &PeiPerformanceLogHeader);
364 if (EFI_ERROR (Status)) {
374 }
else if (Ticker == 1) {
383 if (CallerIdentifier !=
NULL) {
384 ModuleGuid = CallerIdentifier;
386 ModuleGuid = &gEfiCallerIdGuid;
393 case MODULE_START_ID:
396 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
397 FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
399 FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
401 FpdtRecordPtr.GuidEvent->
Timestamp = TimeStamp;
407 case MODULE_LOADIMAGE_START_ID:
408 case MODULE_LOADIMAGE_END_ID:
410 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
411 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
413 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
414 FpdtRecordPtr.GuidQwordEvent->
ProgressID = PerfId;
415 FpdtRecordPtr.GuidQwordEvent->
Timestamp = TimeStamp;
416 if (PerfId == MODULE_LOADIMAGE_START_ID) {
417 PeiPerformanceLogHeader->LoadImageCount++;
420 FpdtRecordPtr.GuidQwordEvent->
Qword = PeiPerformanceLogHeader->LoadImageCount;
426 case PERF_EVENTSIGNAL_START_ID:
427 case PERF_EVENTSIGNAL_END_ID:
428 case PERF_CALLBACK_START_ID:
429 case PERF_CALLBACK_END_ID:
430 if ((String ==
NULL) || (Guid ==
NULL)) {
431 return EFI_INVALID_PARAMETER;
436 StringPtr =
"unknown name";
439 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
440 FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
442 FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
443 FpdtRecordPtr.DualGuidStringEvent->
ProgressID = PerfId;
444 FpdtRecordPtr.DualGuidStringEvent->
Timestamp = TimeStamp;
445 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->
Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->
Guid1));
446 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->
Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->
Guid2));
453 case PERF_FUNCTION_START_ID:
454 case PERF_FUNCTION_END_ID:
455 case PERF_INMODULE_START_ID:
456 case PERF_INMODULE_END_ID:
457 case PERF_CROSSMODULE_START_ID:
458 case PERF_CROSSMODULE_END_ID:
462 StringPtr =
"unknown name";
465 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
466 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
468 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
469 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
470 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
478 if (Attribute != PerfEntry) {
482 StringPtr =
"unknown name";
485 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
486 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
488 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
489 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
490 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
491 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->
Guid));
495 return EFI_INVALID_PARAMETER;
504 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
505 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
507 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
508 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
509 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
525 PeiPerformanceLogHeader->SizeOfAllEntries += FpdtRecordPtr.RecordHeader->Length;
557 IN CONST VOID *Handle OPTIONAL,
558 IN CONST CHAR8 *Token OPTIONAL,
559 IN CONST CHAR8 *Module OPTIONAL,
568 }
else if (Module !=
NULL) {
574 return (RETURN_STATUS)
InsertFpdtRecord (Handle,
NULL, String, TimeStamp, 0, (UINT16)Identifier, PerfStartEntry);
602 IN CONST VOID *Handle OPTIONAL,
603 IN CONST CHAR8 *Token OPTIONAL,
604 IN CONST CHAR8 *Module OPTIONAL,
613 }
else if (Module !=
NULL) {
619 return (RETURN_STATUS)
InsertFpdtRecord (Handle,
NULL, String, TimeStamp, 0, (UINT16)Identifier, PerfEndEntry);
672 OUT UINT64 *StartTimeStamp,
673 OUT UINT64 *EndTimeStamp,
674 OUT UINT32 *Identifier
706 IN CONST VOID *Handle OPTIONAL,
707 IN CONST CHAR8 *Token OPTIONAL,
708 IN CONST CHAR8 *Module OPTIONAL,
738 IN CONST VOID *Handle OPTIONAL,
739 IN CONST CHAR8 *Token OPTIONAL,
740 IN CONST CHAR8 *Module OPTIONAL,
795 OUT UINT64 *StartTimeStamp,
796 OUT UINT64 *EndTimeStamp
841 IN CONST VOID *CallerIdentifier,
843 IN CONST CHAR8 *String OPTIONAL,
844 IN UINT64 Address OPTIONAL,
848 return (RETURN_STATUS)
InsertFpdtRecord (CallerIdentifier, Guid, String, 0, Address, (UINT16)Identifier, PerfEntry);
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
RETURN_STATUS EFIAPI AsciiStrnCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source, IN UINTN Length)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define PcdGet16(TokenName)
#define PcdGet8(TokenName)
#define PcdGetBool(TokenName)