diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-31 04:36:50 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-31 04:36:50 +0000 |
commit | 2a6433fef2413df583db6399008c7e6716a8e243 (patch) | |
tree | 705c6aecb390bb02624c28e410e20918c78fd8d9 /EdkCompatibilityPkg | |
parent | 9ae0edbfa90b6e19765c407d950bed44ee6c01ef (diff) | |
download | edk2-platforms-2a6433fef2413df583db6399008c7e6716a8e243.tar.xz |
Use SmmStatusCode protocol in EfiInitializeSmmDriverLib() funciton.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11213 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r-- | EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c | 49 | ||||
-rw-r--r-- | EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c | 49 |
2 files changed, 52 insertions, 46 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c index 83820a3bba..3e973e0909 100644 --- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c @@ -27,6 +27,8 @@ Abstract: #include EFI_GUID_DEFINITION (StatusCodeCallerId)
#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
//
// Driver Lib Module Globals
@@ -36,6 +38,7 @@ static EFI_EVENT mRuntimeNotifyEvent = NULL; static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
static BOOLEAN mRuntimeLibInitialized = FALSE;
static BOOLEAN mEfiGoneVirtual = FALSE;
+static BOOLEAN mInSmm = FALSE;
//
// Runtime Global, but you should use the Lib functions
@@ -43,6 +46,7 @@ static BOOLEAN mEfiGoneVirtual = FALSE; EFI_CPU_IO_PROTOCOL *gCpuIo;
BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
+EFI_SMM_STATUS_CODE_PROTOCOL *gSmmStatusCodeProtocol = NULL;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
@@ -493,10 +497,8 @@ Returns: --*/
{
- EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- VOID *Registration;
-#endif
+ EFI_STATUS Status;
+ EFI_SMM_BASE_PROTOCOL *SmmBase;
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -512,28 +514,21 @@ Returns: mRT = SystemTable->RuntimeServices;
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 (
- EFI_EVENT_NOTIFY_SIGNAL,
- EFI_TPL_CALLBACK,
- OnStatusCodeInstall,
- NULL,
- &gEfiStatusCodeNotifyEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiStatusCodeRuntimeProtocolGuid,
- gEfiStatusCodeNotifyEvent,
- &Registration
- );
- ASSERT_EFI_ERROR (Status);
+ Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, &SmmBase);
+ if (!EFI_ERROR (Status)) {
+ SmmBase->InSmm (SmmBase, &mInSmm);
+ }
- gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
-#endif
+ //
+ // Directly locate SmmStatusCode protocol
+ //
+ Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, &gSmmStatusCodeProtocol);
+ if (EFI_ERROR (Status)) {
+ gSmmStatusCodeProtocol = NULL;
+ }
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
if (EFI_ERROR (Status)) {
@@ -912,6 +907,14 @@ Returns: --*/
{
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 (gReportStatusCode == NULL) {
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c index a81bd0fb0f..4dfca7c853 100644 --- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c @@ -27,6 +27,8 @@ Abstract: #include EFI_GUID_DEFINITION (StatusCodeCallerId)
#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
//
// Driver Lib Module Globals
@@ -36,6 +38,7 @@ static EFI_EVENT mRuntimeNotifyEvent = NULL; static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
static BOOLEAN mRuntimeLibInitialized = FALSE;
static BOOLEAN mEfiGoneVirtual = FALSE;
+static BOOLEAN mInSmm = FALSE;
//
// Runtime Global, but you should use the Lib functions
@@ -43,6 +46,7 @@ static BOOLEAN mEfiGoneVirtual = FALSE; EFI_CPU_IO_PROTOCOL *gCpuIo;
BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
+EFI_SMM_STATUS_CODE_PROTOCOL *gSmmStatusCodeProtocol = NULL;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
@@ -493,10 +497,8 @@ Returns: --*/
{
- EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- VOID *Registration;
-#endif
+ EFI_STATUS Status;
+ EFI_SMM_BASE_PROTOCOL *SmmBase;
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -512,28 +514,21 @@ Returns: mRT = SystemTable->RuntimeServices;
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 (
- EFI_EVENT_NOTIFY_SIGNAL,
- EFI_TPL_CALLBACK,
- OnStatusCodeInstall,
- NULL,
- &gEfiStatusCodeNotifyEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiStatusCodeRuntimeProtocolGuid,
- gEfiStatusCodeNotifyEvent,
- &Registration
- );
- ASSERT_EFI_ERROR (Status);
+ Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, &SmmBase);
+ if (!EFI_ERROR (Status)) {
+ SmmBase->InSmm (SmmBase, &mInSmm);
+ }
- gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
-#endif
+ //
+ // Directly locate SmmStatusCode protocol
+ //
+ Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, &gSmmStatusCodeProtocol);
+ if (EFI_ERROR (Status)) {
+ gSmmStatusCodeProtocol = NULL;
+ }
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
if (EFI_ERROR (Status)) {
@@ -912,6 +907,14 @@ Returns: --*/
{
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 (gReportStatusCode == NULL) {
|