summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorKun Qin <kun.q@outlook.com>2021-01-25 23:10:21 -0800
committerKun Qin <kun.q@outlook.com>2021-02-01 10:03:14 -0800
commit1f0fa9187b6ed3e20b7d72b9e53dfc6a75496627 (patch)
tree21dd04af91d42bd4475a7dfd0e32e859c803978c /MdeModulePkg
parentb1e97194a053a222c9689d0891740455fa40bb39 (diff)
downloadedk2-1f0fa9187b6ed3e20b7d72b9e53dfc6a75496627.tar.gz
edk2-1f0fa9187b6ed3e20b7d72b9e53dfc6a75496627.tar.bz2
edk2-1f0fa9187b6ed3e20b7d72b9e53dfc6a75496627.zip
MdeModulePkg: SmmSmiHandlerProfileLib: Support StandaloneMm Instance
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3185 This change added support of SMI handler profile library router under StandaloneMm. This change replaces gSmst with gMmst. It also 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: Eric Dong <eric.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Kun Qin <kun.q@outlook.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c102
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h23
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c90
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf4
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c31
-rw-r--r--MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf44
-rw-r--r--MdeModulePkg/MdeModulePkg.dsc1
7 files changed, 211 insertions, 84 deletions
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c
new file mode 100644
index 0000000000..f800220b54
--- /dev/null
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c
@@ -0,0 +1,102 @@
+/** @file
+ MM driver instance of SmiHandlerProfile Library.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiMm.h>
+#include <Library/SmiHandlerProfileLib.h>
+#include <Library/MmServicesTableLib.h>
+#include <Guid/SmiHandlerProfile.h>
+
+SMI_HANDLER_PROFILE_PROTOCOL *mSmiHandlerProfile;
+
+/**
+ This function is called by SmmChildDispatcher module to report
+ a new SMI handler is registered, to SmmCore.
+
+ @param HandlerGuid The GUID to identify the type of the handler.
+ For the SmmChildDispatch protocol, the HandlerGuid
+ must be the GUID of SmmChildDispatch protocol.
+ @param Handler The SMI handler.
+ @param CallerAddress The address of the module who registers the SMI handler.
+ @param Context The context of the SMI handler.
+ For the SmmChildDispatch protocol, the Context
+ must match the one defined for SmmChildDispatch protocol.
+ @param ContextSize The size of the context in bytes.
+ For the SmmChildDispatch protocol, the Context
+ must match the one defined for SmmChildDispatch protocol.
+
+ @retval EFI_SUCCESS The information is recorded.
+ @retval EFI_UNSUPPORTED The feature is unsupported.
+ @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.
+**/
+EFI_STATUS
+EFIAPI
+SmiHandlerProfileRegisterHandler (
+ IN EFI_GUID *HandlerGuid,
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN VOID *Context, OPTIONAL
+ IN UINTN ContextSize OPTIONAL
+ )
+{
+ if (mSmiHandlerProfile != NULL) {
+ return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);
+ }
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ This function is called by SmmChildDispatcher module to report
+ an existing SMI handler is unregistered, to SmmCore.
+
+ @param HandlerGuid The GUID to identify the type of the handler.
+ For the SmmChildDispatch protocol, the HandlerGuid
+ must be the GUID of SmmChildDispatch protocol.
+ @param Handler The SMI handler.
+ @param Context The context of the SMI handler.
+ If it is NOT NULL, it will be used to check what is registered.
+ @param ContextSize The size of the context in bytes.
+ If Context is NOT NULL, it will be used to check what is registered.
+
+ @retval EFI_SUCCESS The original record is removed.
+ @retval EFI_UNSUPPORTED The feature is unsupported.
+ @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.
+**/
+EFI_STATUS
+EFIAPI
+SmiHandlerProfileUnregisterHandler (
+ IN EFI_GUID *HandlerGuid,
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
+ IN VOID *Context, OPTIONAL
+ IN UINTN ContextSize OPTIONAL
+ )
+{
+ if (mSmiHandlerProfile != NULL) {
+ return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);
+ }
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ The common constructor function for SMI handler profile.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+**/
+EFI_STATUS
+MmSmiHandlerProfileLibInitialization (
+ VOID
+ )
+{
+ gMmst->MmLocateProtocol (
+ &gSmiHandlerProfileGuid,
+ NULL,
+ (VOID **) &mSmiHandlerProfile
+ );
+ return EFI_SUCCESS;
+}
+
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h
new file mode 100644
index 0000000000..8e390590ee
--- /dev/null
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h
@@ -0,0 +1,23 @@
+/** @file
+ MM driver instance of SmiHandlerProfile Library.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MM_SMI_HANDLER_PROFILE_LIB_H_
+#define _MM_SMI_HANDLER_PROFILE_LIB_H_
+
+/**
+ The common constructor function for SMI handler profile.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+**/
+EFI_STATUS
+MmSmiHandlerProfileLibInitialization (
+ VOID
+ );
+
+#endif //_SMM_SMI_HANDLER_PROFILE_LIB_H_
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
index b76e8f0dc1..0167d81b88 100644
--- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
@@ -2,87 +2,17 @@
SMM driver instance of SmiHandlerProfile Library.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#include <PiSmm.h>
-#include <Library/SmiHandlerProfileLib.h>
-#include <Library/SmmServicesTableLib.h>
-#include <Guid/SmiHandlerProfile.h>
+#include <PiMm.h>
-SMI_HANDLER_PROFILE_PROTOCOL *mSmiHandlerProfile;
+#include "MmSmiHandlerProfileLib.h"
/**
- This function is called by SmmChildDispatcher module to report
- a new SMI handler is registered, to SmmCore.
-
- @param HandlerGuid The GUID to identify the type of the handler.
- For the SmmChildDispatch protocol, the HandlerGuid
- must be the GUID of SmmChildDispatch protocol.
- @param Handler The SMI handler.
- @param CallerAddress The address of the module who registers the SMI handler.
- @param Context The context of the SMI handler.
- For the SmmChildDispatch protocol, the Context
- must match the one defined for SmmChildDispatch protocol.
- @param ContextSize The size of the context in bytes.
- For the SmmChildDispatch protocol, the Context
- must match the one defined for SmmChildDispatch protocol.
-
- @retval EFI_SUCCESS The information is recorded.
- @retval EFI_UNSUPPORTED The feature is unsupported.
- @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.
-**/
-EFI_STATUS
-EFIAPI
-SmiHandlerProfileRegisterHandler (
- IN EFI_GUID *HandlerGuid,
- IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
- IN PHYSICAL_ADDRESS CallerAddress,
- IN VOID *Context, OPTIONAL
- IN UINTN ContextSize OPTIONAL
- )
-{
- if (mSmiHandlerProfile != NULL) {
- return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);
- }
- return EFI_UNSUPPORTED;
-}
-
-/**
- This function is called by SmmChildDispatcher module to report
- an existing SMI handler is unregistered, to SmmCore.
-
- @param HandlerGuid The GUID to identify the type of the handler.
- For the SmmChildDispatch protocol, the HandlerGuid
- must be the GUID of SmmChildDispatch protocol.
- @param Handler The SMI handler.
- @param Context The context of the SMI handler.
- If it is NOT NULL, it will be used to check what is registered.
- @param ContextSize The size of the context in bytes.
- If Context is NOT NULL, it will be used to check what is registered.
-
- @retval EFI_SUCCESS The original record is removed.
- @retval EFI_UNSUPPORTED The feature is unsupported.
- @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.
-**/
-EFI_STATUS
-EFIAPI
-SmiHandlerProfileUnregisterHandler (
- IN EFI_GUID *HandlerGuid,
- IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
- IN VOID *Context, OPTIONAL
- IN UINTN ContextSize OPTIONAL
- )
-{
- if (mSmiHandlerProfile != NULL) {
- return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);
- }
- return EFI_UNSUPPORTED;
-}
-
-/**
- The constructor function for SMI handler profile.
+ The constructor function for traditional MM SMI handler profile.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@@ -92,15 +22,9 @@ SmiHandlerProfileUnregisterHandler (
EFI_STATUS
EFIAPI
SmmSmiHandlerProfileLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- gSmst->SmmLocateProtocol (
- &gSmiHandlerProfileGuid,
- NULL,
- (VOID **) &mSmiHandlerProfile
- );
- return EFI_SUCCESS;
+ return MmSmiHandlerProfileLibInitialization ();
}
-
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf
index 1d738c7087..56007d5021 100644
--- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf
@@ -27,6 +27,8 @@
#
[Sources]
+ MmSmiHandlerProfileLib.c
+ MmSmiHandlerProfileLib.h
SmmSmiHandlerProfileLib.c
[Packages]
@@ -34,7 +36,7 @@
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
- SmmServicesTableLib
+ MmServicesTableLib
[Guids]
gSmiHandlerProfileGuid ## CONSUMES ## GUID # Locate protocol
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c
new file mode 100644
index 0000000000..a7714390e5
--- /dev/null
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c
@@ -0,0 +1,31 @@
+/** @file
+ Standalone MM driver instance of SmiHandlerProfile Library.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiMm.h>
+
+#include "MmSmiHandlerProfileLib.h"
+
+/**
+ The constructor function for standalone MM SMI handler profile.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+**/
+EFI_STATUS
+EFIAPI
+StandaloneMmSmiHandlerProfileLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *SystemTable
+ )
+{
+ return MmSmiHandlerProfileLibInitialization ();
+}
+
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf
new file mode 100644
index 0000000000..a885cc2b2a
--- /dev/null
+++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf
@@ -0,0 +1,44 @@
+## @file
+# Standalone MM driver instance of SmiHandlerProfile Library.
+#
+# This library instance provides real functionality for SmmChildDispatcher module.
+#
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) Microsoft Corporation.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = StandaloneMmSmiHandlerProfileLib
+ FILE_GUID = 1F2ED27B-A01D-4867-B993-9B710E5926C5
+ MODULE_TYPE = MM_STANDALONE
+ VERSION_STRING = 1.0
+ PI_SPECIFICATION_VERSION = 0x10000032
+ LIBRARY_CLASS = SmiHandlerProfileLib|MM_STANDALONE
+ CONSTRUCTOR = StandaloneMmSmiHandlerProfileLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ MmSmiHandlerProfileLib.c
+ MmSmiHandlerProfileLib.h
+ StandaloneMmSmiHandlerProfileLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ MmServicesTableLib
+
+[Guids]
+ gSmiHandlerProfileGuid ## CONSUMES ## GUID # Locate protocol
+
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index f95c7cd69e..7ca4a1bb30 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -492,6 +492,7 @@
MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf
MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf
+ MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf
MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf