[Description]:

The patch enhances the SmmRuntimeDxeReportStatusCodeLibFramework instance to reduce the library dependency, since DebugLib, UefiBootServicesTableLib and original SmmRuntimeDxeReportStatusCodeLibFramework may result in the circular dependency.

[Impaction]:
It is backward-compatible.

[Reference Info]:
N/A

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4919 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
yshang1 2008-03-19 09:35:46 +00:00
parent 4a73341484
commit e12848a3a3
3 changed files with 15 additions and 13 deletions

View File

@ -19,7 +19,6 @@
#include <Library/ReportStatusCodeLib.h> #include <Library/ReportStatusCodeLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
@ -31,7 +30,6 @@
#include <FrameworkModuleBase.h> #include <FrameworkModuleBase.h>
#include <DebugInfo.h> #include <DebugInfo.h>
/** /**
Locatet he report status code service. Locatet he report status code service.

View File

@ -47,7 +47,6 @@
PcdLib PcdLib
BaseMemoryLib BaseMemoryLib
BaseLib BaseLib
UefiBootServicesTableLib
DebugLib DebugLib
UefiRuntimeServicesTableLib UefiRuntimeServicesTableLib
OemHookStatusCodeLib OemHookStatusCodeLib

View File

@ -35,6 +35,9 @@ BOOLEAN mInSmm;
STATIC STATIC
EFI_RUNTIME_SERVICES *mRT; EFI_RUNTIME_SERVICES *mRT;
STATIC
EFI_BOOT_SERVICES *mBS;
STATIC STATIC
BOOLEAN mHaveExitedBootServices = FALSE; BOOLEAN mHaveExitedBootServices = FALSE;
@ -57,7 +60,7 @@ InternalGetReportStatusCode (
} else if (mRT->Hdr.Revision < 0x20000) { } else if (mRT->Hdr.Revision < 0x20000) {
return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mRT)->ReportStatusCode; return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mRT)->ReportStatusCode;
} else if (!mHaveExitedBootServices) { } else if (!mHaveExitedBootServices) {
Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol); Status = mBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);
if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) { if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {
return StatusCodeProtocol->ReportStatusCode; return StatusCodeProtocol->ReportStatusCode;
} }
@ -123,12 +126,14 @@ ReportStatusCodeLibConstruct (
EFI_SMM_BASE_PROTOCOL *SmmBase; EFI_SMM_BASE_PROTOCOL *SmmBase;
EFI_STATUS Status; EFI_STATUS Status;
mBS = SystemTable->BootServices;
// //
// SMM driver depends on the SMM BASE protocol. // SMM driver depends on the SMM BASE protocol.
// the SMM driver must be success to locate protocol. // the SMM driver must be success to locate protocol.
// //
ASSERT (gBS != NULL); ASSERT (mBS != NULL);
Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &SmmBase); Status = mBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &SmmBase);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
SmmBase->InSmm (SmmBase, &mInSmm); SmmBase->InSmm (SmmBase, &mInSmm);
if (mInSmm) { if (mInSmm) {
@ -151,7 +156,7 @@ ReportStatusCodeLibConstruct (
mRT = gRT; mRT = gRT;
mInSmm = FALSE; mInSmm = FALSE;
gBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData); mBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData);
ASSERT (NULL != mStatusCodeData); ASSERT (NULL != mStatusCodeData);
// //
// Cache the report status code service // Cache the report status code service
@ -161,7 +166,7 @@ ReportStatusCodeLibConstruct (
// //
// Register the call back of virtual address change // Register the call back of virtual address change
// //
Status = gBS->CreateEvent ( Status = mBS->CreateEvent (
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE, EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
TPL_NOTIFY, TPL_NOTIFY,
ReportStatusCodeLibVirtualAddressChange, ReportStatusCodeLibVirtualAddressChange,
@ -174,7 +179,7 @@ ReportStatusCodeLibConstruct (
// //
// Register the call back of virtual address change // Register the call back of virtual address change
// //
Status = gBS->CreateEvent ( Status = mBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES, EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_NOTIFY, TPL_NOTIFY,
ReportStatusCodeLibExitBootServices, ReportStatusCodeLibExitBootServices,
@ -199,13 +204,13 @@ ReportStatusCodeLibDestruct (
// //
// Close SetVirtualAddressMap () notify function // Close SetVirtualAddressMap () notify function
// //
ASSERT (gBS != NULL); ASSERT (mBS != NULL);
Status = gBS->CloseEvent (mVirtualAddressChangeEvent); Status = mBS->CloseEvent (mVirtualAddressChangeEvent);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->CloseEvent (mExitBootServicesEvent); Status = mBS->CloseEvent (mExitBootServicesEvent);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
gBS->FreePool (mStatusCodeData); mBS->FreePool (mStatusCodeData);
return Status; return Status;
} }