From patchwork Mon Jan 14 13:27:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 155496 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3659002jaa; Mon, 14 Jan 2019 05:28:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN4qJMM9c7F26qyfBMWBh1CU4eMTL4x2w5JzIQa4Ago0Gp2uveG0W3JbQku7ZdFvEWFrlcy4 X-Received: by 2002:a62:22d4:: with SMTP id p81mr13280906pfj.16.1547472535935; Mon, 14 Jan 2019 05:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547472535; cv=none; d=google.com; s=arc-20160816; b=Bd+KmCtQE0NdnpDKGX7CZjyCJ3VUkt82K7+KJNZAmlTaWlFHxTlmlKKWTijmiVcay6 FBLTaIXYBK3fCBlMBi6xi5xM2TUh/kBh5NK5gqqRt/qu4sTapoJt5n84CHC+uLE7j6iq PKRofWEpepuKqHukifD+nW14phaVXPQUCdylc1zJygc/GOSvlxgRFPAprctt+b/u0IhB ontuP1WVmnsGNmY3tmVrmf5+LIFIyFKi1AtR5hbpiD8WYaIfrX9eCGDseH5hLtpee4aN ljbmyxgPL4AAOh6JId6z+l0Uvyx9f5VT9kQ+OGzFCBbMVgGAKxkhInsogAF9wYWHQG0f YgGA== 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=sLSH4hexiOm6Py2S5wSGPUvzrOamimSRAbv3CExrTkg=; b=0CEbqyY3+TDZwu8uBez7coCEluoLrOChYU2b7fuTtr/ve1XsJ7mSgL7lnd0N+RinNq 9kCZTfgVFCbEEs2H2qknZRevDQ0yWtOQxOqTOhYl8e3ymdLzV0WwMB83brYnlvRd+mO0 Zqk6OuGnChxTUW0r82yyxiZ/OKQWszmSitkG6rjaVua+wFHOPuoJZbgtKqsVDbzw+hRk TxqD9X+PFN0k28C7cqyC+eiBtoYAMCWXLdt2aZ5pSUWJrukhG/3b/vekSDl85jAi/87o PasogD+jZvVntnTGM5PVZ7mNVBxdYvkuqjU4fGai8jXxOciVwzSRXQOcc5uyQbBL3g8x CuhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HugEvXHW; 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 i9si384887plb.35.2019.01.14.05.28.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 05:28:55 -0800 (PST) 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=HugEvXHW; 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 EF92D211B739D; Mon, 14 Jan 2019 05:28:30 -0800 (PST) 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=2a00:1450:4864:20::32f; helo=mail-wm1-x32f.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 E1C6D211B76D5 for ; Mon, 14 Jan 2019 05:28:28 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id t200so8898567wmt.0 for ; Mon, 14 Jan 2019 05:28:28 -0800 (PST) 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=xXn1B0QGJcfAlWVOf0u5mL+nZysqhKR0xCQC+m4PYOs=; b=HugEvXHWK1PscuuuDj+GvFYrhHWn+ZIIhk75zD3/UzitpwQ1hCYSex0CSg0PZtSXR7 Jsg1PUrjrA6NqIV5n1abCFpj9BolqX35IU7XLcaGEsoORmkHgh0c58p18EsQbtgaZqSD //HZacebgHnHY4+LnPjngRvAEuJPB/iQqto/I= 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=xXn1B0QGJcfAlWVOf0u5mL+nZysqhKR0xCQC+m4PYOs=; b=gDv5/t6dj1nnphuk/qRaMHWc5McPfX0SV0E5q7/iy0u6YzyWTts9xcqF2TDOJr7Qod OtHaWa1U0qq2WXM6PMe9NCSVxWGOpdkAfZmR5rKSN7zeLETeMO4niSMB4pQW9ofqyZCk Ig7AVdLtQMjVyytq66eC5tU73Iu8BZK80bS4AjQpfvVtwQOMzfHBGyEuzGm0g/jX5SAO B2RppG1Q1Pw5eF33gB1o0f0wHLJvt9YsTDhILaNGgc12f1lw2hxQRCO2lxaLrf4uAhlz tDx0QYux+pCx+aFGy8HqG8sZmjiDynRDFwQ2xRErKCbhto9wfsXTlpp3MPv84bHdAjb2 Jrxg== X-Gm-Message-State: AJcUukdBQYRF+tMkL/nQJdM+frp7XttEaXO65Gx1XFcU6Q9GDnQBjp4m VMDQDv9QKm7EO7LNiAnZHIUQZ2t+fm8= X-Received: by 2002:a1c:e044:: with SMTP id x65mr3544173wmg.86.1547472506963; Mon, 14 Jan 2019 05:28:26 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-19-62.w90-86.abo.wanadoo.fr. [90.86.222.62]) by smtp.gmail.com with ESMTPSA id 202sm33446560wmt.8.2019.01.14.05.28.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 05:28:26 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 14 Jan 2019 14:27:51 +0100 Message-Id: <20190114132758.24054-11-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114132758.24054-1-ard.biesheuvel@linaro.org> References: <20190114132758.24054-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 10/17] MdePkg: introduce standalone MM entry point library implementation 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 , Michael D Kinney , Laszlo Ersek , Star Zeng Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Add an implementation of the StandaloneMmDriverEntryPoint library class. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdePkg/MdePkg.dsc | 2 + MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf | 43 ++++++++++ MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c | 90 ++++++++++++++++++++ MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni | 22 +++++ 4 files changed, 157 insertions(+) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 428b14e6a4e0..ec561c53cab0 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -115,6 +115,8 @@ [Components] MdePkg/Library/SmmLibNull/SmmLibNull.inf MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf + MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf + [Components.IA32, Components.X64] MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf new file mode 100644 index 000000000000..c9309de1c755 --- /dev/null +++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf @@ -0,0 +1,43 @@ +## @file +# Module entry point library for Standalone MM driver. +# +# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2016-2018, ARM Ltd. All rights reserved.
+# Copyright (c) 2018, Linaro, Limited. 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. +# +# +## + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = StandaloneMmDriverEntryPoint + MODULE_UNI_FILE = StandaloneMmDriverEntryPoint.uni + FILE_GUID = 5ca126c0-b598-4f4b-abb9-b6e7d077aea9 + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + LIBRARY_CLASS = StandaloneMmDriverEntryPoint|MM_STANDALONE + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 AARCH64 +# + +[Sources] + StandaloneMmDriverEntryPoint.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + MmServicesTableLib diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c new file mode 100644 index 000000000000..111bb1f18a2a --- /dev/null +++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c @@ -0,0 +1,90 @@ +/** @file + Entry point to a Standalone MM driver. + +Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, ARM Ltd. All rights reserved.
+Copyright (c) 2018, Linaro, Limited. 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. + +**/ + +#include + +#include +#include +#include +#include + +/** + The entry point of PE/COFF Image for a Standalone MM Driver. + + This function is the entry point for a Standalone MM Driver. + This function must call ProcessLibraryConstructorList() and + ProcessModuleEntryPointList(). + If the return status from ProcessModuleEntryPointList() + is an error status, then ProcessLibraryDestructorList() must be called. + The return value from ProcessModuleEntryPointList() is returned. + If _gDriverUnloadImageCount is greater + than zero, then an unload handler must be registered for this image and + the unload handler must invoke ProcessModuleUnloadList(). + If _gMmRevision is not zero and SystemTable->Hdr.Revision is + less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION. + + @param ImageHandle The image handle of the Standalone MM Driver. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The Standalone MM Driver exited normally. + @retval EFI_INCOMPATIBLE_VERSION _gMmRevision is greater than + SystemTable->Hdr.Revision. + @retval Other Return value from + ProcessModuleEntryPointList(). + +**/ +EFI_STATUS +EFIAPI +_ModuleEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + EFI_STATUS Status; + + if (_gMmRevision != 0) { + // + // Make sure that the MM spec revision of the platform + // is >= MM spec revision of the driver + // + if (MmSystemTable->Hdr.Revision < _gMmRevision) { + return EFI_INCOMPATIBLE_VERSION; + } + } + + // + // Call constructor for all libraries + // + ProcessLibraryConstructorList (ImageHandle, MmSystemTable); + + // + // Call the driver entry point + // + Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable); + + // + // If all of the drivers returned errors, then invoke all of the library destructors + // + if (EFI_ERROR (Status)) { + ProcessLibraryDestructorList (ImageHandle, MmSystemTable); + } + + // + // Return the cumulative return status code from all of the driver entry points + // + return Status; +} diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni new file mode 100644 index 000000000000..11765d7fb4a6 --- /dev/null +++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni @@ -0,0 +1,22 @@ +// /** @file +// +// Module entry point library for standalone MM driver +// +// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+// Copyright (c) 2018, Linaro, Limited. 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. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Module entry point library for standalone MM driver" + +#string STR_MODULE_DESCRIPTION #language en-US "Module entry point library for standalone MM driver." +