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.web10.422.1624656176382564110 for ; Fri, 25 Jun 2021 14:22:56 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=LzR0hnjw; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [167.220.2.74]) by linux.microsoft.com (Postfix) with ESMTPSA id 283DD20B83DE; Fri, 25 Jun 2021 14:22:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 283DD20B83DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1624656176; bh=shgzdN0p+sFgk4MN3aofqdqJl8YuRPvxWQWl93zYgyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LzR0hnjwpkJzb/Rn3QpDr1vXBtazT4tuHFQb1RweBF2es4V/cR4VS+OQlw7WJD0y+ NOv7Z/ZssgRuNG4EI2IQBCTPXMAcHLwh7sAOH722YPH+48SaFYR4IaCSKmwh0ukIMJ koF9CKArwqahyE27mO4hpqKJJxeB6uIMP79oPqo0= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Ray Ni , Rangasai V Chaganty , Nate DeSimone Subject: [edk2-platforms][PATCH v4 37/41] IntelSiliconPkg: Identify flash regions by GUID Date: Fri, 25 Jun 2021 17:21:16 -0400 Message-Id: <20210625212120.235-38-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210625212120.235-1-mikuback@linux.microsoft.com> References: <20210625212120.235-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3307 Updates the SPI protocol to identify flash regions by GUID instead of fixed values defined in an enum. Packages consuming IntelSiliconPkg are able to associate a given GUID with their chosen values based on their SPI flash details as implemented in their PCH_SPI_PROTOCOL instance. Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCo= mmonLib.c | 2 +- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlashCommo= n.c | 4 +- Silicon/Intel/IntelSiliconPkg/Include/Protocol/Spi.h = | 43 ++++---------------- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCo= mmonLib.inf | 3 ++ 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/S= mmSpiFlashCommonLib.c b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlash= CommonLib/SmmSpiFlashCommonLib.c index 7941b8f8720c..2c9c889e7f48 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFl= ashCommonLib.c +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFl= ashCommonLib.c @@ -52,7 +52,7 @@ SmmSpiFlashCommonLibConstructor ( ); ASSERT_EFI_ERROR (Status); =20 - mSpiProtocol->GetRegionAddress (mSpiProtocol, FlashRegionBios, &BaseAd= dr, &RegionSize); + mSpiProtocol->GetRegionAddress (mSpiProtocol, &gFlashRegionBiosGuid, &= BaseAddr, &RegionSize); mBiosOffset =3D BaseAddr; return Status; } diff --git a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/S= piFlashCommon.c b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommon= Lib/SpiFlashCommon.c index daebaf8e5e33..62c1d099fc2c 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlash= Common.c +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlash= Common.c @@ -127,7 +127,7 @@ SpiFlashWrite ( } Status =3D mSpiProtocol->FlashWrite ( mSpiProtocol, - FlashRegionBios, + &gFlashRegionBiosGuid, (UINT32) Offset, Length, Buffer @@ -201,7 +201,7 @@ SpiFlashBlockErase ( =20 Status =3D mSpiProtocol->FlashErase ( mSpiProtocol, - FlashRegionBios, + &gFlashRegionBiosGuid, (UINT32) Offset, (UINT32) RemainingBytes ); diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Protocol/Spi.h b/Silic= on/Intel/IntelSiliconPkg/Include/Protocol/Spi.h index c13dc5a5f5f5..2b09ca1faf02 100644 --- a/Silicon/Intel/IntelSiliconPkg/Include/Protocol/Spi.h +++ b/Silicon/Intel/IntelSiliconPkg/Include/Protocol/Spi.h @@ -19,33 +19,6 @@ extern EFI_GUID gPchSmmSpiProtocolGu= id; // typedef struct _PCH_SPI_PROTOCOL PCH_SPI_PROTOCOL; =20 -// -// SPI protocol data structures and definitions -// - -/** - Flash Region Type -**/ -typedef enum { - FlashRegionDescriptor, - FlashRegionBios, - FlashRegionMe, - FlashRegionGbE, - FlashRegionPlatformData, - FlashRegionDer, - FlashRegionSecondaryBios, - FlashRegionuCodePatch, - FlashRegionEC, - FlashRegionDeviceExpansion2, - FlashRegionIE, - FlashRegion10Gbe_A, - FlashRegion10Gbe_B, - FlashRegion13, - FlashRegion14, - FlashRegion15, - FlashRegionAll, - FlashRegionMax -} FLASH_REGION_TYPE; // // Protocol member functions // @@ -54,7 +27,7 @@ typedef enum { Read data from the flash part. =20 @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. @param[out] Buffer The Pointer to caller-allocated buffer= containing the dada received. @@ -68,7 +41,7 @@ typedef EFI_STATUS (EFIAPI *PCH_SPI_FLASH_READ) ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer @@ -78,7 +51,7 @@ EFI_STATUS Write data to the flash part. Remark: Erase may be needed before write= to the flash part. =20 @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. @param[in] Buffer Pointer to caller-allocated buffer con= taining the data sent during the SPI cycle. @@ -91,7 +64,7 @@ typedef EFI_STATUS (EFIAPI *PCH_SPI_FLASH_WRITE) ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer @@ -101,7 +74,7 @@ EFI_STATUS Erase some area on the flash part. =20 @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. - @param[in] FlashRegionType The Flash Region type for flash cycle = which is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall wit= hin a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of= the SPI cycle. =20 @@ -113,7 +86,7 @@ typedef EFI_STATUS (EFIAPI *PCH_SPI_FLASH_ERASE) ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount ); @@ -206,7 +179,7 @@ EFI_STATUS Get the SPI region base and size, based on the enum type =20 @param[in] This Pointer to the PCH_SPI_PROTOCOL instan= ce. - @param[in] FlashRegionType The Flash Region type for for the base= address which is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle = which corresponds to the type in the descriptor. @param[out] BaseAddress The Flash Linear Address for the Regio= n 'n' Base @param[out] RegionSize The size for the Region 'n' =20 @@ -218,7 +191,7 @@ typedef EFI_STATUS (EFIAPI *PCH_SPI_GET_REGION_ADDRESS) ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, OUT UINT32 *BaseAddress, OUT UINT32 *RegionSize ); diff --git a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/S= mmSpiFlashCommonLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFla= shCommonLib/SmmSpiFlashCommonLib.inf index f6a06351ace5..b28ea3c2719d 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFl= ashCommonLib.inf +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFl= ashCommonLib.inf @@ -37,6 +37,9 @@ [Pcd] gIntelSiliconPkgTokenSpaceGuid.PcdBiosAreaBaseAddress ## CONSUMES gIntelSiliconPkgTokenSpaceGuid.PcdBiosSize ## CONSUMES =20 +[Guids] + gFlashRegionBiosGuid + [Sources] SmmSpiFlashCommonLib.c SpiFlashCommon.c --=20 2.28.0.windows.1