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 (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 6F5BB21B02822 for ; Wed, 28 Nov 2018 01:35:27 -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 4B1671B55; Wed, 28 Nov 2018 01:35:27 -0800 (PST) Received: from usa.arm.com (a075555-lin.blr.arm.com [10.162.2.152]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 825073F5A0; Wed, 28 Nov 2018 01:35:25 -0800 (PST) From: Jagadeesh Ujja To: edk2-devel@lists.01.org, liming.gao@intel.com, chao.b.zhang@intel.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Date: Wed, 28 Nov 2018 15:05:01 +0530 Message-Id: <1543397709-31847-4-git-send-email-jagadeesh.ujja@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543397709-31847-1-git-send-email-jagadeesh.ujja@arm.com> References: <1543397709-31847-1-git-send-email-jagadeesh.ujja@arm.com> Subject: [RFC PATCH v3 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: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:27 -0000 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. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja --- MdeModulePkg/Library/{AuthVariableLibNull/AuthVariableLibNull.inf => StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf} | 19 ++-- StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h => MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h | 86 ++++++++--------- StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c => MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c | 100 +++++++------------- 3 files changed, 86 insertions(+), 119 deletions(-) diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf similarity index 61% copy from MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf copy to MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf index 900fef5d4989..5948fd27081c 100644 --- a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf +++ b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.inf @@ -1,7 +1,7 @@ ## @file -# Provides NULL authenticated variable services. +# Provides StandaloneMmRuntimeDxe. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2018, ARM Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions @@ -16,25 +16,28 @@ [Defines] INF_VERSION = 0x00010005 - BASE_NAME = AuthVariableLibNull - MODULE_UNI_FILE = AuthVariableLibNull.uni - FILE_GUID = 435CB0E4-7C9A-4BB7-9907-8FD4643E978A + BASE_NAME = StandaloneMmRuntimeDxe + FILE_GUID = 8099cfbf-9564-4c9b-9052-e66b1da88930 MODULE_TYPE = DXE_RUNTIME_DRIVER VERSION_STRING = 1.0 - LIBRARY_CLASS = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER + 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 +# VALID_ARCHITECTURES = IA32 X64 AARCH64 # [Sources] - AuthVariableLibNull.c + StandaloneMmRuntimeDxe.c [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec [LibraryClasses] + BaseLib + BaseMemoryLib DebugLib + MemoryAllocationLib + diff --git a/StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h b/MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h similarity index 73% copy from StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h copy to MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h index e7a670d3636d..e4a61f6a7b21 100644 --- a/StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h +++ b/MdeModulePkg/Include/Library/StandaloneMmRuntimeDxe.h @@ -1,47 +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) 2009 - 2018, Intel Corporation. All rights reserved.
-Copyright (c) 2016 - 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 __MM_SERVICES_TABLE_LIB_H__ -#define __MM_SERVICES_TABLE_LIB_H__ - -#include -#include - -/// -/// Cache pointer to the Standalone MM Services Table - -extern EFI_MM_SYSTEM_TABLE *gMmst; - - -/** - 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 +/** @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/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c similarity index 50% copy from StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c copy to MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c index e0e004406287..61ef59a19a4f 100644 --- a/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c +++ b/MdeModulePkg/Library/StandaloneMmRuntimeDxe/StandaloneMmRuntimeDxe.c @@ -1,64 +1,36 @@ -/** @file - MM Core MM Services Table Library. - - Copyright (c) 2015, Intel Corporation. All rights reserved.
- Copyright (c) 2016 - 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 -#include - -extern EFI_MM_SYSTEM_TABLE *gMmst; - -/** - The constructor function caches the pointer of MM Services Table. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -StandaloneMmServicesTableLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_MM_SYSTEM_TABLE *MmSystemTable - ) -{ - gMmst = MmSystemTable; - return EFI_SUCCESS; -} - -/** - 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 - ) -{ - // - // We are already in Standalone MM - // - return TRUE; -} - +/** @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; +} -- 2.7.4