]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: SmmSmiHandlerProfileLib: Support StandaloneMm Instance
authorKun Qin <kun.q@outlook.com>
Tue, 26 Jan 2021 07:10:21 +0000 (23:10 -0800)
committerKun Qin <kun.q@outlook.com>
Mon, 1 Feb 2021 18:03:14 +0000 (10:03 -0800)
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>
MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c [new file with mode: 0644]
MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h [new file with mode: 0644]
MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c
MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf
MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c [new file with mode: 0644]
MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dsc

diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c
new file mode 100644 (file)
index 0000000..f800220
--- /dev/null
@@ -0,0 +1,102 @@
+/** @file\r
+  MM driver instance of SmiHandlerProfile Library.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiMm.h>\r
+#include <Library/SmiHandlerProfileLib.h>\r
+#include <Library/MmServicesTableLib.h>\r
+#include <Guid/SmiHandlerProfile.h>\r
+\r
+SMI_HANDLER_PROFILE_PROTOCOL  *mSmiHandlerProfile;\r
+\r
+/**\r
+  This function is called by SmmChildDispatcher module to report\r
+  a new SMI handler is registered, to SmmCore.\r
+\r
+  @param HandlerGuid     The GUID to identify the type of the handler.\r
+                         For the SmmChildDispatch protocol, the HandlerGuid\r
+                         must be the GUID of SmmChildDispatch protocol.\r
+  @param Handler         The SMI handler.\r
+  @param CallerAddress   The address of the module who registers the SMI handler.\r
+  @param Context         The context of the SMI handler.\r
+                         For the SmmChildDispatch protocol, the Context\r
+                         must match the one defined for SmmChildDispatch protocol.\r
+  @param ContextSize     The size of the context in bytes.\r
+                         For the SmmChildDispatch protocol, the Context\r
+                         must match the one defined for SmmChildDispatch protocol.\r
+\r
+  @retval EFI_SUCCESS           The information is recorded.\r
+  @retval EFI_UNSUPPORTED       The feature is unsupported.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no enough resource to record the information.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileRegisterHandler (\r
+  IN EFI_GUID                       *HandlerGuid,\r
+  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
+  IN PHYSICAL_ADDRESS               CallerAddress,\r
+  IN VOID                           *Context, OPTIONAL\r
+  IN UINTN                          ContextSize OPTIONAL\r
+  )\r
+{\r
+  if (mSmiHandlerProfile != NULL) {\r
+    return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);\r
+  }\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This function is called by SmmChildDispatcher module to report\r
+  an existing SMI handler is unregistered, to SmmCore.\r
+\r
+  @param HandlerGuid     The GUID to identify the type of the handler.\r
+                         For the SmmChildDispatch protocol, the HandlerGuid\r
+                         must be the GUID of SmmChildDispatch protocol.\r
+  @param Handler         The SMI handler.\r
+  @param Context         The context of the SMI handler.\r
+                         If it is NOT NULL, it will be used to check what is registered.\r
+  @param ContextSize     The size of the context in bytes.\r
+                         If Context is NOT NULL, it will be used to check what is registered.\r
+\r
+  @retval EFI_SUCCESS           The original record is removed.\r
+  @retval EFI_UNSUPPORTED       The feature is unsupported.\r
+  @retval EFI_NOT_FOUND         There is no record for the HandlerGuid and handler.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileUnregisterHandler (\r
+  IN EFI_GUID                       *HandlerGuid,\r
+  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
+  IN VOID                           *Context, OPTIONAL\r
+  IN UINTN                          ContextSize OPTIONAL\r
+  )\r
+{\r
+  if (mSmiHandlerProfile != NULL) {\r
+    return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);\r
+  }\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  The common constructor function for SMI handler profile.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+**/\r
+EFI_STATUS\r
+MmSmiHandlerProfileLibInitialization (\r
+  VOID\r
+  )\r
+{\r
+  gMmst->MmLocateProtocol (\r
+           &gSmiHandlerProfileGuid,\r
+           NULL,\r
+           (VOID **) &mSmiHandlerProfile\r
+           );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.h
new file mode 100644 (file)
index 0000000..8e39059
--- /dev/null
@@ -0,0 +1,23 @@
+/** @file\r
+  MM driver instance of SmiHandlerProfile Library.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef _MM_SMI_HANDLER_PROFILE_LIB_H_\r
+#define _MM_SMI_HANDLER_PROFILE_LIB_H_\r
+\r
+/**\r
+  The common constructor function for SMI handler profile.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+**/\r
+EFI_STATUS\r
+MmSmiHandlerProfileLibInitialization (\r
+  VOID\r
+  );\r
+\r
+#endif //_SMM_SMI_HANDLER_PROFILE_LIB_H_\r
index b76e8f0dc1320f80d600542f7225a0731dc9f121..0167d81b880d30f3a545e36e11de6a46c61d8180 100644 (file)
@@ -2,87 +2,17 @@
   SMM driver instance of SmiHandlerProfile Library.\r
 \r
   Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
-#include <Library/SmiHandlerProfileLib.h>\r
-#include <Library/SmmServicesTableLib.h>\r
-#include <Guid/SmiHandlerProfile.h>\r
+#include <PiMm.h>\r
 \r
-SMI_HANDLER_PROFILE_PROTOCOL  *mSmiHandlerProfile;\r
+#include "MmSmiHandlerProfileLib.h"\r
 \r
 /**\r
-  This function is called by SmmChildDispatcher module to report\r
-  a new SMI handler is registered, to SmmCore.\r
-\r
-  @param HandlerGuid     The GUID to identify the type of the handler.\r
-                         For the SmmChildDispatch protocol, the HandlerGuid\r
-                         must be the GUID of SmmChildDispatch protocol.\r
-  @param Handler         The SMI handler.\r
-  @param CallerAddress   The address of the module who registers the SMI handler.\r
-  @param Context         The context of the SMI handler.\r
-                         For the SmmChildDispatch protocol, the Context\r
-                         must match the one defined for SmmChildDispatch protocol.\r
-  @param ContextSize     The size of the context in bytes.\r
-                         For the SmmChildDispatch protocol, the Context\r
-                         must match the one defined for SmmChildDispatch protocol.\r
-\r
-  @retval EFI_SUCCESS           The information is recorded.\r
-  @retval EFI_UNSUPPORTED       The feature is unsupported.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no enough resource to record the information.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SmiHandlerProfileRegisterHandler (\r
-  IN EFI_GUID                       *HandlerGuid,\r
-  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
-  IN PHYSICAL_ADDRESS               CallerAddress,\r
-  IN VOID                           *Context, OPTIONAL\r
-  IN UINTN                          ContextSize OPTIONAL\r
-  )\r
-{\r
-  if (mSmiHandlerProfile != NULL) {\r
-    return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);\r
-  }\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  This function is called by SmmChildDispatcher module to report\r
-  an existing SMI handler is unregistered, to SmmCore.\r
-\r
-  @param HandlerGuid     The GUID to identify the type of the handler.\r
-                         For the SmmChildDispatch protocol, the HandlerGuid\r
-                         must be the GUID of SmmChildDispatch protocol.\r
-  @param Handler         The SMI handler.\r
-  @param Context         The context of the SMI handler.\r
-                         If it is NOT NULL, it will be used to check what is registered.\r
-  @param ContextSize     The size of the context in bytes.\r
-                         If Context is NOT NULL, it will be used to check what is registered.\r
-\r
-  @retval EFI_SUCCESS           The original record is removed.\r
-  @retval EFI_UNSUPPORTED       The feature is unsupported.\r
-  @retval EFI_NOT_FOUND         There is no record for the HandlerGuid and handler.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SmiHandlerProfileUnregisterHandler (\r
-  IN EFI_GUID                       *HandlerGuid,\r
-  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
-  IN VOID                           *Context, OPTIONAL\r
-  IN UINTN                          ContextSize OPTIONAL\r
-  )\r
-{\r
-  if (mSmiHandlerProfile != NULL) {\r
-    return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);\r
-  }\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  The constructor function for SMI handler profile.\r
+  The constructor function for traditional MM SMI handler profile.\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
@@ -92,15 +22,9 @@ SmiHandlerProfileUnregisterHandler (
 EFI_STATUS\r
 EFIAPI\r
 SmmSmiHandlerProfileLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  gSmst->SmmLocateProtocol (\r
-           &gSmiHandlerProfileGuid,\r
-           NULL,\r
-           (VOID **) &mSmiHandlerProfile\r
-           );\r
-  return EFI_SUCCESS;\r
+  return MmSmiHandlerProfileLibInitialization ();\r
 }\r
-\r
index 1d738c7087c62bd04ea94e82105bbf679483f511..56007d502134fb526a7ee84a615d00c21b2efb3f 100644 (file)
@@ -27,6 +27,8 @@
 #\r
 \r
 [Sources]\r
+  MmSmiHandlerProfileLib.c\r
+  MmSmiHandlerProfileLib.h\r
   SmmSmiHandlerProfileLib.c\r
 \r
 [Packages]\r
@@ -34,7 +36,7 @@
   MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
-  SmmServicesTableLib\r
+  MmServicesTableLib\r
 \r
 [Guids]\r
   gSmiHandlerProfileGuid  ## CONSUMES   ## GUID # Locate protocol\r
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c
new file mode 100644 (file)
index 0000000..a771439
--- /dev/null
@@ -0,0 +1,31 @@
+/** @file\r
+  Standalone MM driver instance of SmiHandlerProfile Library.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiMm.h>\r
+\r
+#include "MmSmiHandlerProfileLib.h"\r
+\r
+/**\r
+  The constructor function for standalone MM SMI handler profile.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StandaloneMmSmiHandlerProfileLibConstructor (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_MM_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  return MmSmiHandlerProfileLibInitialization ();\r
+}\r
+\r
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf
new file mode 100644 (file)
index 0000000..a885cc2
--- /dev/null
@@ -0,0 +1,44 @@
+## @file\r
+# Standalone MM driver instance of SmiHandlerProfile Library.\r
+#\r
+# This library instance provides real functionality for SmmChildDispatcher module.\r
+#\r
+#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) Microsoft Corporation.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = StandaloneMmSmiHandlerProfileLib\r
+  FILE_GUID                      = 1F2ED27B-A01D-4867-B993-9B710E5926C5\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  VERSION_STRING                 = 1.0\r
+  PI_SPECIFICATION_VERSION       = 0x10000032\r
+  LIBRARY_CLASS                  = SmiHandlerProfileLib|MM_STANDALONE\r
+  CONSTRUCTOR                    = StandaloneMmSmiHandlerProfileLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  MmSmiHandlerProfileLib.c\r
+  MmSmiHandlerProfileLib.h\r
+  StandaloneMmSmiHandlerProfileLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MmServicesTableLib\r
+\r
+[Guids]\r
+  gSmiHandlerProfileGuid  ## CONSUMES   ## GUID # Locate protocol\r
+\r
index f95c7cd69ee1f593061c2339a168589d68e41c4c..7ca4a1bb30805ec9a63b131a65eb873cfb44fe5f 100644 (file)
   MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf\r
   MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf\r
   MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf\r
+  MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.inf\r
   MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib.inf\r
   MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf\r
   MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf\r