IntelFsp2Pkg: Added changes to enable FPDT performance measurements
[mirror_edk2.git] / IntelFsp2WrapperPkg / FspWrapperNotifyDxe / FspWrapperNotifyDxe.c
index 0797f44..a692632 100644 (file)
@@ -25,6 +25,7 @@
 #include <Library/FspWrapperPlatformLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/HobLib.h>\r
+#include <FspStatusCode.h>\r
 \r
 typedef\r
 EFI_STATUS\r
@@ -91,9 +92,9 @@ OnPciEnumerationComplete (
   }\r
 \r
   NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;\r
-  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x6000);\r
+  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_POST_PCIE_ENUM_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
   Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
-  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x607F);\r
+  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_POST_PCIE_ENUM_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
 \r
   //\r
   // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
@@ -130,16 +131,13 @@ OnReadyToBoot (
 {\r
   NOTIFY_PHASE_PARAMS               NotifyPhaseParams;\r
   EFI_STATUS                        Status;\r
-  ADD_PERFORMANCE_RECORD_PROTOCOL   *AddPerfRecordInterface;\r
-  EFI_PEI_HOB_POINTERS              Hob;\r
-  VOID                              **FspHobListPtr;\r
 \r
   gBS->CloseEvent (Event);\r
 \r
   NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;\r
-  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x4000);\r
+  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_READY_TO_BOOT_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
   Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
-  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x407F);\r
+  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_READY_TO_BOOT_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
 \r
   //\r
   // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
@@ -154,23 +152,6 @@ OnReadyToBoot (
   } else {\r
     DEBUG((DEBUG_INFO, "FSP NotifyPhase ReadyToBoot Success.\n"));\r
   }\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gAddPerfRecordProtocolGuid,\r
-                  NULL,\r
-                  (VOID**) &AddPerfRecordInterface\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG((DEBUG_INFO, "gAddPerfRecordProtocolGuid - Locate protocol failed\n"));\r
-    return;\r
-  } else {\r
-    Hob.Raw = GetHobList ();\r
-    if (Hob.Raw != NULL) {\r
-      Hob.Raw = GetNextGuidHob (&gFspHobGuid, Hob.Raw);\r
-      FspHobListPtr = GET_GUID_HOB_DATA(Hob.Raw);\r
-      AddPerfRecordInterface->AddPerformanceRecords((VOID *)(UINTN)(((UINT32)(UINTN)*FspHobListPtr) & 0xFFFFFFFF));\r
-    }\r
-  }\r
 }\r
 \r
 /**\r
@@ -189,15 +170,18 @@ OnEndOfFirmware (
   IN VOID       *Context\r
   )\r
 {\r
-  NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
-  EFI_STATUS          Status;\r
+  NOTIFY_PHASE_PARAMS               NotifyPhaseParams;\r
+  EFI_STATUS                        Status;\r
+  ADD_PERFORMANCE_RECORD_PROTOCOL   *AddPerfRecordInterface;\r
+  EFI_PEI_HOB_POINTERS              Hob;\r
+  VOID                              **FspHobListPtr;\r
 \r
   gBS->CloseEvent (Event);\r
 \r
   NotifyPhaseParams.Phase = EnumInitPhaseEndOfFirmware;\r
-  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x2000);\r
+  PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
   Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
-  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0x207F);\r
+  PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_END_OF_FIRMWARE_NOTIFICATION | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
 \r
   //\r
   // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
@@ -212,6 +196,21 @@ OnEndOfFirmware (
   } else {\r
     DEBUG((DEBUG_INFO, "FSP NotifyPhase EndOfFirmware Success.\n"));\r
   }\r
+  Status = gBS->LocateProtocol (\r
+                  &gAddPerfRecordProtocolGuid,\r
+                  NULL,\r
+                  (VOID**) &AddPerfRecordInterface\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG((DEBUG_INFO, "gAddPerfRecordProtocolGuid - Locate protocol failed\n"));\r
+    return;\r
+  } else {\r
+    Hob.Raw = GetFirstGuidHob (&gFspHobGuid);\r
+    if (Hob.Raw != NULL) {\r
+      FspHobListPtr = GET_GUID_HOB_DATA (Hob.Raw);\r
+      AddPerfRecordInterface->AddPerformanceRecords ((VOID *)(UINTN)(((UINT32)(UINTN)*FspHobListPtr) & 0xFFFFFFFF));\r
+    }\r
+  }\r
 }\r
 \r
 /**\r