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
This commit is contained in:
lgao4 2011-08-02 06:23:54 +00:00
parent 3c28a7280b
commit c05e7994a1
2 changed files with 46 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/** @file
API implementation for instance of Report Status Code Library.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
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);
}

View File

@ -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.<BR>
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
#
# 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