diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c index 0b98e7ec63..348f55edba 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c @@ -151,6 +151,16 @@ SerialStatusCodeReportWorker ( // SerialPortWrite ((UINT8 *) Buffer, CharCount); + // + // If register an unregister function of gEfiEventExitBootServicesGuid, + // then some log called in ExitBootServices() will be lost, + // so unregister the handler after receive the value of exit boot service. + // + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE && + Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) { + UnregisterSerialBootTimeHandlers(); + } + return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c index a8c0fe5b71..d50335af8a 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c @@ -10,23 +10,17 @@ #include "StatusCodeHandlerRuntimeDxe.h" EFI_EVENT mVirtualAddressChangeEvent = NULL; -static EFI_EVENT mExitBootServicesEvent = NULL; EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; /** Unregister status code callback functions only available at boot time from report status code router when exiting boot services. - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context, which is - always zero in current implementation. - **/ VOID EFIAPI -UnregisterBootTimeHandlers ( - IN EFI_EVENT Event, - IN VOID *Context +UnregisterSerialBootTimeHandlers ( + VOID ) { if (PcdGetBool (PcdStatusCodeUseSerial)) { @@ -178,15 +172,6 @@ StatusCodeHandlerRuntimeDxeEntry ( mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL); } - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - UnregisterBootTimeHandlers, - NULL, - &gEfiEventExitBootServicesGuid, - &mExitBootServicesEvent - ); - Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h index fd4689c2d7..a2cf2ae0b7 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h @@ -118,4 +118,15 @@ RtMemoryStatusCodeReportWorker ( IN EFI_STATUS_CODE_DATA *Data OPTIONAL ); +/** + Unregister status code callback functions only available at boot time from + report status code router when exiting boot services. + +**/ +VOID +EFIAPI +UnregisterSerialBootTimeHandlers ( + VOID + ); + #endif