From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: ALg8bN4LyyYeDAiFnFql7mEsTD/QQIdPYRExmpsbeUH+gXUhyRbrDjbQCJQaHIbOl9vk1p9GSdCLRA== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Michael D Kinney , Liming Gao , Jian J Wang , Hao Wu , Jagadeesh Ujja , Achin Gupta , Thomas Panakamattam Abraham , Sami Mujawar , Star Zeng 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: [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: , X-List-Received-Date: Mon, 14 Jan 2019 13:28:29 -0000 Content-Transfer-Encoding: 8bit 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(+) 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." + -- 2.20.1