]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Unregister DXE FpdtStatusCodeHandler.
authorLiming Gao <liming.gao@intel.com>
Wed, 3 Dec 2014 15:34:08 +0000 (15:34 +0000)
committerlgao4 <lgao4@Edk2>
Wed, 3 Dec 2014 15:34:08 +0000 (15:34 +0000)
DXE FpdtStatusCodeHandler is required to be unregistered even if StatusCodeReport is disabled. This change makes sure FpdtStatusCodeHandler be always unregistered.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Vincent Zimmer <vincent.zimmer@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16470 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c

index caf924ccf8e7a9b04ab32e89b7d7ca6f2d1d9782..b1801a70f8c46c9c06656f8b4f108f21bc7a2b9b 100644 (file)
@@ -54,6 +54,7 @@ UINTN                       mFirmwarePerformanceTableTemplateKey  = 0;
 UINT32                      mBootRecordSize = 0;\r
 UINT32                      mBootRecordMaxSize = 0;\r
 UINT8                       *mBootRecordBuffer = NULL;\r
+BOOLEAN                     mDxeCoreReportStatusCodeEnable = FALSE;\r
 \r
 BOOT_PERFORMANCE_TABLE                      *mAcpiBootPerformanceTable = NULL;\r
 S3_PERFORMANCE_TABLE                        *mAcpiS3PerformanceTable   = NULL;\r
@@ -594,45 +595,6 @@ FpdtLegacyBootEventNotify (
   DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit    = 0\n"));\r
 }\r
 \r
-/**\r
-  Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record\r
-  performance data for ExitBootServicesEntry in FPDT.\r
-\r
-  @param[in]  Event   The Event that is being processed.\r
-  @param[in]  Context The Event Context.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FpdtExitBootServicesEventNotify (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  if (mAcpiBootPerformanceTable == NULL) {\r
-    //\r
-    // Firmware Performance Data Table not installed, do nothing.\r
-    //\r
-    return ;\r
-  }\r
-\r
-  //\r
-  // Update Firmware Basic Boot Performance Record for UEFI boot.\r
-  //\r
-  mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = GetTimeInNanoSecond (GetPerformanceCounter ());\r
-\r
-  //\r
-  // Dump FPDT Boot Performance record.\r
-  //\r
-  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd                = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));\r
-  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart  = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart));\r
-  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));\r
-  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry   = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry));\r
-  //\r
-  // ExitBootServicesExit will be updated later, so don't dump it here.\r
-  //\r
-}\r
-\r
 /**\r
   Report status code listener of FPDT. This is used to collect performance data\r
   for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.\r
@@ -670,6 +632,13 @@ FpdtStatusCodeListenerDxe (
   if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {\r
     return EFI_UNSUPPORTED;\r
   }\r
+  \r
+  if (Value == (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)) {\r
+    //\r
+    // DxeCore ReportStatusCode Enable so that the capability can be supported.\r
+    //\r
+    mDxeCoreReportStatusCodeEnable = TRUE;\r
+  }\r
 \r
   Status = EFI_SUCCESS;\r
   if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) {\r
@@ -697,6 +666,11 @@ FpdtStatusCodeListenerDxe (
     //\r
     mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ());\r
   } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {\r
+    //\r
+    // Unregister boot time report status code listener.\r
+    //\r
+    mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);\r
+\r
     //\r
     // Progress code for ExitBootServices.\r
     //\r
@@ -708,11 +682,6 @@ FpdtStatusCodeListenerDxe (
     // Update ExitBootServicesExit for UEFI boot.\r
     //\r
     mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesExit = GetTimeInNanoSecond (GetPerformanceCounter ());\r
-\r
-    //\r
-    // Unregister boot time report status code listener.\r
-    //\r
-    mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);\r
   } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {\r
     //\r
     // Append one or more Boot records\r
@@ -759,6 +728,54 @@ FpdtStatusCodeListenerDxe (
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record\r
+  performance data for ExitBootServicesEntry in FPDT.\r
+\r
+  @param[in]  Event   The Event that is being processed.\r
+  @param[in]  Context The Event Context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FpdtExitBootServicesEventNotify (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  if (mDxeCoreReportStatusCodeEnable == FALSE) {\r
+    //\r
+    // When DxeCore Report Status Code is disabled, \r
+    // Unregister boot time report status code listener at ExitBootService Event.\r
+    //\r
+    mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);\r
+  }\r
+\r
+  if (mAcpiBootPerformanceTable == NULL) {\r
+    //\r
+    // Firmware Performance Data Table not installed, do nothing.\r
+    //\r
+    return ;\r
+  }\r
+\r
+  //\r
+  // Update Firmware Basic Boot Performance Record for UEFI boot.\r
+  //\r
+  mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = GetTimeInNanoSecond (GetPerformanceCounter ());\r
+\r
+  //\r
+  // Dump FPDT Boot Performance record.\r
+  //\r
+  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd                = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));\r
+  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart  = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart));\r
+  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));\r
+  DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry   = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry));\r
+  //\r
+  // ExitBootServicesExit will be updated later, so don't dump it here.\r
+  //\r
+}\r
+\r
 /**\r
   The module Entry Point of the Firmware Performance Data Table DXE driver.\r
 \r