summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-26 01:54:49 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-26 01:54:49 +0000
commit3e99020dbf0a159e34b84e7ae9125f2e368d5390 (patch)
tree0eb6339318f7bf7da1b679b8009cf267b2234566 /EdkCompatibilityPkg/Foundation/Library/RuntimeDxe
parent68bb5ce77e51cf35791e46f2202e36da97e5e6be (diff)
downloadedk2-platforms-3e99020dbf0a159e34b84e7ae9125f2e368d5390.tar.xz
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Foundation/Library/RuntimeDxe')
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c176
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c176
3 files changed, 312 insertions, 70 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
index 9807b45035..29cdeb967a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -21,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = NULL;
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_PROTOCOL *StatusCode;
+
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
+ if (!EFI_ERROR (Status)) {
+ gReportStatusCode = StatusCode->ReportStatusCode;
+ }
+}
+
+EFI_STATUS
+GetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ //
+ // Get Hob list
+ //
+ Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+ if (END_OF_HOB_LIST (GuidHob)) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+
+ if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
#endif
EFI_STATUS
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ 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);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ 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);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode == NULL) {
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gReportStatusCode == NULL) {
+ //
+ // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
+ // running here indicates that the StatusCode driver has not started yet.
+ //
if (EfiAtRuntime ()) {
+ //
+ // Running here only when StatusCode driver never starts.
+ //
return EFI_UNSUPPORTED;
}
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status) || gStatusCode == NULL) {
+
+ //
+ // Try to get the PEI version of ReportStatusCode.
+ //
+ Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
- Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
index c94ee431ef..ac169a1166 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -599,13 +599,6 @@ Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
@@ -617,11 +610,6 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
@@ -640,15 +628,6 @@ Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
Arguments:
FvDevicePathNode - Pointer to FV device path to check
@@ -660,16 +639,11 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
return &FvDevicePathNode->NameGuid;
}
- return NULL;
+ return NULL;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
index 8771e2bcd3..11b36e056d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -21,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = NULL;
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_PROTOCOL *StatusCode;
+
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
+ if (!EFI_ERROR (Status)) {
+ gReportStatusCode = StatusCode->ReportStatusCode;
+ }
+}
+
+EFI_STATUS
+GetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ //
+ // Get Hob list
+ //
+ Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+ if (END_OF_HOB_LIST (GuidHob)) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+
+ if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
#endif
EFI_STATUS
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ 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);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ 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);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode == NULL) {
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gReportStatusCode == NULL) {
+ //
+ // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
+ // running here indicates that the StatusCode driver has not started yet.
+ //
if (EfiAtRuntime ()) {
+ //
+ // Running here only when StatusCode driver never starts.
+ //
return EFI_UNSUPPORTED;
}
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status) || gStatusCode == NULL) {
+
+ //
+ // Try to get the PEI version of ReportStatusCode.
+ //
+ Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
- Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;