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 3C97521196217 for ; Wed, 28 Nov 2018 01:35:25 -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 132A51B55; Wed, 28 Nov 2018 01:35:25 -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 0D4063F5A0; Wed, 28 Nov 2018 01:35:22 -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:00 +0530 Message-Id: <1543397709-31847-3-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 02/11] StandaloneMmPkg: Pull in additonal libraries from staging branch 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:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 X-List-Received-Date: Wed, 28 Nov 2018 09:35:25 -0000 Three additional library packages are being pulled into StandaloneMmPkg from the staging area in order to support the secure variable service. The three packages being pulled in are - StandaloneMmHobLib - StandaloneMmMemoryAllocationLib - StandaloneMmServicesTableLib Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja --- StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf | 2 +- StandaloneMmPkg/Library/{StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf => StandaloneMmHobLib/StandaloneMmHobLib.inf} | 11 +-- StandaloneMmPkg/Library/{StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf => StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf} | 14 ++- StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf | 36 ++++++++ MdePkg/Include/Library/SmmServicesTableLib.h => StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h | 90 ++++++++++---------- StandaloneMmPkg/Library/{StandaloneMmCoreHobLib => StandaloneMmHobLib}/AArch64/StandaloneMmCoreHobLibInternal.c | 4 +- StandaloneMmPkg/Library/{StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c => StandaloneMmHobLib/StandaloneMmHobLib.c} | 55 +++++++++++- MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c => StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c | 69 ++++++++------- MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.c => StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c | 34 ++++---- 9 files changed, 203 insertions(+), 112 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf index db19d3c926e8..ac036e31cf5e 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf @@ -24,7 +24,7 @@ [Defines] MODULE_TYPE = MM_CORE_STANDALONE VERSION_STRING = 1.0 PI_SPECIFICATION_VERSION = 0x00010032 - LIBRARY_CLASS = HobLib|MM_CORE_STANDALONE MM_STANDALONE + LIBRARY_CLASS = HobLib|MM_CORE_STANDALONE # # VALID_ARCHITECTURES = AARCH64 diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf similarity index 79% copy from StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf copy to StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf index db19d3c926e8..d73188ec1b57 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf @@ -20,17 +20,17 @@ [Defines] INF_VERSION = 0x0001001A BASE_NAME = HobLib - FILE_GUID = CF56EF2C-68D8-4BD5-9A8B-8A7BFCFF751C - MODULE_TYPE = MM_CORE_STANDALONE + FILE_GUID = 8262551B-AB2D-4E76-99FC-5EBB83F4988E + MODULE_TYPE = MM_STANDALONE VERSION_STRING = 1.0 PI_SPECIFICATION_VERSION = 0x00010032 - LIBRARY_CLASS = HobLib|MM_CORE_STANDALONE MM_STANDALONE - + LIBRARY_CLASS = HobLib|MM_STANDALONE + CONSTRUCTOR = HobLibConstructor # # VALID_ARCHITECTURES = AARCH64 # [Sources.Common] - StandaloneMmCoreHobLib.c + StandaloneMmHobLib.c [Sources.AARCH64] AArch64/StandaloneMmCoreHobLibInternal.c @@ -42,6 +42,7 @@ [Packages] [LibraryClasses] BaseMemoryLib DebugLib + MmServicesTableLib [Guids] gEfiHobListGuid ## CONSUMES ## SystemTable diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf similarity index 76% copy from StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf copy to StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf index 3958655cb4cf..9ac03df4caad 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf @@ -19,22 +19,20 @@ [Defines] INF_VERSION = 0x0001001A BASE_NAME = MemoryAllocationLib - FILE_GUID = DCDCBE1D-E760-4E1D-85B4-96E3F0439C41 + FILE_GUID = 54646378-A9DC-473F-9BE1-BD027C4C76DE MODULE_TYPE = MM_CORE_STANDALONE VERSION_STRING = 1.0 PI_SPECIFICATION_VERSION = 0x00010032 - LIBRARY_CLASS = MemoryAllocationLib|MM_CORE_STANDALONE - CONSTRUCTOR = MemoryAllocationLibConstructor + LIBRARY_CLASS = MemoryAllocationLib|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] - StandaloneMmCoreMemoryAllocationLib.c - StandaloneMmCoreMemoryAllocationServices.h + StandaloneMmMemoryAllocationLib.c [Packages] MdePkg/MdePkg.dec @@ -43,7 +41,5 @@ [Packages] [LibraryClasses] BaseMemoryLib DebugLib + MmServicesTableLib HobLib - -[Guids] - gEfiMmPeiMmramMemoryReserveGuid diff --git a/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf b/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf new file mode 100644 index 000000000000..c36242914229 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf @@ -0,0 +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. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = StandaloneMmServicesTableLib + FILE_GUID = BEE33A2F-F49D-4B71-AF3E-FFCCB9885DEA + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + LIBRARY_CLASS = MmServicesTableLib|MM_STANDALONE + CONSTRUCTOR = StandaloneMmServicesTableLibConstructor + +# +# VALID_ARCHITECTURES = IA32 X64 AARCH64 +# + +[Sources] + StandaloneMmServicesTableLib.c + +[Packages] + MdePkg/MdePkg.dec + diff --git a/MdePkg/Include/Library/SmmServicesTableLib.h b/StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h similarity index 55% copy from MdePkg/Include/Library/SmmServicesTableLib.h copy to StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h index 01e999d234e7..e7a670d3636d 100644 --- a/MdePkg/Include/Library/SmmServicesTableLib.h +++ b/StandaloneMmPkg/Include/Library/StandaloneMmServicesTableLib.h @@ -1,43 +1,47 @@ -/** @file - Provides a service to retrieve a pointer to the SMM Services Table. - Only available to SMM module types. - -Copyright (c) 2009 - 2018, Intel Corporation. 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 __SMM_SERVICES_TABLE_LIB_H__ -#define __SMM_SERVICES_TABLE_LIB_H__ - -#include - -/// -/// Cache pointer to the SMM Services Table -/// -extern EFI_SMM_SYSTEM_TABLE2 *gSmst; - -/** - This function allows the caller to determine if the driver is executing in - System 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 System Management Mode (SMM). - @retval FALSE The driver is not executing in System Management Mode (SMM). - -**/ -BOOLEAN -EFIAPI -InSmm ( - 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) 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 diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c similarity index 90% copy from StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c copy to StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c index 90e1cd479cb2..ac5a1c039f6a 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/StandaloneMmCoreHobLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c @@ -42,11 +42,11 @@ HobConstructor ( HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1); Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF; - Hob->Header.HobLength = sizeof (EFI_HOB_HANDOFF_INFO_TABLE); + Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE); Hob->Header.Reserved = 0; HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST; - HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER); + HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER); HobEnd->Reserved = 0; Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION; diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c similarity index 88% copy from StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c copy to StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c index e2fcda813d1b..591a78c7f3b6 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c @@ -27,6 +27,43 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // VOID *gHobList = NULL; +EFI_MM_SYSTEM_TABLE *gMmst = NULL; + +/** + The constructor function caches the pointer to HOB list. + + The constructor function gets the start address of HOB list from system configuration table. + It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor successfully gets HobList. + @retval Other value The constructor can't get HobList. + +**/ +EFI_STATUS +EFIAPI +HobLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SmmSystemTable + ) +{ + UINTN Index; + + for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) { + gHobList = gMmst->MmConfigurationTable[Index].VendorTable; + break; + } + } + + /* HACK: Use the ImageHandle to smuggle the hoblist into the library constructor */ + if (ImageHandle) + gHobList = (VOID *) ImageHandle; + + return EFI_SUCCESS; +} /** Returns the pointer to the HOB list. @@ -42,6 +79,16 @@ GetHobList ( VOID ) { + UINTN Index; + + if (gHobList == NULL) { + for (Index = 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gEfiHobListGuid, &gMmst->MmConfigurationTable[Index].VendorGuid)) { + gHobList = gMmst->MmConfigurationTable[Index].VendorTable; + break; + } + } + } ASSERT (gHobList != NULL); return gHobList; } @@ -206,7 +253,7 @@ GetBootModeHob ( HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList (); - return HandOffHob->BootMode; + return HandOffHob->BootMode; } VOID * @@ -227,7 +274,7 @@ CreateHob ( FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; if (FreeMemory < HobLength) { - return NULL; + return NULL; } Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList; @@ -239,7 +286,7 @@ CreateHob ( HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST; - HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER); + HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER); HobEnd->Reserved = 0; HobEnd++; HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; @@ -314,7 +361,7 @@ BuildResourceDescriptorHob ( EFI_HOB_RESOURCE_DESCRIPTOR *Hob; Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); - ASSERT (Hob != NULL); + ASSERT(Hob != NULL); Hob->ResourceType = ResourceType; Hob->ResourceAttribute = ResourceAttribute; diff --git a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c similarity index 89% copy from MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c copy to StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c index dce13bbdf5e6..e989f277c159 100644 --- a/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c @@ -1,27 +1,28 @@ /** @file - Support routines for memory allocation routines based - on boot services for Dxe phase drivers. + Support routines for memory allocation routines based on Standalone MM Core internal functions. + + Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
- Copyright (c) 2006 - 2018, Intel Corporation. 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. + 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 #include #include +extern EFI_MM_SYSTEM_TABLE *gMmst; + /** Allocates one or more 4KB pages of a certain memory type. @@ -48,7 +49,7 @@ InternalAllocatePages ( return NULL; } - Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); if (EFI_ERROR (Status)) { return NULL; } @@ -74,7 +75,7 @@ AllocatePages ( IN UINTN Pages ) { - return InternalAllocatePages (EfiBootServicesData, Pages); + return InternalAllocatePages (EfiRuntimeServicesData, Pages); } /** @@ -118,7 +119,7 @@ AllocateReservedPages ( IN UINTN Pages ) { - return InternalAllocatePages (EfiReservedMemoryType, Pages); + return NULL; } /** @@ -134,7 +135,7 @@ AllocateReservedPages ( then ASSERT(). If Pages is zero, then ASSERT(). - @param Buffer The pointer to the buffer of pages to free. + @param Buffer Pointer to the buffer of pages to free. @param Pages The number of 4 KB pages to free. **/ @@ -148,7 +149,7 @@ FreePages ( EFI_STATUS Status; ASSERT (Pages != 0); - Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); ASSERT_EFI_ERROR (Status); } @@ -203,7 +204,7 @@ InternalAllocateAlignedPages ( // ASSERT (RealPages > Pages); - Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory); + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory); if (EFI_ERROR (Status)) { return NULL; } @@ -213,23 +214,23 @@ InternalAllocateAlignedPages ( // // Free first unaligned page(s). // - Status = gBS->FreePages (Memory, UnalignedPages); + Status = gMmst->MmFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } - Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages); + Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages)); UnalignedPages = RealPages - Pages - UnalignedPages; if (UnalignedPages > 0) { // // Free last unaligned page(s). // - Status = gBS->FreePages (Memory, UnalignedPages); + Status = gMmst->MmFreePages (Memory, UnalignedPages); ASSERT_EFI_ERROR (Status); } } else { // // Do not over-allocate pages in this case. // - Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); + Status = gMmst->MmAllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); if (EFI_ERROR (Status)) { return NULL; } @@ -263,7 +264,7 @@ AllocateAlignedPages ( IN UINTN Alignment ) { - return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment); + return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); } /** @@ -319,7 +320,7 @@ AllocateAlignedReservedPages ( IN UINTN Alignment ) { - return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment); + return NULL; } /** @@ -335,7 +336,7 @@ AllocateAlignedReservedPages ( Library, then ASSERT(). If Pages is zero, then ASSERT(). - @param Buffer The pointer to the buffer of pages to free. + @param Buffer Pointer to the buffer of pages to free. @param Pages The number of 4 KB pages to free. **/ @@ -349,7 +350,7 @@ FreeAlignedPages ( EFI_STATUS Status; ASSERT (Pages != 0); - Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); + Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages); ASSERT_EFI_ERROR (Status); } @@ -375,7 +376,9 @@ InternalAllocatePool ( EFI_STATUS Status; VOID *Memory; - Status = gBS->AllocatePool (MemoryType, AllocationSize, &Memory); + Memory = NULL; + + Status = gMmst->MmAllocatePool (MemoryType, AllocationSize, &Memory); if (EFI_ERROR (Status)) { Memory = NULL; } @@ -400,7 +403,7 @@ AllocatePool ( IN UINTN AllocationSize ) { - return InternalAllocatePool (EfiBootServicesData, AllocationSize); + return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize); } /** @@ -442,7 +445,7 @@ AllocateReservedPool ( IN UINTN AllocationSize ) { - return InternalAllocatePool (EfiReservedMemoryType, AllocationSize); + return NULL; } /** @@ -493,7 +496,7 @@ AllocateZeroPool ( IN UINTN AllocationSize ) { - return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize); + return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize); } /** @@ -537,7 +540,7 @@ AllocateReservedZeroPool ( IN UINTN AllocationSize ) { - return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); + return NULL; } /** @@ -600,7 +603,7 @@ AllocateCopyPool ( IN CONST VOID *Buffer ) { - return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer); + return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); } /** @@ -654,7 +657,7 @@ AllocateReservedCopyPool ( IN CONST VOID *Buffer ) { - return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer); + return NULL; } /** @@ -726,7 +729,7 @@ ReallocatePool ( IN VOID *OldBuffer OPTIONAL ) { - return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer); + return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer); } /** @@ -790,7 +793,7 @@ ReallocateReservedPool ( IN VOID *OldBuffer OPTIONAL ) { - return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer); + return NULL; } /** @@ -804,7 +807,7 @@ ReallocateReservedPool ( If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). - @param Buffer The pointer to the buffer to free. + @param Buffer Pointer to the buffer to free. **/ VOID @@ -815,7 +818,7 @@ FreePool ( { EFI_STATUS Status; - Status = gBS->FreePool (Buffer); + Status = gMmst->MmFreePool (Buffer); ASSERT_EFI_ERROR (Status); } diff --git a/MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.c b/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c similarity index 56% copy from MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.c copy to StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c index c1ea2944338d..e0e004406287 100644 --- a/MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c @@ -1,7 +1,9 @@ /** @file - SMM Core SMM Services Table Library. + MM Core MM Services Table Library. + + Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
- Copyright (c) 2010 - 2018, Intel Corporation. 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 @@ -12,15 +14,13 @@ **/ -#include -#include +#include #include -EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL; -extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst; +extern EFI_MM_SYSTEM_TABLE *gMmst; /** - The constructor function caches the pointer of SMM Services Table. + 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. @@ -30,31 +30,35 @@ extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst; **/ EFI_STATUS EFIAPI -SmmCoreSmmServicesTableLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +StandaloneMmServicesTableLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { - gSmst = &gSmmCoreSmst; + gMmst = MmSystemTable; return EFI_SUCCESS; } /** This function allows the caller to determine if the driver is executing in - System Management Mode(SMM). + 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 System Management Mode (SMM). - @retval FALSE The driver is not executing in System Management Mode (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 -InSmm ( +InMm ( VOID ) { + // + // We are already in Standalone MM + // return TRUE; } + -- 2.7.4