From c05e7994a16761ef212db0ff6ab95ee2748b29e9 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 2 Aug 2011 06:23:54 +0000 Subject: Fixed the issue in RuntimeStatusCode library that may not work on the early dispatched Runtime driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12073 6f19259b-4bc3-4df7-8a09-765794883524 --- .../ReportStatusCodeLib.c | 48 ++++++++++++++++++++-- .../RuntimeDxeReportStatusCodeLib.inf | 3 +- 2 files changed, 46 insertions(+), 5 deletions(-) (limited to 'MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib') diff --git a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c index cbfd8247b9..f6b7ee756b 100644 --- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -1,7 +1,7 @@ /** @file API implementation for instance of Report Status Code Library. - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -29,6 +29,8 @@ EFI_STATUS_CODE_PROTOCOL *mReportStatusCodeLibStatusCodeProtocol = NULL; EFI_EVENT mReportStatusCodeLibVirtualAddressChangeEvent; +EFI_EVENT mReportStatusCodeLibExitBootServicesEvent; +BOOLEAN mHaveExitedBootServices = FALSE; /** Locate the report status code service. @@ -47,7 +49,7 @@ InternalGetReportStatusCode ( return; } - if (EfiAtRuntime ()) { + if (mHaveExitedBootServices) { return; } @@ -82,6 +84,28 @@ ReportStatusCodeLibVirtualAddressChange ( EfiConvertPointer (0, (VOID **) &mReportStatusCodeLibStatusCodeProtocol); } +/** + Notification function of EVT_SIGNAL_EXIT_BOOT_SERVICES. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context + +**/ +VOID +EFIAPI +ReportStatusCodeLibExitBootServices ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Locate the report status code service before enter runtime. + // + InternalGetReportStatusCode (); + + mHaveExitedBootServices = TRUE; +} + /** The constructor function of Runtime DXE Report Status Code Lib. @@ -121,6 +145,19 @@ ReportStatusCodeLibConstructor ( ); ASSERT_EFI_ERROR (Status); + // + // Register notify function for EVT_SIGNAL_EXIT_BOOT_SERVICES + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + ReportStatusCodeLibExitBootServices, + NULL, + &gEfiEventExitBootServicesGuid, + &mReportStatusCodeLibExitBootServicesEvent + ); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } @@ -149,6 +186,9 @@ ReportStatusCodeLibDestructor ( Status = gBS->CloseEvent (mReportStatusCodeLibVirtualAddressChangeEvent); ASSERT_EFI_ERROR (Status); + Status = gBS->CloseEvent (mReportStatusCodeLibExitBootServicesEvent); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; } @@ -586,7 +626,7 @@ ReportStatusCodeEx ( ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); - if (EfiAtRuntime ()) { + if (mHaveExitedBootServices) { if (sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { return EFI_OUT_OF_RESOURCES; } @@ -634,7 +674,7 @@ ReportStatusCodeEx ( // // Free the allocated buffer // - if (!EfiAtRuntime()) { + if (!mHaveExitedBootServices) { gBS->FreePool (StatusCodeData); } diff --git a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf index ccdb66eb6d..6d1542dfc2 100644 --- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf +++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf @@ -1,7 +1,7 @@ ## @file # Report status code library instance which supports logging message in DXE & runtime phase. # -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -48,6 +48,7 @@ gEfiStatusCodeSpecificDataGuid ## CONSUMES gEfiStatusCodeDataTypeDebugGuid ## CONSUMES gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event + gEfiEventExitBootServicesGuid ## CONSUMES ## Event [Protocols] gEfiStatusCodeRuntimeProtocolGuid ## CONSUMES -- cgit v1.2.3