Make use of UefiRuntimeLib for refinement.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9647 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24
2009-12-30 09:05:31 +00:00
parent cde6425513
commit 9ae650ef6c
3 changed files with 11 additions and 44 deletions

View File

@ -25,6 +25,7 @@
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Library/OemHookStatusCodeLib.h> #include <Library/OemHookStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Guid/StatusCodeDataTypeId.h> #include <Guid/StatusCodeDataTypeId.h>
#include <Guid/StatusCodeDataTypeDebug.h> #include <Guid/StatusCodeDataTypeDebug.h>

View File

@ -48,11 +48,11 @@
OemHookStatusCodeLib OemHookStatusCodeLib
DevicePathLib DevicePathLib
MemoryAllocationLib MemoryAllocationLib
UefiRuntimeLib
[Guids] [Guids]
gEfiStatusCodeSpecificDataGuid ## CONSUMES gEfiStatusCodeSpecificDataGuid ## CONSUMES
gEfiStatusCodeDataTypeDebugGuid ## CONSUMES gEfiStatusCodeDataTypeDebugGuid ## CONSUMES
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event

View File

@ -14,11 +14,9 @@
#include "ReportStatusCodeLibInternal.h" #include "ReportStatusCodeLibInternal.h"
EFI_EVENT mVirtualAddressChangeEvent; EFI_EVENT mStatusCodeVirtualAddressChangeEvent;
EFI_EVENT mExitBootServicesEvent;
EFI_STATUS_CODE_DATA *mStatusCodeData; EFI_STATUS_CODE_DATA *mStatusCodeData;
EFI_RUNTIME_SERVICES *mInternalRT; EFI_RUNTIME_SERVICES *mStatusCodeInternalRT;
BOOLEAN mHaveExitedBootServices = FALSE;
EFI_REPORT_STATUS_CODE mReportStatusCode = NULL; EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;
/** /**
@ -39,7 +37,7 @@ InternalGetReportStatusCode (
EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol; EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;
EFI_STATUS Status; EFI_STATUS Status;
if (!mHaveExitedBootServices) { if (!EfiAtRuntime ()) {
// //
// Check gBS just in case. ReportStatusCode is called before gBS is initialized. // Check gBS just in case. ReportStatusCode is called before gBS is initialized.
// //
@ -122,27 +120,10 @@ ReportStatusCodeLibVirtualAddressChange (
) )
{ {
if (mReportStatusCode != NULL) { if (mReportStatusCode != NULL) {
mInternalRT->ConvertPointer (0, (VOID **) &mReportStatusCode); mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mReportStatusCode);
} }
mInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeData); mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeData);
mInternalRT->ConvertPointer (0, (VOID **) &mInternalRT); mStatusCodeInternalRT->ConvertPointer (0, (VOID **) &mStatusCodeInternalRT);
}
/**
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
)
{
mHaveExitedBootServices = TRUE;
} }
/** /**
@ -169,7 +150,7 @@ ReportStatusCodeLibConstruct (
// //
// Library should not use the gRT directly, for it may be converted by other library instance. // Library should not use the gRT directly, for it may be converted by other library instance.
// //
mInternalRT = gRT; mStatusCodeInternalRT = gRT;
mStatusCodeData = AllocateRuntimePool (sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE); mStatusCodeData = AllocateRuntimePool (sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE);
ASSERT (mStatusCodeData != NULL); ASSERT (mStatusCodeData != NULL);
@ -187,20 +168,7 @@ ReportStatusCodeLibConstruct (
ReportStatusCodeLibVirtualAddressChange, ReportStatusCodeLibVirtualAddressChange,
NULL, NULL,
&gEfiEventVirtualAddressChangeGuid, &gEfiEventVirtualAddressChangeGuid,
&mVirtualAddressChangeEvent &mStatusCodeVirtualAddressChangeEvent
);
ASSERT_EFI_ERROR (Status);
//
// Register notify function for EVT_SIGNAL_EXIT_BOOT_SERVICES
//
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
ReportStatusCodeLibExitBootServices,
NULL,
&gEfiEventExitBootServicesGuid,
&mExitBootServicesEvent
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
@ -229,9 +197,7 @@ ReportStatusCodeLibDestruct (
EFI_STATUS Status; EFI_STATUS Status;
ASSERT (gBS != NULL); ASSERT (gBS != NULL);
Status = gBS->CloseEvent (mVirtualAddressChangeEvent); Status = gBS->CloseEvent (mStatusCodeVirtualAddressChangeEvent);
ASSERT_EFI_ERROR (Status);
Status = gBS->CloseEvent (mExitBootServicesEvent);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
FreePool (mStatusCodeData); FreePool (mStatusCodeData);