MdeModulePkg: Unregister DXE FpdtStatusCodeHandler.

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
This commit is contained in:
Liming Gao 2014-12-03 15:34:08 +00:00 committed by lgao4
parent 8546dfeace
commit 40a0f8cb78
1 changed files with 61 additions and 44 deletions

View File

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