--- /dev/null
+/** @file\r
+ MM Services Table Library.\r
+\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiMm.h>\r
+#include <Protocol/MmBase.h>\r
+#include <Library/MmServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+EFI_MM_SYSTEM_TABLE *gMmst = NULL;\r
+\r
+/**\r
+ The constructor function caches the pointer of the MM Services Table.\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
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmServicesTableLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_MM_BASE_PROTOCOL *InternalMmBase;\r
+\r
+ InternalMmBase = NULL;\r
+ //\r
+ // Retrieve MM Base Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r
+ // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the\r
+ // MM driver explicity declares that dependency.\r
+ //\r
+ Status = SystemTable->BootServices->LocateProtocol (\r
+ &gEfiMmBaseProtocolGuid,\r
+ NULL,\r
+ (VOID **)&InternalMmBase\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ ASSERT (InternalMmBase != NULL);\r
+\r
+ //\r
+ // We are in MM, retrieve the pointer to MM System Table\r
+ //\r
+ InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);\r
+ ASSERT (gMmst != NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+## @file\r
+# MM Services Table Library.\r
+#\r
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php.\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x0001001B\r
+ BASE_NAME = MmServicesTableLib\r
+ MODULE_UNI_FILE = MmServicesTableLib.uni\r
+ FILE_GUID = 9508ECFD-66D1-4B4C-9415-F25F0FFF9E93\r
+ MODULE_TYPE = DXE_SMM_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = MmServicesTableLib|DXE_SMM_DRIVER\r
+ PI_SPECIFICATION_VERSION = 0x00010032\r
+ CONSTRUCTOR = MmServicesTableLibConstructor\r
+\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64\r
+#\r
+\r
+[Sources]\r
+ MmServicesTableLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
+\r
+[Protocols]\r
+ gEfiMmBaseProtocolGuid ## CONSUMES\r
+\r
+[Depex]\r
+ gEfiMmBaseProtocolGuid\r
--- /dev/null
+// /** @file\r
+//\r
+// MM Services Table Library.\r
+//\r
+// It implements MmServicesTableLib based on gEfiMmBaseProtocolGuid, which\r
+// is simply gEfiSmmBase2ProtocolGuid under the hood.\r
+//\r
+// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r
+//\r
+// This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution. The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php.\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// **/\r
+\r
+\r
+#string STR_MODULE_ABSTRACT #language en-US "MM Services Table Library"\r
+\r
+#string STR_MODULE_DESCRIPTION #language en-US "MM Services Table Library."\r
MdePkg/Library/BaseRngLib/BaseRngLib.inf\r
MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf\r
MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf\r
+ MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf\r
\r
[Components.EBC]\r
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r