From nobody Thu Dec 18 20:00:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+77134+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77134+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1624656182; cv=none; d=zohomail.com; s=zohoarc; b=SN+tq6mwVPVJWoNfDOMrZPdxPWQGxBqticZ+5jd/CYNJ0kL8DjyP/bjFaKwqLiyX2FZm2AAS+KoEYmX45LhgYHbBUpPtD94rcTCtliQOweQm6Jtb61nJxJVc8KPQmoJK5e8KEaun547plZKt3+KtSKYbqc7XnPB5QKRbQfMm0dA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624656182; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=w+GhagrMhWmzKBiWxfqRC+IZEPx1rpCpAloDtPrtH8s=; b=FDa2t9QCmCm8Wg9MhkGCclQyxjKm6kYFKaEdMGJ+RgsZaYJimu6ii2qgJuh+Q1tjYkvQI8QIRMNyfpu/WMyfUcfMHMzkEHUF+oYO6q3OspolTPjauH2/+QrcJOCno0qIozwKuCnGC+yrVtrwiaySywY4BGlqncU+trAjXmvBg1A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+77134+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624656182176851.7486671819369; Fri, 25 Jun 2021 14:23:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id QfOrYY1788612xW2Gw71TucN; Fri, 25 Jun 2021 14:23:01 -0700 X-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 X-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 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Ray Ni , Rangasai V Chaganty , Nate DeSimone Subject: [edk2-devel] [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> In-Reply-To: <20210625212120.235-1-mikuback@linux.microsoft.com> References: <20210625212120.235-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: pHibw7GEVZsZUkzz6XeTZWdux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624656181; bh=3ycsFWQP9Z1gnKwHKzsWmHRLba7SOIqflF4KhVrv5FQ=; h=Cc:Date:From:Reply-To:Subject:To; b=csF10orIEEbx8zKD1YKOFlldGpSd0tWrYzGcUMSSkaomADcVqrblFwjtFC2PYuT/tvT CooFsq78D32yvBXB0P08KgEMpqMV+GT7CP6laZPkp4zwHPkRS+n1WDuh0DEy5UrH3JN3r KqShtpcagFbw+NPP/rILdUIuOLZExTIR7fo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Nate DeSimone Reviewed-by: Sai Chaganty =20 --- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashComm= onLib.c | 2 +- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlashCommon.= c | 4 +- Silicon/Intel/IntelSiliconPkg/Include/Protocol/Spi.h = | 43 ++++---------------- Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashComm= onLib.inf | 3 ++ 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/Smm= SpiFlashCommonLib.c b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashComm= onLib/SmmSpiFlashCommonLib.c index 7941b8f8720c..2c9c889e7f48 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlas= hCommonLib.c +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlas= hCommonLib.c @@ -52,7 +52,7 @@ SmmSpiFlashCommonLibConstructor ( ); ASSERT_EFI_ERROR (Status); =20 - mSpiProtocol->GetRegionAddress (mSpiProtocol, FlashRegionBios, &BaseAddr= , &RegionSize); + mSpiProtocol->GetRegionAddress (mSpiProtocol, &gFlashRegionBiosGuid, &Ba= seAddr, &RegionSize); mBiosOffset =3D BaseAddr; return Status; } diff --git a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/Spi= FlashCommon.c b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/= SpiFlashCommon.c index daebaf8e5e33..62c1d099fc2c 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlashCo= mmon.c +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SpiFlashCo= mmon.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/Silicon= /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 gPchSmmSpiProtocolGuid; // 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 instance. - @param[in] FlashRegionType The Flash Region type for flash cycle wh= ich is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle wh= ich corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall withi= n a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of t= he SPI cycle. @param[out] Buffer The Pointer to caller-allocated buffer c= ontaining 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 t= o the flash part. =20 @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @param[in] FlashRegionType The Flash Region type for flash cycle wh= ich is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle wh= ich corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall withi= n a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of t= he SPI cycle. @param[in] Buffer Pointer to caller-allocated buffer conta= ining 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 instance. - @param[in] FlashRegionType The Flash Region type for flash cycle wh= ich is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle wh= ich corresponds to the type in the descriptor. @param[in] Address The Flash Linear Address must fall withi= n a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of t= he 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 instance. - @param[in] FlashRegionType The Flash Region type for for the base a= ddress which is listed in the Descriptor. + @param[in] FlashRegionGuid The Flash Region GUID for flash cycle wh= ich corresponds to the type in the descriptor. @param[out] BaseAddress The Flash Linear Address for the Region = '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/Smm= SpiFlashCommonLib.inf b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCo= mmonLib/SmmSpiFlashCommonLib.inf index f6a06351ace5..b28ea3c2719d 100644 --- a/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlas= hCommonLib.inf +++ b/Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlas= hCommonLib.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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#77134): https://edk2.groups.io/g/devel/message/77134 Mute This Topic: https://groups.io/mt/83794826/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-