From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: APXvYqzj5+vYrUgHYiqkVygU6D+XUrg25cXXJcNg7Z8w9ZULtav5vYziYF41hwa7915X1rZ0vWIu9A== 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 Cc: Ard Biesheuvel , Jian J Wang , Hao Wu , Star Zeng , Michael D Kinney , Liming Gao , Achin Gupta , Jiewen Yao , Supreeth Venkatesh , Jagadeesh Ujja 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: [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: , X-List-Received-Date: Mon, 11 Mar 2019 15:37:18 -0000 Content-Transfer-Encoding: 8bit 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(+) 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 -- 2.20.1