24#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
25#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
26#define FIRMWARE_RECORD_BUFFER 0x10000
27#define CACHE_HANDLE_GUID_COUNT 0x800
37 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT,
39 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
55 CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
60UINTN mCachePairCount = 0;
62UINT32 mLoadImageCount = 0;
63UINT32 mPerformanceLength = 0;
64UINT32 mMaxPerformanceLength = 0;
65UINT32 mBootRecordSize = 0;
66UINTN mBootRecordMaxSize = 0;
67UINT32 mCachedLength = 0;
69BOOLEAN mFpdtBufferIsReported =
FALSE;
70BOOLEAN mLackSpaceIsReported =
FALSE;
71CHAR8 *mPlatformLanguage =
NULL;
72UINT8 *mPerformancePointer =
NULL;
73UINT8 *mBootRecordBuffer =
NULL;
74BOOLEAN mLockInsertRecord =
FALSE;
75CHAR8 *mDevicePathString =
NULL;
76UINTN mSmmBootRecordOffset = 0;
104 if (mFpdtBufferIsReported) {
108 if (mBootRecordSize + RecordSize > mBootRecordMaxSize) {
109 if (!mLackSpaceIsReported) {
110 DEBUG ((DEBUG_INFO,
"DxeCorePerformanceLib: No enough space to save boot records\n"));
111 mLackSpaceIsReported =
TRUE;
114 return EFI_OUT_OF_RESOURCES;
125 if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {
128 mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER,
131 if (mPerformancePointer ==
NULL) {
132 return EFI_OUT_OF_RESOURCES;
135 mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
196 if ((Identifier == MODULE_START_ID) ||
197 (Identifier == MODULE_END_ID) ||
198 (Identifier == MODULE_LOADIMAGE_START_ID) ||
199 (Identifier == MODULE_LOADIMAGE_END_ID) ||
200 (Identifier == MODULE_DB_START_ID) ||
201 (Identifier == MODULE_DB_END_ID) ||
202 (Identifier == MODULE_DB_SUPPORT_START_ID) ||
203 (Identifier == MODULE_DB_SUPPORT_END_ID) ||
204 (Identifier == MODULE_DB_STOP_START_ID) ||
205 (Identifier == MODULE_DB_STOP_END_ID))
223 OUT VOID **SmmPerfData,
225 IN BOOLEAN SkipGetPerfData
229 UINT8 *SmmBootRecordCommBuffer;
237 VOID *SmmBootRecordData;
238 UINTN SmmBootRecordDataSize;
239 UINTN ReservedMemSize;
240 UINTN SmmBootRecordDataRetrieved;
245 SmmBootRecordCommBuffer =
NULL;
247 SmmBootRecordData =
NULL;
249 Status =
gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid,
NULL, (VOID **)&Communication);
250 if (!EFI_ERROR (Status)) {
256 &gEdkiiPiSmmCommunicationRegionTableGuid,
257 (VOID **)&SmmCommRegionTable
259 if (!EFI_ERROR (Status)) {
260 ASSERT (SmmCommRegionTable !=
NULL);
262 for (Index = 0; Index < SmmCommRegionTable->NumberOfEntries; Index++) {
267 SmmCommMemRegion = (
EFI_MEMORY_DESCRIPTOR *)((UINT8 *)SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
270 ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
278 if (ReservedMemSize > SMM_BOOT_RECORD_COMM_SIZE) {
286 CommSize = SMM_BOOT_RECORD_COMM_SIZE;
291 SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE;
292 SmmCommData->BootRecordData =
NULL;
293 Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
295 if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && (SmmCommData->BootRecordSize != 0)) {
296 if (SkipGetPerfData) {
297 *SmmPerfDataSize = SmmCommData->BootRecordSize;
304 SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
305 SmmCommData->BootRecordOffset = mSmmBootRecordOffset;
306 SmmBootRecordDataSize = SmmCommData->BootRecordSize - mSmmBootRecordOffset;
308 SmmBootRecordDataRetrieved = 0;
309 ASSERT (SmmBootRecordData !=
NULL);
310 SmmCommData->BootRecordData = (VOID *)((
UINTN)SmmCommMemRegion->
PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
311 SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
312 while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {
313 Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
316 if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
317 CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);
319 CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
322 SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;
323 SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;
326 mSmmBootRecordOffset = SmmCommData->BootRecordOffset;
328 *SmmPerfData = SmmBootRecordData;
329 *SmmPerfDataSize = SmmBootRecordDataSize;
349 UINTN BootPerformanceDataSize;
350 UINT8 *BootPerformanceData;
352 UINTN SmmBootRecordDataSize;
354 SmmBootRecordDataSize = 0;
371 ZeroMem (&PerformanceVariable,
sizeof (PerformanceVariable));
372 Size =
sizeof (PerformanceVariable);
373 Status =
gRT->GetVariable (
374 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
375 &gEfiFirmwarePerformanceGuid,
380 if (!EFI_ERROR (Status)) {
381 Status =
gBS->AllocatePages (
387 if (!EFI_ERROR (Status)) {
392 if (mAcpiBootPerformanceTable ==
NULL) {
400 if (mAcpiBootPerformanceTable !=
NULL) {
401 ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);
405 DEBUG ((DEBUG_INFO,
"DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
407 if (mAcpiBootPerformanceTable ==
NULL) {
408 return EFI_OUT_OF_RESOURCES;
414 BootPerformanceData = (UINT8 *)mAcpiBootPerformanceTable;
418 CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate,
sizeof (mBootPerformanceTableTemplate));
419 BootPerformanceData = BootPerformanceData + mAcpiBootPerformanceTable->
Header.Length;
423 if (mPerformancePointer !=
NULL) {
424 CopyMem (BootPerformanceData, mPerformancePointer, mPerformanceLength);
425 mAcpiBootPerformanceTable->
Header.Length += mPerformanceLength;
426 BootPerformanceData = BootPerformanceData + mPerformanceLength;
428 mPerformancePointer =
NULL;
429 mPerformanceLength = 0;
430 mMaxPerformanceLength = 0;
433 mBootRecordBuffer = (UINT8 *)mAcpiBootPerformanceTable;
434 mBootRecordSize = mAcpiBootPerformanceTable->
Header.Length;
435 mBootRecordMaxSize = BootPerformanceDataSize;
457 OUT CHAR8 *NameString,
470 BOOLEAN ModuleGuidIsGet;
476 if ((NameString ==
NULL) || (BufferSize == 0)) {
477 return EFI_INVALID_PARAMETER;
483 if (mCachePairCount > 0) {
484 for (Count = mCachePairCount -1; Count >= 0; Count--) {
485 if (Handle == mCacheHandleGuidTable[Count].Handle) {
486 CopyGuid (ModuleGuid, &mCacheHandleGuidTable[Count].ModuleGuid);
487 AsciiStrCpyS (NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, mCacheHandleGuidTable[Count].NameString);
493 Status = EFI_INVALID_PARAMETER;
495 ModuleGuidIsGet =
FALSE;
500 TempGuid = &gZeroGuid;
506 if (Handle !=
NULL) {
510 Status =
gBS->HandleProtocol (
512 &gEfiLoadedImageProtocolGuid,
513 (VOID **)&LoadedImage
516 if (EFI_ERROR (Status)) {
520 Status =
gBS->OpenProtocol (
522 &gEfiDriverBindingProtocolGuid,
523 (VOID **)&DriverBinding,
526 EFI_OPEN_PROTOCOL_GET_PROTOCOL
528 if (!EFI_ERROR (Status)) {
532 Status =
gBS->HandleProtocol (
533 DriverBinding->ImageHandle,
534 &gEfiLoadedImageProtocolGuid,
535 (VOID **)&LoadedImage
541 if (!EFI_ERROR (Status) && (LoadedImage !=
NULL)) {
553 ModuleGuidIsGet =
TRUE;
555 TempGuid = &FvFilePath->FvFileName;
561 PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->
ImageBase);
562 if ((PdbFileName !=
NULL) && (BufferSize > 0)) {
564 for (Index = 0; PdbFileName[Index] != 0; Index++) {
565 if ((PdbFileName[Index] ==
'\\') || (PdbFileName[Index] ==
'/')) {
566 StartIndex = Index + 1;
574 for (Index = 0; Index < BufferSize - 1; Index++) {
575 NameString[Index] = PdbFileName[Index + StartIndex];
576 if ((NameString[Index] == 0) || (NameString[Index] ==
'.')) {
577 NameString[Index] = 0;
582 if (Index == BufferSize - 1) {
583 NameString[Index] = 0;
596 Status =
gBS->HandleProtocol (
598 &gEfiComponentName2ProtocolGuid,
599 (VOID **)&ComponentName2
601 if (!EFI_ERROR (Status)) {
605 if (mPlatformLanguage ==
NULL) {
609 if (mPlatformLanguage !=
NULL) {
610 Status = ComponentName2->GetDriverName (
612 mPlatformLanguage !=
NULL ? mPlatformLanguage :
"en-US",
615 if (!EFI_ERROR (Status)) {
616 for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
617 NameString[Index] = (CHAR8)StringPtr[Index];
620 NameString[Index] = 0;
629 if (ModuleGuidIsGet) {
637 EFI_SECTION_USER_INTERFACE,
643 if (!EFI_ERROR (Status)) {
647 for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
648 NameString[Index] = (CHAR8)StringPtr[Index];
651 NameString[Index] = 0;
660 if (ModuleGuid !=
NULL) {
662 if (
IsZeroGuid (TempGuid) && (Handle !=
NULL) && !ModuleGuidIsGet) {
671 if (mCachePairCount < CACHE_HANDLE_GUID_COUNT) {
672 mCacheHandleGuidTable[mCachePairCount].Handle = Handle;
673 CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, ModuleGuid);
674 AsciiStrCpyS (mCacheHandleGuidTable[mCachePairCount].NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, NameString);
697 IN PERF_MEASUREMENT_ATTRIBUTE Attribute,
700 OUT UINT16 *ProgressID
706 if (String !=
NULL) {
709 if (Attribute == PerfStartEntry) {
710 *ProgressID = MODULE_START_ID;
712 *ProgressID = MODULE_END_ID;
716 if (Attribute == PerfStartEntry) {
717 *ProgressID = MODULE_LOADIMAGE_START_ID;
719 *ProgressID = MODULE_LOADIMAGE_END_ID;
723 if (Attribute == PerfStartEntry) {
724 *ProgressID = MODULE_DB_START_ID;
726 *ProgressID = MODULE_DB_END_ID;
730 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
734 if (Attribute == PerfStartEntry) {
735 *ProgressID = MODULE_DB_SUPPORT_START_ID;
737 *ProgressID = MODULE_DB_SUPPORT_END_ID;
741 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
745 if (Attribute == PerfStartEntry) {
746 *ProgressID = MODULE_DB_STOP_START_ID;
748 *ProgressID = MODULE_DB_STOP_END_ID;
754 if (Attribute == PerfStartEntry) {
755 *ProgressID = PERF_CROSSMODULE_START_ID;
757 *ProgressID = PERF_CROSSMODULE_END_ID;
761 if (Attribute == PerfStartEntry) {
762 *ProgressID = PERF_INMODULE_START_ID;
764 *ProgressID = PERF_INMODULE_END_ID;
767 }
else if (Handle !=
NULL) {
769 if (Attribute == PerfStartEntry) {
770 *ProgressID = PERF_INMODULE_START_ID;
772 *ProgressID = PERF_INMODULE_END_ID;
775 return EFI_INVALID_PARAMETER;
792 IN OUT CHAR8 *Destination,
800 ASSERT (Source !=
NULL);
802 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
803 DestMax = STRING_SIZE;
806 if (DestMax > STRING_SIZE) {
807 DestMax = STRING_SIZE;
812 if (StringLen >= DestMax) {
813 StringLen = DestMax -1;
817 *Length += (UINT8)DestMax;
840 OUT CHAR8 *ComponentNameString,
848 CHAR8 *AsciiStringPtr;
849 UINTN ControllerNameStringSize;
850 UINTN DevicePathStringSize;
852 ControllerNameStringSize = 0;
854 Status =
gBS->HandleProtocol (
856 &gEfiComponentName2ProtocolGuid,
857 (VOID **)&ComponentName2
860 if (!EFI_ERROR (Status)) {
864 if (mPlatformLanguage ==
NULL) {
868 Status = ComponentName2->GetControllerName (
872 mPlatformLanguage !=
NULL ? mPlatformLanguage :
"en-US",
877 if (!EFI_ERROR (Status)) {
882 ControllerNameStringSize =
StrSize (StringPtr) / 2;
887 if ((ControllerNameStringSize + (*Length) + 1) > FPDT_MAX_PERF_RECORD_SIZE) {
891 ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
894 UnicodeStrnToAsciiStrS (StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
899 AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
900 *AsciiStringPtr = 0x20;
903 ControllerNameStringSize++;
905 *Length += (UINT8)ControllerNameStringSize;
914 if (DevicePathProtocol !=
NULL) {
916 if (StringPtr !=
NULL) {
921 DevicePathStringSize =
StrSize (StringPtr) / 2;
923 if ((DevicePathStringSize + (*Length)) > FPDT_MAX_PERF_RECORD_SIZE) {
927 DevicePathStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length);
930 if (ControllerNameStringSize != 0) {
931 AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
933 AsciiStringPtr = ComponentNameString;
936 UnicodeStrnToAsciiStrS (StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
937 *Length += (UINT8)DevicePathStringSize;
942 return EFI_UNSUPPORTED;
971 IN CONST VOID *CallerIdentifier OPTIONAL,
973 IN CONST CHAR8 *String OPTIONAL,
975 IN UINT64 Address OPTIONAL,
977 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
981 CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
985 CONST CHAR8 *StringPtr;
993 ZeroMem (ModuleName,
sizeof (ModuleName));
999 if (Attribute != PerfEntry) {
1010 return EFI_INVALID_PARAMETER;
1012 if ((Attribute == PerfStartEntry) && ((PerfId & 0x000F) != 0)) {
1014 }
else if ((Attribute == PerfEndEntry) && ((PerfId & 0x000F) == 0)) {
1017 }
else if (PerfId == 0) {
1021 Status =
GetFpdtRecordId (Attribute, CallerIdentifier, String, &ProgressId);
1022 if (EFI_ERROR (Status)) {
1026 PerfId = ProgressId;
1034 if (EFI_ERROR (Status)) {
1044 }
else if (Ticker == 1) {
1054 case MODULE_START_ID:
1057 StringPtr = ModuleName;
1061 if ((Attribute == PerfEntry) && (PerfId == MODULE_START_ID)) {
1062 if (mFpdtBufferIsReported) {
1063 mCachedLength = mBootRecordSize;
1065 mCachedLength = mPerformanceLength;
1069 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1070 FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
1072 FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1073 FpdtRecordPtr.GuidEvent->
ProgressID = PerfId;
1074 FpdtRecordPtr.GuidEvent->
Timestamp = TimeStamp;
1075 CopyMem (&FpdtRecordPtr.GuidEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->
Guid));
1076 if ((CallerIdentifier ==
NULL) && (PerfId == MODULE_END_ID) && (mCachedLength != 0)) {
1077 if (mFpdtBufferIsReported) {
1083 CopyMem (&FpdtRecordPtr.GuidEvent->
Guid, &CachedFpdtRecordPtr.GuidEvent->
Guid, sizeof (FpdtRecordPtr.GuidEvent->
Guid));
1090 case MODULE_LOADIMAGE_START_ID:
1091 case MODULE_LOADIMAGE_END_ID:
1093 StringPtr = ModuleName;
1094 if (PerfId == MODULE_LOADIMAGE_START_ID) {
1099 if ((CallerIdentifier ==
NULL) && (Attribute == PerfEntry)) {
1100 if (mFpdtBufferIsReported) {
1101 mCachedLength = mBootRecordSize;
1103 mCachedLength = mPerformanceLength;
1108 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1109 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
1111 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1112 FpdtRecordPtr.GuidQwordEvent->
ProgressID = PerfId;
1113 FpdtRecordPtr.GuidQwordEvent->
Timestamp = TimeStamp;
1114 FpdtRecordPtr.GuidQwordEvent->
Qword = mLoadImageCount;
1115 CopyMem (&FpdtRecordPtr.GuidQwordEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->
Guid));
1116 if ((PerfId == MODULE_LOADIMAGE_END_ID) && (mCachedLength != 0)) {
1117 if (mFpdtBufferIsReported) {
1123 CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->
Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->
Guid));
1130 case MODULE_DB_START_ID:
1131 case MODULE_DB_SUPPORT_START_ID:
1132 case MODULE_DB_SUPPORT_END_ID:
1133 case MODULE_DB_STOP_START_ID:
1134 case MODULE_DB_STOP_END_ID:
1136 StringPtr = ModuleName;
1137 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1138 FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
1140 FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1141 FpdtRecordPtr.GuidQwordEvent->
ProgressID = PerfId;
1142 FpdtRecordPtr.GuidQwordEvent->
Timestamp = TimeStamp;
1143 FpdtRecordPtr.GuidQwordEvent->
Qword = Address;
1144 CopyMem (&FpdtRecordPtr.GuidQwordEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->
Guid));
1149 case MODULE_DB_END_ID:
1151 StringPtr = ModuleName;
1152 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1153 FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
1155 FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1156 FpdtRecordPtr.GuidQwordStringEvent->
ProgressID = PerfId;
1157 FpdtRecordPtr.GuidQwordStringEvent->
Timestamp = TimeStamp;
1158 FpdtRecordPtr.GuidQwordStringEvent->
Qword = Address;
1159 CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordStringEvent->
Guid));
1167 case PERF_EVENTSIGNAL_START_ID:
1168 case PERF_EVENTSIGNAL_END_ID:
1169 case PERF_CALLBACK_START_ID:
1170 case PERF_CALLBACK_END_ID:
1171 if ((String ==
NULL) || (Guid ==
NULL)) {
1172 return EFI_INVALID_PARAMETER;
1177 StringPtr =
"unknown name";
1180 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1181 FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
1183 FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1184 FpdtRecordPtr.DualGuidStringEvent->
ProgressID = PerfId;
1185 FpdtRecordPtr.DualGuidStringEvent->
Timestamp = TimeStamp;
1186 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->
Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->
Guid1));
1187 CopyMem (&FpdtRecordPtr.DualGuidStringEvent->
Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->
Guid2));
1194 case PERF_FUNCTION_START_ID:
1195 case PERF_FUNCTION_END_ID:
1196 case PERF_INMODULE_START_ID:
1197 case PERF_INMODULE_END_ID:
1198 case PERF_CROSSMODULE_START_ID:
1199 case PERF_CROSSMODULE_END_ID:
1201 if (String !=
NULL) {
1204 StringPtr = ModuleName;
1208 StringPtr =
"unknown name";
1211 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1212 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1214 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1215 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
1216 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
1217 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->
Guid));
1224 if (Attribute != PerfEntry) {
1226 if (String !=
NULL) {
1229 StringPtr = ModuleName;
1233 StringPtr =
"unknown name";
1236 if (!
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1237 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1239 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1240 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
1241 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
1242 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->
Guid));
1246 return EFI_INVALID_PARAMETER;
1255 if (
PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
1256 if ((StringPtr ==
NULL) || (PerfId == MODULE_DB_SUPPORT_START_ID) || (PerfId == MODULE_DB_SUPPORT_END_ID)) {
1257 return EFI_INVALID_PARAMETER;
1260 FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
1262 FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
1263 FpdtRecordPtr.DynamicStringEvent->
ProgressID = PerfId;
1264 FpdtRecordPtr.DynamicStringEvent->
Timestamp = TimeStamp;
1269 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->
Guid));
1271 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->
Guid));
1275 StringPtr =
"unknown name";
1280 if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
1284 if (((PerfId == MODULE_LOADIMAGE_END_ID) || (PerfId == MODULE_END_ID)) && (mCachedLength != 0)) {
1285 if (mFpdtBufferIsReported) {
1291 if (PerfId == MODULE_LOADIMAGE_END_ID) {
1294 if (StringLen >= DestMax) {
1295 StringLen = DestMax -1;
1298 CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->
Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->
Guid));
1299 AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->
String, DestMax, StringPtr, StringLen);
1300 }
else if (PerfId == MODULE_END_ID) {
1303 if (StringLen >= DestMax) {
1304 StringLen = DestMax -1;
1307 CopyMem (&FpdtRecordPtr.DynamicStringEvent->
Guid, &CachedFpdtRecordPtr.DynamicStringEvent->
Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->
Guid));
1308 AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->
String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->
String, StringLen);
1318 if (mFpdtBufferIsReported) {
1319 mBootRecordSize += FpdtRecordPtr.RecordHeader->Length;
1320 mAcpiBootPerformanceTable->
Header.Length += FpdtRecordPtr.RecordHeader->Length;
1322 mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
1343 UINT8 *FirmwarePerformanceHob;
1348 GuidHob =
GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, HobStart);
1349 while (GuidHob !=
NULL) {
1350 FirmwarePerformanceHob = GET_GUID_HOB_DATA (GuidHob);
1353 if (mPerformanceLength + PeiPerformanceLogHeader->SizeOfAllEntries > mMaxPerformanceLength) {
1356 mPerformanceLength +
1357 (
UINTN)PeiPerformanceLogHeader->SizeOfAllEntries +
1358 FIRMWARE_RECORD_BUFFER,
1361 ASSERT (mPerformancePointer !=
NULL);
1362 mMaxPerformanceLength = mPerformanceLength +
1363 (
UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries) +
1364 FIRMWARE_RECORD_BUFFER;
1367 EventRec = mPerformancePointer + mPerformanceLength;
1372 mPerformanceLength += (
UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries);
1373 mLoadImageCount += PeiPerformanceLogHeader->LoadImageCount;
1378 GuidHob =
GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
1399 if (!mFpdtBufferIsReported) {
1401 if (!EFI_ERROR (Status)) {
1402 BPDTAddr = (UINT64)(
UINTN)mAcpiBootPerformanceTable;
1405 EFI_SOFTWARE_DXE_BS_DRIVER,
1408 &gEdkiiFpdtExtendedFirmwarePerformanceGuid,
1412 Status =
gBS->InstallConfigurationTable (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, (VOID *)(
UINTN)BPDTAddr);
1419 mFpdtBufferIsReported =
TRUE;
1437 VOID *SmmBootRecordData;
1438 UINTN SmmBootRecordDataSize;
1440 UINT8 *FirmwarePerformanceTablePtr;
1442 SmmBootRecordDataSize = 0;
1447 SmmBootRecordData =
NULL;
1450 FirmwarePerformanceTablePtr = (UINT8 *)mAcpiBootPerformanceTable + mAcpiBootPerformanceTable->
Header.Length;
1452 if (mAcpiBootPerformanceTable->
Header.Length + SmmBootRecordDataSize > mBootRecordMaxSize) {
1453 DEBUG ((DEBUG_INFO,
"DxeCorePerformanceLib: No enough space to save all SMM boot performance data\n"));
1454 AppendSize = mBootRecordMaxSize - mAcpiBootPerformanceTable->
Header.Length;
1456 AppendSize = SmmBootRecordDataSize;
1459 if (SmmBootRecordData !=
NULL) {
1460 CopyMem (FirmwarePerformanceTablePtr, SmmBootRecordData, AppendSize);
1461 mAcpiBootPerformanceTable->
Header.Length += (UINT32)AppendSize;
1462 mBootRecordSize += (UINT32)AppendSize;
1509 Status =
gBS->InstallMultipleProtocolInterfaces (
1511 &gEdkiiPerformanceMeasurementProtocolGuid,
1512 &mPerformanceMeasurementInterface,
1520 Status =
gBS->CreateEventEx (
1525 &gEfiEndOfDxeEventGroupGuid,
1532 Status =
gBS->CreateEventEx (
1537 &gEfiEventReadyToBootGuid,
1544 if (EFI_ERROR (Status)) {
1548 mPerformanceProperty.Revision = PERFORMANCE_PROPERTY_REVISION;
1549 mPerformanceProperty.Reserved = 0;
1551 &mPerformanceProperty.TimerStartValue,
1552 &mPerformanceProperty.TimerEndValue
1554 Status =
gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty);
1582 IN CONST VOID *CallerIdentifier,
1584 IN CONST CHAR8 *String OPTIONAL,
1585 IN UINT64 TimeStamp,
1586 IN UINT64 Address OPTIONAL,
1587 IN UINT32 Identifier,
1588 IN PERF_MEASUREMENT_ATTRIBUTE Attribute
1595 if (mLockInsertRecord) {
1596 return EFI_INVALID_PARAMETER;
1599 mLockInsertRecord =
TRUE;
1601 Status =
InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
1603 mLockInsertRecord =
FALSE;
1636 IN CONST VOID *Handle OPTIONAL,
1637 IN CONST CHAR8 *Token OPTIONAL,
1638 IN CONST CHAR8 *Module OPTIONAL,
1639 IN UINT64 TimeStamp,
1640 IN UINT32 Identifier
1643 CONST CHAR8 *String;
1645 if (Token !=
NULL) {
1647 }
else if (Module !=
NULL) {
1685 IN CONST VOID *Handle OPTIONAL,
1686 IN CONST CHAR8 *Token OPTIONAL,
1687 IN CONST CHAR8 *Module OPTIONAL,
1688 IN UINT64 TimeStamp,
1689 IN UINT32 Identifier
1692 CONST CHAR8 *String;
1694 if (Token !=
NULL) {
1696 }
else if (Module !=
NULL) {
1756 OUT UINT64 *StartTimeStamp,
1757 OUT UINT64 *EndTimeStamp,
1758 OUT UINT32 *Identifier
1790 IN CONST VOID *Handle OPTIONAL,
1791 IN CONST CHAR8 *Token OPTIONAL,
1792 IN CONST CHAR8 *Module OPTIONAL,
1826 IN CONST VOID *Handle OPTIONAL,
1827 IN CONST CHAR8 *Token OPTIONAL,
1828 IN CONST CHAR8 *Module OPTIONAL,
1883 OUT UINT64 *StartTimeStamp,
1884 OUT UINT64 *EndTimeStamp
1929 IN CONST VOID *CallerIdentifier,
1931 IN CONST CHAR8 *String OPTIONAL,
1932 IN UINT64 Address OPTIONAL,
1933 IN UINT32 Identifier
#define EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
UINT64 EFIAPI GetPerformanceCounterProperties(OUT UINT64 *StartValue OPTIONAL, OUT UINT64 *EndValue OPTIONAL)
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
VOID *EFIAPI GetHobList(VOID)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
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)
RETURN_STATUS EFIAPI UnicodeStrnToAsciiStrS(IN CONST CHAR16 *Source, IN UINTN Length, OUT CHAR8 *Destination, IN UINTN DestMax, OUT UINTN *DestinationLength)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
#define MEDIA_PIWG_FW_FILE_DP
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID *EFIAPI AllocatePeiAccessiblePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
EFI_STATUS EFIAPI GetSectionFromAnyFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_RUNTIME_SERVICES * gRT
#define RETURN_UNSUPPORTED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define REPORT_STATUS_CODE_EX(Type, Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, ExtendedDataSize)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
#define PcdGetBool(TokenName)
#define EFI_PROGRESS_CODE
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER Header
Common ACPI table header.
EFI_DEVICE_PATH_PROTOCOL * FilePath
VOID * ImageBase
The base address at which the image was loaded.
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_PHYSICAL_ADDRESS BootPerformanceTablePointer
Pointer to Boot Performance Table.