MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router

This change added support of RSC router under StandaloneMm. It replaces
SMM version ReportStatusCode protocol definitions with MM version. This
patch also switched to use gMmst instead of gSmst. Lastly, it abstracts
standalone and traditional MM driver entrypoints into separate files to
allow maximal common implementations.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>

Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Kun Qin 2020-12-17 14:28:57 -08:00
parent 06201d580b
commit b1e97194a0
7 changed files with 179 additions and 55 deletions

View File

@ -479,6 +479,7 @@
MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf
MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf
MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf
MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterStandaloneMm.inf
MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryAllocationProfileLib.inf
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf

View File

@ -7,7 +7,7 @@
**/
#include "ReportStatusCodeRouterSmm.h"
#include "ReportStatusCodeRouterCommon.h"
LIST_ENTRY mCallbackListHead = INITIALIZE_LIST_HEAD_VARIABLE (mCallbackListHead);
@ -17,11 +17,11 @@ LIST_ENTRY mCallbackListHead = INITIALIZE_LIST_HEAD_VARIABLE (mCallba
//
UINT32 mStatusCodeNestStatus = 0;
EFI_SMM_STATUS_CODE_PROTOCOL mSmmStatusCodeProtocol = {
EFI_MM_STATUS_CODE_PROTOCOL mSmmStatusCodeProtocol = {
ReportDispatcher
};
EFI_SMM_RSC_HANDLER_PROTOCOL mSmmRscHandlerProtocol = {
EFI_MM_RSC_HANDLER_PROTOCOL mSmmRscHandlerProtocol = {
Register,
Unregister
};
@ -45,18 +45,18 @@ EFI_SMM_RSC_HANDLER_PROTOCOL mSmmRscHandlerProtocol = {
EFI_STATUS
EFIAPI
Register (
IN EFI_SMM_RSC_HANDLER_CALLBACK Callback
IN EFI_MM_RSC_HANDLER_CALLBACK Callback
)
{
LIST_ENTRY *Link;
SMM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
MM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
if (Callback == NULL) {
return EFI_INVALID_PARAMETER;
}
for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {
CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
CallbackEntry = CR (Link, MM_RSC_HANDLER_CALLBACK_ENTRY, Node, MM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
if (CallbackEntry->RscHandlerCallback == Callback) {
//
// If the function was already registered. It can't be registered again.
@ -65,10 +65,10 @@ Register (
}
}
CallbackEntry = (SMM_RSC_HANDLER_CALLBACK_ENTRY *)AllocatePool (sizeof (SMM_RSC_HANDLER_CALLBACK_ENTRY));
CallbackEntry = (MM_RSC_HANDLER_CALLBACK_ENTRY *)AllocatePool (sizeof (MM_RSC_HANDLER_CALLBACK_ENTRY));
ASSERT (CallbackEntry != NULL);
CallbackEntry->Signature = SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE;
CallbackEntry->Signature = MM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE;
CallbackEntry->RscHandlerCallback = Callback;
InsertTailList (&mCallbackListHead, &CallbackEntry->Node);
@ -92,18 +92,18 @@ Register (
EFI_STATUS
EFIAPI
Unregister (
IN EFI_SMM_RSC_HANDLER_CALLBACK Callback
IN EFI_MM_RSC_HANDLER_CALLBACK Callback
)
{
LIST_ENTRY *Link;
SMM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
MM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
if (Callback == NULL) {
return EFI_INVALID_PARAMETER;
}
for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {
CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
CallbackEntry = CR (Link, MM_RSC_HANDLER_CALLBACK_ENTRY, Node, MM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
if (CallbackEntry->RscHandlerCallback == Callback) {
//
// If the function is found in list, delete it and return.
@ -121,8 +121,8 @@ Unregister (
/**
Provides an interface that a software module can call to report a status code.
@param This EFI_SMM_STATUS_CODE_PROTOCOL instance.
@param Type Indicates the type of status code being reported.
@param This EFI_MM_STATUS_CODE_PROTOCOL instance.
@param CodeType Indicates the type of status code being reported.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to
classify the entity as well as an operation.
@ -140,16 +140,16 @@ Unregister (
EFI_STATUS
EFIAPI
ReportDispatcher (
IN CONST EFI_SMM_STATUS_CODE_PROTOCOL *This,
IN EFI_STATUS_CODE_TYPE Type,
IN CONST EFI_MM_STATUS_CODE_PROTOCOL *This,
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN CONST EFI_GUID *CallerId OPTIONAL,
IN CONST EFI_GUID *CallerId,
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
LIST_ENTRY *Link;
SMM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
MM_RSC_HANDLER_CALLBACK_ENTRY *CallbackEntry;
//
// Use atom operation to avoid the reentant of report.
@ -160,13 +160,13 @@ ReportDispatcher (
}
for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link);) {
CallbackEntry = CR (Link, SMM_RSC_HANDLER_CALLBACK_ENTRY, Node, SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
CallbackEntry = CR (Link, MM_RSC_HANDLER_CALLBACK_ENTRY, Node, MM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
//
// The handler may remove itself, so get the next handler in advance.
//
Link = GetNextNode (&mCallbackListHead, Link);
CallbackEntry->RscHandlerCallback (
Type,
CodeType,
Value,
Instance,
(EFI_GUID*)CallerId,
@ -186,20 +186,15 @@ ReportDispatcher (
/**
Entry point of Generic Status Code Driver.
This function is the entry point of SMM Status Code Router .
It produces SMM Report Stataus Code Handler and Status Code protocol.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
This function is the common entry point of MM Status Code Router.
It produces MM Report Status Code Handler and Status Code protocol.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
GenericStatusCodeSmmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
GenericStatusCodeCommonEntry (
VOID
)
{
EFI_STATUS Status;
@ -210,9 +205,9 @@ GenericStatusCodeSmmEntry (
//
// Install SmmRscHandler Protocol
//
Status = gSmst->SmmInstallProtocolInterface (
Status = gMmst->MmInstallProtocolInterface (
&Handle,
&gEfiSmmRscHandlerProtocolGuid,
&gEfiMmRscHandlerProtocolGuid,
EFI_NATIVE_INTERFACE,
&mSmmRscHandlerProtocol
);
@ -221,9 +216,9 @@ GenericStatusCodeSmmEntry (
//
// Install SmmStatusCode Protocol
//
Status = gSmst->SmmInstallProtocolInterface (
Status = gMmst->MmInstallProtocolInterface (
&Handle,
&gEfiSmmStatusCodeProtocolGuid,
&gEfiMmStatusCodeProtocolGuid,
EFI_NATIVE_INTERFACE,
&mSmmStatusCodeProtocol
);

View File

@ -6,28 +6,26 @@
**/
#ifndef __REPORT_STATUS_CODE_ROUTER_SMM_H__
#define __REPORT_STATUS_CODE_ROUTER_SMM_H__
#ifndef __REPORT_STATUS_CODE_ROUTER_COMMON_H__
#define __REPORT_STATUS_CODE_ROUTER_COMMON_H__
#include <Protocol/SmmReportStatusCodeHandler.h>
#include <Protocol/SmmStatusCode.h>
#include <Protocol/MmReportStatusCodeHandler.h>
#include <Protocol/MmStatusCode.h>
#include <Library/BaseLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/MmServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#define SMM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE SIGNATURE_32 ('s', 'h', 'c', 'e')
#define MM_RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE SIGNATURE_32 ('s', 'h', 'c', 'e')
typedef struct {
UINTN Signature;
EFI_SMM_RSC_HANDLER_CALLBACK RscHandlerCallback;
EFI_MM_RSC_HANDLER_CALLBACK RscHandlerCallback;
LIST_ENTRY Node;
} SMM_RSC_HANDLER_CALLBACK_ENTRY;
} MM_RSC_HANDLER_CALLBACK_ENTRY;
/**
Register the callback function for ReportStatusCode() notification.
@ -48,7 +46,7 @@ typedef struct {
EFI_STATUS
EFIAPI
Register (
IN EFI_SMM_RSC_HANDLER_CALLBACK Callback
IN EFI_MM_RSC_HANDLER_CALLBACK Callback
);
/**
@ -67,14 +65,14 @@ Register (
EFI_STATUS
EFIAPI
Unregister (
IN EFI_SMM_RSC_HANDLER_CALLBACK Callback
IN EFI_MM_RSC_HANDLER_CALLBACK Callback
);
/**
Provides an interface that a software module can call to report a status code.
@param This EFI_SMM_STATUS_CODE_PROTOCOL instance.
@param Type Indicates the type of status code being reported.
@param This EFI_MM_STATUS_CODE_PROTOCOL instance.
@param CodeType Indicates the type of status code being reported.
@param Value Describes the current status of a hardware or software entity.
This included information about the class and subclass that is used to
classify the entity as well as an operation.
@ -92,12 +90,26 @@ Unregister (
EFI_STATUS
EFIAPI
ReportDispatcher (
IN CONST EFI_SMM_STATUS_CODE_PROTOCOL *This,
IN EFI_STATUS_CODE_TYPE Type,
IN CONST EFI_MM_STATUS_CODE_PROTOCOL *This,
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN CONST EFI_GUID *CallerId OPTIONAL,
IN CONST EFI_GUID *CallerId,
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
);
/**
Entry point of Generic Status Code Driver.
This function is the common entry point of MM Status Code Router.
It produces MM Report Status Code Handler and Status Code protocol.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
GenericStatusCodeCommonEntry (
VOID
);
#endif

View File

@ -16,7 +16,7 @@
MODULE_TYPE = DXE_SMM_DRIVER
PI_SPECIFICATION_VERSION = 0x0001000A
VERSION_STRING = 1.0
ENTRY_POINT = GenericStatusCodeSmmEntry
ENTRY_POINT = GenericStatusCodeTraditionalEntry
#
# The following information is for reference only and not required by the build tools.
@ -25,15 +25,16 @@
#
[Sources]
ReportStatusCodeRouterSmm.c
ReportStatusCodeRouterSmm.h
ReportStatusCodeRouterCommon.c
ReportStatusCodeRouterCommon.h
ReportStatusCodeRouterTraditional.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
SmmServicesTableLib
MmServicesTableLib
UefiDriverEntryPoint
DebugLib
BaseLib
@ -41,8 +42,8 @@
MemoryAllocationLib
[Protocols]
gEfiSmmRscHandlerProtocolGuid ## PRODUCES
gEfiSmmStatusCodeProtocolGuid ## PRODUCES
gEfiMmRscHandlerProtocolGuid ## PRODUCES
gEfiMmStatusCodeProtocolGuid ## PRODUCES
[Depex]
TRUE

View File

@ -0,0 +1,33 @@
/** @file
Report Status Code Router Driver which produces MM Report Stataus Code Handler Protocol
and MM Status Code Protocol.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "ReportStatusCodeRouterCommon.h"
/**
Entry point of Generic Status Code Driver.
This function is the entry point of MM Status Code Router .
It produces MM Report Stataus Code Handler and Status Code protocol.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
GenericStatusCodeStandaloneMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_MM_SYSTEM_TABLE *SystemTable
)
{
return GenericStatusCodeCommonEntry ();
}

View File

@ -0,0 +1,49 @@
## @file
# Report Status Code Router Driver which produces MM Report Stataus Code Handler Protocol and MM Status Code Protocol.
#
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ReportStatusCodeRouterStandaloneMm
FILE_GUID = EAEEDEF9-ABE7-4B95-82B0-5A534C899B46
MODULE_TYPE = MM_STANDALONE
PI_SPECIFICATION_VERSION = 0x00010032
VERSION_STRING = 1.0
ENTRY_POINT = GenericStatusCodeStandaloneMmEntry
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
ReportStatusCodeRouterCommon.c
ReportStatusCodeRouterCommon.h
ReportStatusCodeRouterStandaloneMm.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
MmServicesTableLib
StandaloneMmDriverEntryPoint
DebugLib
BaseLib
SynchronizationLib
MemoryAllocationLib
[Protocols]
gEfiMmRscHandlerProtocolGuid ## PRODUCES
gEfiMmStatusCodeProtocolGuid ## PRODUCES
[Depex]
TRUE

View File

@ -0,0 +1,33 @@
/** @file
Report Status Code Router Driver which produces MM Report Stataus Code Handler Protocol
and MM Status Code Protocol.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "ReportStatusCodeRouterCommon.h"
/**
Entry point of Generic Status Code Driver.
This function is the entry point of SMM Status Code Router .
It produces SMM Report Stataus Code Handler and Status Code protocol.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
GenericStatusCodeTraditionalEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return GenericStatusCodeCommonEntry ();
}