public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Jian J Wang <jian.j.wang@intel.com>, Hao Wu <hao.a.wu@intel.com>,
	Star Zeng <star.zeng@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <liming.gao@intel.com>,
	Achin Gupta <achin.gupta@arm.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
	Jagadeesh Ujja <jagadeesh.ujja@arm.com>
Subject: [PATCH 1/4] MdeModulePkg: introduce MmCommunicationLib library class
Date: Mon, 11 Mar 2019 16:36:05 +0100	[thread overview]
Message-ID: <20190311153608.3251-2-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20190311153608.3251-1-ard.biesheuvel@linaro.org>

In order to abstract away the difference between traditional and
standalone MM implementations of the MM communicate protocol, which
have different requirements when it comes to the way the address of
the communication buffer is passed, introduce a library class that
can encapsulate calls to the MM communicate protocols, and which
takes both the physical and virtual adresses of the buffer. This
way, it is left up to the library implementation to decide which
address is passed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/MdeModulePkg.dec                   |  4 ++
 MdeModulePkg/Include/Library/MmCommunicateLib.h | 50 ++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index a2130bc43991..0778bf01edca 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -182,6 +182,10 @@ [LibraryClasses]
   #
   DisplayUpdateProgressLib|Include/Library/DisplayUpdateProgressLib.h
 
+  ## @libraryclass  Provides an abstraction for invoking the MM communicate protocol
+  #
+  MmCommunicateLib|Include/Library/MmCommunicateLib.h
+
 [Guids]
   ## MdeModule package token space guid
   # Include/Guid/MdeModulePkgTokenSpace.h
diff --git a/MdeModulePkg/Include/Library/MmCommunicateLib.h b/MdeModulePkg/Include/Library/MmCommunicateLib.h
new file mode 100644
index 000000000000..b302e47f6f8f
--- /dev/null
+++ b/MdeModulePkg/Include/Library/MmCommunicateLib.h
@@ -0,0 +1,50 @@
+/** @file
+  Abstraction library for calls to EFI_MM_COMMUNICATE_PROTOCOL::Communicate
+
+  Copyright (c) 2019, Linaro Ltd. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution. The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef MM_COMMUNICATE_LIB_H__
+#define MM_COMMUNICATE_LIB_H__
+
+/**
+  Invoke the MM communication protocol
+
+  @param[in] PhysicalCommBuffer  Physical address of the communication buffer.
+  @param[in] VirtualCommBuffer   Virtual address of the communication buffer.
+  @param[in] CommSize            The size of the data buffer being passed in.
+                                 On exit, the size of data being returned. Zero
+                                 if the handler does not wish to reply with any
+                                 data. This parameter is optional and may be
+                                 NULL.
+
+  @retval EFI_SUCCESS            The message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM
+                                 implementation. If this error is returned, the
+                                 MessageLength field in the CommBuffer header or
+                                 the integer pointed by CommSize, are updated to
+                                 reflect the maximum payload size the
+                                 implementation can accommodate.
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter(s) or CommSize
+                                 parameter, if not omitted, are in address range
+                                 that cannot be accessed by the MM environment.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCommunicate (
+  IN OUT VOID                              *PhysicalCommBuffer,
+  IN OUT VOID                              *VirtualCommBuffer,
+  IN OUT UINTN                             *CommSize OPTIONAL
+  );
+
+#endif
-- 
2.20.1



  reply	other threads:[~2019-03-11 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 15:36 [PATCH 0/4] MdeModulePkg, StandaloneMmPkg: work around VA vs PA ambiguity Ard Biesheuvel
2019-03-11 15:36 ` Ard Biesheuvel [this message]
2019-03-11 15:36 ` [PATCH 2/4] MdeModulePkg: add implementation of MmCommunicateLib Ard Biesheuvel
2019-03-11 15:36 ` [PATCH 3/4] StandaloneMmPkg: " Ard Biesheuvel
2019-03-11 15:36 ` [PATCH 4/4] MdeModulePkg/VariableSmmRuntimeDxe: switch to MmCommunicateLib library Ard Biesheuvel
2019-03-15  2:15 ` [PATCH 0/4] MdeModulePkg, StandaloneMmPkg: work around VA vs PA ambiguity Wu, Hao A
2019-03-15  8:12   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190311153608.3251-2-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox