Use SmmStatusCode protocol in EfiInitializeSmmDriverLib() funciton.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11213 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2010-12-31 04:36:50 +00:00
parent 9ae0edbfa9
commit 2a6433fef2
2 changed files with 52 additions and 46 deletions

View File

@ -27,6 +27,8 @@ Abstract:
#include EFI_GUID_DEFINITION (StatusCodeCallerId) #include EFI_GUID_DEFINITION (StatusCodeCallerId)
#include EFI_GUID_DEFINITION (Hob) #include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
#include EFI_PROTOCOL_DEFINITION (SmmBase)
// //
// Driver Lib Module Globals // Driver Lib Module Globals
@ -36,6 +38,7 @@ static EFI_EVENT mRuntimeNotifyEvent = NULL;
static EFI_EVENT mEfiVirtualNotifyEvent = NULL; static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
static BOOLEAN mRuntimeLibInitialized = FALSE; static BOOLEAN mRuntimeLibInitialized = FALSE;
static BOOLEAN mEfiGoneVirtual = FALSE; static BOOLEAN mEfiGoneVirtual = FALSE;
static BOOLEAN mInSmm = FALSE;
// //
// Runtime Global, but you should use the Lib functions // Runtime Global, but you should use the Lib functions
@ -43,6 +46,7 @@ static BOOLEAN mEfiGoneVirtual = FALSE;
EFI_CPU_IO_PROTOCOL *gCpuIo; EFI_CPU_IO_PROTOCOL *gCpuIo;
BOOLEAN mEfiAtRuntime = FALSE; BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry; FVB_ENTRY *mFvbEntry;
EFI_SMM_STATUS_CODE_PROTOCOL *gSmmStatusCodeProtocol = NULL;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
@ -493,10 +497,8 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_SMM_BASE_PROTOCOL *SmmBase;
VOID *Registration;
#endif
if (mRuntimeLibInitialized) { if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
@ -512,28 +514,21 @@ Returns:
mRT = SystemTable->RuntimeServices; mRT = SystemTable->RuntimeServices;
ASSERT (mRT != NULL); ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
// //
// Register EFI_STATUS_CODE_PROTOCOL notify function // Check whether it is in SMM mode.
// //
Status = gBS->CreateEvent ( Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, &SmmBase);
EFI_EVENT_NOTIFY_SIGNAL, if (!EFI_ERROR (Status)) {
EFI_TPL_CALLBACK, SmmBase->InSmm (SmmBase, &mInSmm);
OnStatusCodeInstall, }
NULL,
&gEfiStatusCodeNotifyEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->RegisterProtocolNotify ( //
&gEfiStatusCodeRuntimeProtocolGuid, // Directly locate SmmStatusCode protocol
gEfiStatusCodeNotifyEvent, //
&Registration Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, &gSmmStatusCodeProtocol);
); if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status); gSmmStatusCodeProtocol = NULL;
}
gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo); Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -912,6 +907,14 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (mInSmm) {
if (gSmmStatusCodeProtocol == NULL) {
return EFI_UNSUPPORTED;
}
Status = gSmmStatusCodeProtocol->ReportStatusCode (gSmmStatusCodeProtocol, CodeType, Value, Instance, CallerId, Data);
return Status;
}
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
if (gReportStatusCode == NULL) { if (gReportStatusCode == NULL) {

View File

@ -27,6 +27,8 @@ Abstract:
#include EFI_GUID_DEFINITION (StatusCodeCallerId) #include EFI_GUID_DEFINITION (StatusCodeCallerId)
#include EFI_GUID_DEFINITION (Hob) #include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode) #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
#include EFI_PROTOCOL_DEFINITION (SmmBase)
// //
// Driver Lib Module Globals // Driver Lib Module Globals
@ -36,6 +38,7 @@ static EFI_EVENT mRuntimeNotifyEvent = NULL;
static EFI_EVENT mEfiVirtualNotifyEvent = NULL; static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
static BOOLEAN mRuntimeLibInitialized = FALSE; static BOOLEAN mRuntimeLibInitialized = FALSE;
static BOOLEAN mEfiGoneVirtual = FALSE; static BOOLEAN mEfiGoneVirtual = FALSE;
static BOOLEAN mInSmm = FALSE;
// //
// Runtime Global, but you should use the Lib functions // Runtime Global, but you should use the Lib functions
@ -43,6 +46,7 @@ static BOOLEAN mEfiGoneVirtual = FALSE;
EFI_CPU_IO_PROTOCOL *gCpuIo; EFI_CPU_IO_PROTOCOL *gCpuIo;
BOOLEAN mEfiAtRuntime = FALSE; BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry; FVB_ENTRY *mFvbEntry;
EFI_SMM_STATUS_CODE_PROTOCOL *gSmmStatusCodeProtocol = NULL;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
@ -493,10 +497,8 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_SMM_BASE_PROTOCOL *SmmBase;
VOID *Registration;
#endif
if (mRuntimeLibInitialized) { if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
@ -512,28 +514,21 @@ Returns:
mRT = SystemTable->RuntimeServices; mRT = SystemTable->RuntimeServices;
ASSERT (mRT != NULL); ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
// //
// Register EFI_STATUS_CODE_PROTOCOL notify function // Check whether it is in SMM mode.
// //
Status = gBS->CreateEvent ( Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, &SmmBase);
EFI_EVENT_NOTIFY_SIGNAL, if (!EFI_ERROR (Status)) {
EFI_TPL_CALLBACK, SmmBase->InSmm (SmmBase, &mInSmm);
OnStatusCodeInstall, }
NULL,
&gEfiStatusCodeNotifyEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->RegisterProtocolNotify ( //
&gEfiStatusCodeRuntimeProtocolGuid, // Directly locate SmmStatusCode protocol
gEfiStatusCodeNotifyEvent, //
&Registration Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, &gSmmStatusCodeProtocol);
); if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status); gSmmStatusCodeProtocol = NULL;
}
gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo); Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -912,6 +907,14 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (mInSmm) {
if (gSmmStatusCodeProtocol == NULL) {
return EFI_UNSUPPORTED;
}
Status = gSmmStatusCodeProtocol->ReportStatusCode (gSmmStatusCodeProtocol, CodeType, Value, Instance, CallerId, Data);
return Status;
}
#if (EFI_SPECIFICATION_VERSION >= 0x00020000) #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
if (gReportStatusCode == NULL) { if (gReportStatusCode == NULL) {