From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=jagadeesh.ujja@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 937FD21195BF6 for ; Tue, 27 Nov 2018 03:26:48 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6EE3435E0; Tue, 27 Nov 2018 03:26:48 -0800 (PST) Received: from usa.arm.com (a75556-lin.blr.arm.com [10.162.2.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6180C3F575; Tue, 27 Nov 2018 03:26:46 -0800 (PST) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, liming.gao@intel.com, chao.b.zhang@intel.com, lersek@readhat.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 27 Nov 2018 16:56:18 +0530 Message-Id: <20181127112626.7854-4-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181127112626.7854-1-jagadeesh.ujja@arm.com> References: <20181127112626.7854-1-jagadeesh.ujja@arm.com> MIME-Version: 1.0 Subject: [RFC PATCH v2 03/11] MdeModulePkg/Library: Add StandaloneMmRuntimeDxe library 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: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 X-List-Received-Date: Tue, 27 Nov 2018 11:26:48 -0000 Content-Transfer-Encoding: 8bit To resuse some the libraries in both MM and non-MM mode, a mechanism to determine the execution mode is required, i.e, in MM or non-MM. Add a new library for use by non-MM code to determine the current execution mode. Change-Id: If0ec88f4691b2b059c770faefed59b2dc29312da Signed-off-by: Jagadeesh Ujja Signed-off-by: Thomas Abraham --- .../Include/Library/StandaloneMmRuntimeDxe.h | 39 +++++++++++++++++ .../StandaloneMmRuntimeDxe.c | 36 ++++++++++++++++ .../StandaloneMmRuntimeDxe.inf | 43 +++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h create mode 100644 MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c create mode 100644 MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf diff --git a/MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h b/MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h new file mode 100644 index 0000000000..e4a61f6a7b --- /dev/null +++ b/MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h @@ -0,0 +1,39 @@ +/** @file + Provides a service to retrieve a pointer to the Standalone MM Services Table. + Only available to Standalone MM module types. + +Copyright (c) 2018, ARM 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. + +**/ + +#ifndef __STANDALONEMM_RUNTIME_DXE_LIB_H__ +#define __STANDALONEMM_RUNTIME_DXE_LIB_H__ + +#include + +/** + This function allows the caller to determine if the driver is executing in + Standalone Management Mode(SMM). + + This function returns TRUE if the driver is executing in SMM and FALSE if the + driver is not executing in SMM. + + @retval TRUE The driver is executing in Standalone Management Mode (SMM). + @retval FALSE The driver is not executing in Standalone Management Mode (SMM). + +**/ +BOOLEAN +EFIAPI +InMm ( + VOID + ); + +#endif diff --git a/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c new file mode 100644 index 0000000000..61ef59a19a --- /dev/null +++ b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c @@ -0,0 +1,36 @@ +/** @file + StandaloneMmRuntimeDxe Library. + + Copyright (c) 2018, ARM 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 + +/** + This function allows the caller to determine if the driver is executing in + Standalone Management Mode(SMM). + + This function returns TRUE if the driver is executing in SMM and FALSE if the + driver is not executing in SMM. + + @retval TRUE The driver is executing in Standalone Management Mode (SMM). + @retval FALSE The driver is not executing in Standalone Management Mode (SMM). + +**/ +BOOLEAN +EFIAPI +InMm ( + VOID + ) +{ + return FALSE; +} diff --git a/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf new file mode 100644 index 0000000000..5948fd2708 --- /dev/null +++ b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf @@ -0,0 +1,43 @@ +## @file +# Provides StandaloneMmRuntimeDxe. +# +# Copyright (c) 2018, ARM 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 = 0x00010005 + BASE_NAME = StandaloneMmRuntimeDxe + FILE_GUID = 8099cfbf-9564-4c9b-9052-e66b1da88930 + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = StandaloneMmRuntimeDxe |DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 AARCH64 +# + +[Sources] + StandaloneMmRuntimeDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + -- 2.19.1