mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
1) Replace mBS with gBS from UefiBootServicesTablePointer Lib to avoid library instance to cache too many copies of Boot Service Pointer.
2) Check gBS before make call using it. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5944 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
834a2e41fb
commit
9556741cbf
@ -23,6 +23,7 @@
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
#include <Protocol/StatusCode.h>
|
||||
|
@ -49,6 +49,7 @@
|
||||
BaseLib
|
||||
DebugLib
|
||||
UefiRuntimeServicesTableLib
|
||||
UefiBootServicesTableLib
|
||||
OemHookStatusCodeLib
|
||||
|
||||
[Guids]
|
||||
|
@ -37,9 +37,6 @@ EFI_SMM_BASE_PROTOCOL *mSmmBase;
|
||||
STATIC
|
||||
EFI_RUNTIME_SERVICES *mRT;
|
||||
|
||||
STATIC
|
||||
EFI_BOOT_SERVICES *mBS;
|
||||
|
||||
STATIC
|
||||
BOOLEAN mHaveExitedBootServices = FALSE;
|
||||
|
||||
@ -59,12 +56,17 @@ InternalGetReportStatusCode (
|
||||
|
||||
if (mInSmm) {
|
||||
return (EFI_REPORT_STATUS_CODE) OemHookStatusCodeReport;
|
||||
} else if (mRT->Hdr.Revision < 0x20000) {
|
||||
} else if (mRT != NULL && mRT->Hdr.Revision < 0x20000) {
|
||||
return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mRT)->ReportStatusCode;
|
||||
} else if (!mHaveExitedBootServices) {
|
||||
Status = mBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);
|
||||
if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {
|
||||
return StatusCodeProtocol->ReportStatusCode;
|
||||
//
|
||||
// Check gBS just in case. ReportStatusCode is called before gBS is initialized.
|
||||
//
|
||||
if (gBS != NULL) {
|
||||
Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);
|
||||
if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {
|
||||
return StatusCodeProtocol->ReportStatusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,14 +129,11 @@ ReportStatusCodeLibConstruct (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
mBS = SystemTable->BootServices;
|
||||
|
||||
//
|
||||
// SMM driver depends on the SMM BASE protocol.
|
||||
// the SMM driver must be success to locate protocol.
|
||||
//
|
||||
ASSERT (mBS != NULL);
|
||||
Status = mBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase);
|
||||
Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
mSmmBase->InSmm (mSmmBase, &mInSmm);
|
||||
if (mInSmm) {
|
||||
@ -157,7 +156,7 @@ ReportStatusCodeLibConstruct (
|
||||
mRT = gRT;
|
||||
mInSmm = FALSE;
|
||||
|
||||
mBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData);
|
||||
gBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData);
|
||||
ASSERT (NULL != mStatusCodeData);
|
||||
//
|
||||
// Cache the report status code service
|
||||
@ -167,7 +166,7 @@ ReportStatusCodeLibConstruct (
|
||||
//
|
||||
// Register the call back of virtual address change
|
||||
//
|
||||
Status = mBS->CreateEvent (
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
|
||||
TPL_NOTIFY,
|
||||
ReportStatusCodeLibVirtualAddressChange,
|
||||
@ -180,7 +179,7 @@ ReportStatusCodeLibConstruct (
|
||||
//
|
||||
// Register the call back of virtual address change
|
||||
//
|
||||
Status = mBS->CreateEvent (
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_SIGNAL_EXIT_BOOT_SERVICES,
|
||||
TPL_NOTIFY,
|
||||
ReportStatusCodeLibExitBootServices,
|
||||
@ -212,13 +211,13 @@ ReportStatusCodeLibDestruct (
|
||||
//
|
||||
// Close SetVirtualAddressMap () notify function
|
||||
//
|
||||
ASSERT (mBS != NULL);
|
||||
Status = mBS->CloseEvent (mVirtualAddressChangeEvent);
|
||||
ASSERT (gBS != NULL);
|
||||
Status = gBS->CloseEvent (mVirtualAddressChangeEvent);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = mBS->CloseEvent (mExitBootServicesEvent);
|
||||
Status = gBS->CloseEvent (mExitBootServicesEvent);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
mBS->FreePool (mStatusCodeData);
|
||||
gBS->FreePool (mStatusCodeData);
|
||||
} else {
|
||||
mSmmBase->SmmFreePool (mSmmBase, mStatusCodeData);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user