From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web09.2242.1613075975125543034 for ; Thu, 11 Feb 2021 12:39:35 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=Gy40+R6E; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [131.107.174.202]) by linux.microsoft.com (Postfix) with ESMTPSA id D4DD520B6C40; Thu, 11 Feb 2021 12:39:34 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D4DD520B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613075974; bh=INkzyPKUOCs702q5hsjH0B6G92sYTY8YnLek2bQKa4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gy40+R6ELeEIcIBSEGgkbMFaW5DRRtnKUj/PNk140aGZnXiEXvJu6ZBpqxMEwcXmm 0P8rruEvOk5es60e1K+sFUzcQm2jqi06i1T+glOiAxbTqAVZKTYaRg9QUwcOo2VQex 9oYwgvpigWaWtRLzqyZrcmtDtnP8qeMK99t+ztHw= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-platforms][PATCH v2 3/3] MinPlatformPkg/SpiFvbService: Add Standalone MM support Date: Thu, 11 Feb 2021 12:38:55 -0800 Message-Id: <20210211203855.1656-4-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210211203855.1656-1-mikuback@linux.microsoft.com> References: <20210211203855.1656-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki Adds support for MM_STANDALONE. Retains the directory path to the SMM INF instance for backward compatibility with existing platforms. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki --- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common =3D> }/FvbInfo= .c | 0 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common =3D> }/SpiFvbS= erviceCommon.c | 0 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Smm/SpiFvbServiceSmm.= c =3D> SpiFvbServiceMm.c} | 35 ++++++----------- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandalon= eMm.c | 32 ++++++++++++++++ Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTradition= alMm.c | 32 ++++++++++++++++ Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common =3D> }/SpiFvbS= erviceCommon.h | 4 -- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h = | 22 +++++++++++ Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf = | 17 +++++---- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{SpiFvbServiceSmm.inf = =3D> SpiFvbServiceStandaloneMm.inf} | 40 ++++++++++---------- Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc = | 2 + 10 files changed, 130 insertions(+), 54 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/Fvb= Info.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/FvbInfo.c similarity index 100% rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/FvbI= nfo.c rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/FvbInfo.c diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/Spi= FvbServiceCommon.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Sp= iFvbServiceCommon.c similarity index 100% rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiF= vbServiceCommon.c rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbService= Common.c diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvb= ServiceSmm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbSe= rviceMm.c similarity index 89% rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvbS= erviceSmm.c rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbService= Mm.c index 251fcae30b90..016f19587c91 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvbService= Smm.c +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c @@ -1,14 +1,16 @@ /** @file - Common driver source for several Serial Flash devices + MM driver source for several Serial Flash devices which are compliant with the Intel(R) Serial Flash Interface Compatibi= lity Specification. =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "SpiFvbServiceCommon.h" -#include +#include +#include #include =20 /** @@ -74,7 +76,7 @@ InstallFvbProtocol ( // FvbHandle =3D NULL; =20 - Status =3D gSmst->SmmInstallProtocolInterface ( + Status =3D gMmst->MmInstallProtocolInterface ( &FvbHandle, &gEfiSmmFirmwareVolumeBlockProtocolGuid, EFI_NATIVE_INTERFACE, @@ -82,7 +84,7 @@ InstallFvbProtocol ( ); ASSERT_EFI_ERROR (Status); =20 - Status =3D gSmst->SmmInstallProtocolInterface ( + Status =3D gMmst->MmInstallProtocolInterface ( &FvbHandle, &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, @@ -92,22 +94,13 @@ InstallFvbProtocol ( } =20 /** - The function does the necessary initialization work for Firmware Volume Block Driver. =20 - @param[in] ImageHandle The firmware allocated handle for the UE= FI image. - @param[in] SystemTable A pointer to the EFI system table. - - @retval EFI_SUCCESS This funtion always return EFI_SUCCESS. - It will ASSERT on errors. - **/ -EFI_STATUS -EFIAPI +VOID FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + VOID ) { EFI_FVB_INSTANCE *FvbInstance; @@ -219,8 +212,7 @@ FvbInitialize ( mFvbModuleGlobal.FvbInstance =3D (EFI_FVB_INSTANCE *) AllocateRunti= meZeroPool (BufferSize); if (mFvbModuleGlobal.FvbInstance =3D=3D NULL) { ASSERT (FALSE); - Status =3D EFI_OUT_OF_RESOURCES; - goto ERROR; + return; } =20 MaxLbaSize =3D 0; @@ -276,9 +268,4 @@ FvbInitialize ( =20 } } - - return EFI_SUCCESS; - -ERROR: - return Status; } diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceStandaloneMm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Spi= FvbServiceStandaloneMm.c new file mode 100644 index 000000000000..252c818d6551 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStan= daloneMm.c @@ -0,0 +1,32 @@ +/** @file + MM driver source for several Serial Flash devices + which are compliant with the Intel(R) Serial Flash Interface Compatibi= lity Specification. + + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "SpiFvbServiceCommon.h" +#include "SpiFvbServiceMm.h" + +/** + The driver Standalone MM entry point. + + @param[in] ImageHandle Image handle of this driver. + @param[in] MmSystemTable A pointer to the MM system table. + + @retval EFI_SUCCESS This function always returns EFI_SUCCE= SS. + +**/ +EFI_STATUS +EFIAPI +SpiFvbStandaloneMmInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *MmSystemTable + ) +{ + FvbInitialize (); + + return EFI_SUCCESS; +} diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceTraditionalMm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Sp= iFvbServiceTraditionalMm.c new file mode 100644 index 000000000000..1c2dac70e3c6 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTrad= itionalMm.c @@ -0,0 +1,32 @@ +/** @file + MM driver source for several Serial Flash devices + which are compliant with the Intel(R) Serial Flash Interface Compatibi= lity Specification. + + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "SpiFvbServiceCommon.h" +#include "SpiFvbServiceMm.h" + +/** + The driver Traditional MM entry point. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A pointer to the EFI system table. + + @retval EFI_SUCCESS This function always returns EFI_SUCCE= SS. + +**/ +EFI_STATUS +EFIAPI +SpiFvbTraditionalMmInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + FvbInitialize (); + + return EFI_SUCCESS; +} diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/Spi= FvbServiceCommon.h b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Sp= iFvbServiceCommon.h similarity index 94% rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiF= vbServiceCommon.h rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbService= Common.h index 6379fc86d52e..e9d69e985814 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServ= iceCommon.h +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceComm= on.h @@ -15,9 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 -#include -#include -#include #include #include #include @@ -159,4 +156,3 @@ extern FV_INFO mPlatformFv= BaseAddress[]; extern FV_INFO mPlatformDefaultBaseAddress[]; =20 #endif - diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceMm.h b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbService= Mm.h new file mode 100644 index 000000000000..36af1130c8ee --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h @@ -0,0 +1,22 @@ +/** @file + Definitions common to MM implementation in this driver. + + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _SPI_FVB_SERVICE_MM_H_ +#define _SPI_FVB_SERVICE_MM_H_ + +/** + The function does the necessary initialization work for + Firmware Volume Block Driver. + +**/ +VOID +FvbInitialize ( + VOID + ); + +#endif diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceSmm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceSmm.inf index d59c499b2e9e..10e51e11756f 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.= inf +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.= inf @@ -2,6 +2,7 @@ # Component description file for the Serial Flash device Runtime driver. # # Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -14,7 +15,8 @@ [Defines] VERSION_STRING =3D 1.0 MODULE_TYPE =3D DXE_SMM_DRIVER PI_SPECIFICATION_VERSION =3D 1.10 - ENTRY_POINT =3D FvbInitialize + ENTRY_POINT =3D SpiFvbTraditionalMmInitialize + # # The following information is for reference only and not required by th= e build tools. # @@ -28,11 +30,10 @@ [LibraryClasses] BaseMemoryLib DebugLib BaseLib - UefiLib UefiBootServicesTableLib UefiDriverEntryPoint SpiFlashCommonLib - SmmServicesTableLib + MmServicesTableLib =20 [Packages] MdePkg/MdePkg.dec @@ -48,10 +49,12 @@ [Pcd] gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize ## CONS= UMES =20 [Sources] - Common/SpiFvbServiceCommon.c - Common/FvbInfo.c - Common/SpiFvbServiceCommon.h - Smm/SpiFvbServiceSmm.c + FvbInfo.c + SpiFvbServiceCommon.h + SpiFvbServiceCommon.c + SpiFvbServiceMm.h + SpiFvbServiceMm.c + SpiFvbServiceTraditionalMm.c =20 [Protocols] gEfiDevicePathProtocolGuid ## PRODUCES diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceSmm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServ= iceStandaloneMm.inf similarity index 64% copy from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbService= Smm.inf copy to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSt= andaloneMm.inf index d59c499b2e9e..9f08d3673f41 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.= inf +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStan= daloneMm.inf @@ -1,20 +1,22 @@ ### @file -# Component description file for the Serial Flash device Runtime driver. +# Component description file for the Serial Flash device Standalone MM d= river. # # Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ### =20 [Defines] - INF_VERSION =3D 0x00010017 - BASE_NAME =3D SpiFvbServiceSmm - FILE_GUID =3D 68A10D85-6858-4402-B070-028B3EA2174= 7 + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SpiFvbServiceStandaloneMm + FILE_GUID =3D E6313655-8BD0-4EAB-B319-AD5E212CE6A= B VERSION_STRING =3D 1.0 - MODULE_TYPE =3D DXE_SMM_DRIVER - PI_SPECIFICATION_VERSION =3D 1.10 - ENTRY_POINT =3D FvbInitialize + MODULE_TYPE =3D MM_STANDALONE + PI_SPECIFICATION_VERSION =3D 0x00010032 + ENTRY_POINT =3D SpiFvbStandaloneMmInitialize + # # The following information is for reference only and not required by th= e build tools. # @@ -22,17 +24,15 @@ [Defines] # =20 [LibraryClasses] - PcdLib - MemoryAllocationLib - CacheMaintenanceLib + BaseLib BaseMemoryLib + CacheMaintenanceLib DebugLib - BaseLib - UefiLib - UefiBootServicesTableLib - UefiDriverEntryPoint + MemoryAllocationLib + PcdLib + MmServicesTableLib SpiFlashCommonLib - SmmServicesTableLib + StandaloneMmDriverEntryPoint =20 [Packages] MdePkg/MdePkg.dec @@ -48,10 +48,12 @@ [Pcd] gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize ## CONS= UMES =20 [Sources] - Common/SpiFvbServiceCommon.c - Common/FvbInfo.c - Common/SpiFvbServiceCommon.h - Smm/SpiFvbServiceSmm.c + FvbInfo.c + SpiFvbServiceCommon.h + SpiFvbServiceCommon.c + SpiFvbServiceMm.h + SpiFvbServiceMm.c + SpiFvbServiceStandaloneMm.c =20 [Protocols] gEfiDevicePathProtocolGuid ## PRODUCES diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/= Intel/MinPlatformPkg/MinPlatformPkg.dsc index 5e88de43e08d..0460fd5a3206 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc @@ -117,6 +117,7 @@ [LibraryClasses.common.MM_STANDALONE] DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocati= onLib/StandaloneMmMemoryAllocationLib.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standal= oneMmServicesTableLib.inf + SpiFlashCommonLib|MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/S= piFlashCommonLibNull.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoi= nt/StandaloneMmDriverEntryPoint.inf =20 ########################################################################= ########################### @@ -155,6 +156,7 @@ [Components] MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootMa= nagerLib.inf =20 MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf + MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNu= ll.inf =20 MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf --=20 2.28.0.windows.1