]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StandaloneMmPkg/Library: Install Variable Arch Protocol
authorJagadeesh Ujja <jagadeesh.ujja@arm.com>
Mon, 4 Mar 2019 08:53:59 +0000 (14:23 +0530)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 11 Mar 2019 11:39:06 +0000 (12:39 +0100)
In a system implementing the variable store in MM, there are no variable
arch protocol and variable write arch protocol installed into the
DXE_SMM protocol database. On such systems, it is not required to
locate these protocols by the DXE runtime variable drivers because
it can be assumed that these protocols are already installed in the
MM context. But then such an implementation will deviate from the
existing traditional MM based variable driver implementation.

So in order to maintain consistency with the traditional MM variable
driver implementation, allow platforms to install these protocols into
the DXE protocol database but these protocol will not be consumed
by non-secure variable service runtime driver.

The Platform which uses StandaloneMM based secure variable storage
have to include this library

Example
In edk2-platforms/Platform/ARM/SgiPkg/SgiPlatform.dsc

  ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf {
    <LibraryClasses>
      NULL|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf
  }

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
Acked-by "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.c [new file with mode: 0644]
StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf [new file with mode: 0644]

diff --git a/StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.c b/StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.c
new file mode 100644 (file)
index 0000000..f0a46b2
--- /dev/null
@@ -0,0 +1,53 @@
+/** @file\r
+  Runtime DXE part corresponding to StanaloneMM variable module.\r
+\r
+This module installs variable arch protocol and variable write arch protocol\r
+to StandaloneMM runtime variable service.\r
+\r
+Copyright (c) 2019, ARM Ltd. All rights reserved.\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
+\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 <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+/**\r
+  The constructor function installs variable arch protocol and variable\r
+  write arch protocol to StandaloneMM runtime variable service\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the Management mode System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+VariableMmDependencyLibConstructor (\r
+  IN EFI_HANDLE                           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_HANDLE            Handle;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiSmmVariableProtocolGuid,\r
+                  NULL,\r
+                  &gSmmVariableWriteGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf b/StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf
new file mode 100644 (file)
index 0000000..e71c44d
--- /dev/null
@@ -0,0 +1,46 @@
+## @file\r
+#  Runtime DXE part corresponding to StanaloneMM variable module.\r
+#\r
+#  This module installs variable arch protocol and variable write arch protocol\r
+#  to StandaloneMM runtime variable service.\r
+#\r
+# Copyright (c) 2019, ARM Ltd. All rights reserved.\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
+[Defines]\r
+  INF_VERSION                    = 0x0001001A\r
+  BASE_NAME                      = VariableMmDependency\r
+  FILE_GUID                      = 64BC4129-778E-4867-BA07-13999A4DEC3F\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  LIBRARY_CLASS                  = NULL\r
+  CONSTRUCTOR                    = VariableMmDependencyLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = AARCH64\r
+#\r
+#\r
+\r
+[Sources]\r
+  VariableMmDependency.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[Protocols]\r
+  gEfiSmmVariableProtocolGuid        ## PRODUCES\r
+\r
+[Guids]\r
+  gSmmVariableWriteGuid              ## PRODUCES             ## GUID # Install protocol\r
+\r
+[Depex]\r
+  TRUE\r