]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: implement MmServicesTableLib based on traditional SMM
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 3 Jan 2019 18:28:21 +0000 (19:28 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 14 Jan 2019 08:20:36 +0000 (09:20 +0100)
The definitions of the rebranded MM protocol stack were chosen such
that the existing SMM based core drivers can be reused. So let's
implement MmServicesTableLib based on gEfiMmBaseProtocolGuid, which
is simply gEfiSmmBase2ProtocolGuid under the hood.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c [new file with mode: 0644]
MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf [new file with mode: 0644]
MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni [new file with mode: 0644]
MdePkg/MdePkg.dsc

diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
new file mode 100644 (file)
index 0000000..f3af1cc
--- /dev/null
@@ -0,0 +1,63 @@
+/** @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
diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
new file mode 100644 (file)
index 0000000..4418cc2
--- /dev/null
@@ -0,0 +1,45 @@
+## @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
diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni
new file mode 100644 (file)
index 0000000..8a96793
--- /dev/null
@@ -0,0 +1,23 @@
+// /** @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
index d43ffe4deb4917502ce4efca66e3f8805c10bd80..428b14e6a4e04dabf2fb5813c0ed7b420d3d26fb 100644 (file)
   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