From patchwork Mon Mar 11 15:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 160043 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12060471jad; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1SYa+lOyH4muWBVG89o1Pr6BEWljb6aeFy+HvhZbD1nGDiMsb92r58DpsPv9WpLwNF0ON X-Received: by 2002:a63:1c02:: with SMTP id c2mr30861729pgc.351.1552318639860; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318639; cv=none; d=google.com; s=arc-20160816; b=xFrqwdQm2aghYvHxbKPK5AnvdPh9kKpH7scEluAiHN3tTY2KvHV96sPsOJG0GWi30k EYYKkneYFmhLBiob4MDe5FPTHKzY56tMnVIJTv8Vpy5IVl1Ok1E5KMN0XmkgZuXOBeND sHGDy5jC7eyaKIezenoB65I/lrOx4MfwTzEqHK07l/gDipvaEHVZ2gvWHMOhe2uzhsBv U4yT4Tlm2uCRnaNwngrMRHBkVovxf9A1YLF3QBw9h8A+AIiIsYW8umqaTBiMoOnZuE/Q Y9ul9ixWYYuFzKc8CCQtih9sGktoPlMoL8NlC3FN4lS8OYqz7iorJe/0TYXfznpUbKo6 6UTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=58L/H12Ghz/bjoL7mxrAkNqFyMSxr9vHIUSQCy7n4hc=; b=y7HjvdRRkmKFEU68lSGGyFWc+myc4nhjbbfn7hjytk1TphSK5eUAJp5G1xKeaS0qNi ZRaMcR2+he7HQ+RUSozA8t4JzIKcYmhbSrF9ECjMSoS8fmDUhbl9ysIk9NtmZWOHGbgh 0KayF/PyiS9NswYxpm3HAYm+X5HCK7lp9qmq44swCTpfPAF83xkTbeFH5VNKRUTkK5zV u0BPQcnnqXXJdUgZuybHjZAJHS8weHPZ5uFMFlJp79x5bSu6CFX3TSZlcPZ0x+SHV+F8 zsvG5Z5oD3+4hki9m7ZhW26TfEsqSc3y+ml87VehW9F2FevNfpIWsZMixgUO+O/5eUzI +lQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=rKpn4SBP; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id q188si5859796pfc.159.2019.03.11.08.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:37:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=rKpn4SBP; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3B174211DB417; Mon, 11 Mar 2019 08:37:19 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.128.67; helo=mail-wm1-f67.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9A4DC211D07B2 for ; Mon, 11 Mar 2019 08:37:17 -0700 (PDT) Received: by mail-wm1-f67.google.com with SMTP id a188so4715536wmf.3 for ; Mon, 11 Mar 2019 08:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y1ktGFqEb5Ow2e7B6qjBnx7JE3Qj89ugIXwznhY5gF0=; b=rKpn4SBPOCE0qMzUOLzjIvuXfC+9nU+bdJzpaqhJGY5416VIitr/Z9veoqbFbi8vAP wHy6ZeBiG5+F22mbp1aGAOSD2Gn/CNtB2HOuFcLUftK10KkjS2ikz1PqMhXP909BfFof 8ds1/ai92+mPqEUKh8E8Eb7zNcEIijZieQ5b/badHgdzl+rsP84KgRk7sTpatgsyUMFx ADM11RIa+TqLbJYZyU6A1BySiL7UPRjsCDs+xBdrs2srxF89ALeDLnjfgAzqnr2X9Xn+ RiSFE3BIUIl1To0afLZ9gLpcQD2QMjIsLfkBwO3CT7bhw4GBcnqeYLTB/jxLGTce6Bq3 8amg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1ktGFqEb5Ow2e7B6qjBnx7JE3Qj89ugIXwznhY5gF0=; b=ZIYmQAAJjIk/xixSCvaK+1XiWgKSSCQKPQX0rKum4/GkFSAYm+vH+JrzdSS5VPNQnm HDYSz8LgPvtS2MWtv6ug/gh/tfGxrNgjGHaoorqWEjdD0/V7n/e9btAdDv1wBwz//Pbj GtbuXqB+RQcv/WM2UJG8UiEZhYABZxw914+elRwmql5sIr0RNGUinzFQQvTFKQfBkHoz j0T30fI5DZjvsKcow2TrHof3VlWGLEtNn0ilGexcKvJMsB5utSWQX+4IJiWPp/0Ihs+N ERr91OqzqKtOIiOX9Z9OvjRkBjiGY0VKwb/52a1LKWZoGW6xgxhenA0Vipgjcev+IvC9 hOtw== X-Gm-Message-State: APjAAAUQ0zxrJMsJ2uPfkRnwUNV2m4Sx6biNh8Sz0GUsHnugpcj2I1uK nLQwbfSRdFfnqlhWLe6VqfHObu0M47U= X-Received: by 2002:a1c:b709:: with SMTP id h9mr224999wmf.114.1552318575816; Mon, 11 Mar 2019 08:36:15 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id u13sm34938965wmf.3.2019.03.11.08.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 08:36:14 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 11 Mar 2019 16:36:05 +0100 Message-Id: <20190311153608.3251-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311153608.3251-1-ard.biesheuvel@linaro.org> References: <20190311153608.3251-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 1/4] MdeModulePkg: introduce MmCommunicationLib library class X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Liming Gao , Jiewen Yao , Michael D Kinney , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- MdeModulePkg/MdeModulePkg.dec | 4 ++ MdeModulePkg/Include/Library/MmCommunicateLib.h | 50 ++++++++++++++++++++ 2 files changed, 54 insertions(+) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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.
+ + 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