* [edk2-platforms][PATCH v4 40/41] SimicsIch10Pkg/BasePchSpiCommonLib: Identify flash regions by GUID @ 2021-06-25 22:49 Michael Kubacki 2021-06-25 22:49 ` [edk2-platforms][PATCH v4 41/41] TigerlakeSiliconPkg/BasePchSpiCommonLib: " Michael Kubacki 0 siblings, 1 reply; 3+ messages in thread From: Michael Kubacki @ 2021-06-25 22:49 UTC (permalink / raw) To: devel; +Cc: Agyeman Prince, Nate DeSimone From: Michael Kubacki <michael.kubacki@microsoft.com> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3307 Updates the library to identify flash regions by GUID and internally map the GUID entries to values specific to SimicsIch10Pkg. Cc: Agyeman Prince <prince.agyeman@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> --- Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c | 139 ++++++++++++++++---- Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h | 20 +-- Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf | 11 ++ 3 files changed, 137 insertions(+), 33 deletions(-) diff --git a/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c b/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c index fc2a8be76b6a..04dbd921c091 100644 --- a/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c +++ b/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c @@ -2,11 +2,13 @@ PCH SPI Common Driver implements the SPI Host Controller Compatibility Interface. Copyright (c) 2019 Intel Corporation. All rights reserved. <BR> + Copyright (c) Microsoft Corporation.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include <Uefi/UefiBaseType.h> +#include <Guid/FlashRegion.h> #include <Library/IoLib.h> #include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> @@ -16,6 +18,90 @@ #include <IncludePrivate/Library/PchSpiCommonLib.h> #include <Register/X58Ich10.h> +typedef enum { + FlashRegionDescriptor, + FlashRegionBios, + FlashRegionMe, + FlashRegionGbe, + FlashRegionPlatformData, + FlashRegionDer, + FlashRegionAll, + FlashRegionMax +} FLASH_REGION_TYPE; + +typedef struct { + EFI_GUID *Guid; + FLASH_REGION_TYPE Type; +} FLASH_REGION_MAPPING; + +FLASH_REGION_MAPPING mFlashRegionTypes[] = { + { + &gFlashRegionDescriptorGuid, + FlashRegionDescriptor + }, + { + &gFlashRegionBiosGuid, + FlashRegionBios + }, + { + &gFlashRegionMeGuid, + FlashRegionMe + }, + { + &gFlashRegionGbeGuid, + FlashRegionGbe + }, + { + &gFlashRegionPlatformDataGuid, + FlashRegionPlatformData + }, + { + &gFlashRegionDerGuid, + FlashRegionDer + }, + { + &gFlashRegionAllGuid, + FlashRegionAll + }, + { + &gFlashRegionMaxGuid, + FlashRegionMax + } +}; + +/** + Returns the type of a flash region given its GUID. + + @param[in] FlashRegionGuid Pointer to the flash region GUID. + @param[out] FlashRegionType Pointer to a buffer that will be set to the flash region type value. + + @retval EFI_SUCCESS The flash region type was found for the given flash region GUID. + @retval EFI_INVALID_PARAMETER A pointer argument passed to the function is NULL. + @retval EFI_NOT_FOUND The flash region type was not found for the given flash region GUID. + +**/ +EFI_STATUS +GetFlashRegionType ( + IN EFI_GUID *FlashRegionGuid, + OUT FLASH_REGION_TYPE *FlashRegionType + ) +{ + UINTN Index; + + if (FlashRegionGuid == NULL || FlashRegionType == NULL) { + return EFI_INVALID_PARAMETER; + } + + for (Index = 0; Index < ARRAY_SIZE (mFlashRegionTypes); Index++) { + if (CompareGuid (mFlashRegionTypes[Index].Guid, FlashRegionGuid)) { + *FlashRegionType = mFlashRegionTypes[Index].Type; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + /** Initialize an SPI protocol instance. @@ -145,7 +231,7 @@ PchPmTimerStallRuntimeSafe ( Read data from the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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. @@ -159,7 +245,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashRead ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer @@ -172,7 +258,7 @@ SpiProtocolFlashRead ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleRead, Address, ByteCount, @@ -185,7 +271,7 @@ SpiProtocolFlashRead ( Write data to the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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 containing the data sent during the SPI cycle. @@ -198,7 +284,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashWrite ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer @@ -211,7 +297,7 @@ SpiProtocolFlashWrite ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleWrite, Address, ByteCount, @@ -224,7 +310,7 @@ SpiProtocolFlashWrite ( Erase some area on the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -236,7 +322,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashErase ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount ) @@ -248,7 +334,7 @@ SpiProtocolFlashErase ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleErase, Address, ByteCount, @@ -303,7 +389,7 @@ SpiProtocolFlashReadSfdp ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadSfdp, FlashAddress, ByteCount, @@ -356,7 +442,7 @@ SpiProtocolFlashReadJedecId ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadJedecId, Address, ByteCount, @@ -391,7 +477,7 @@ SpiProtocolFlashWriteStatus ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleWriteStatus, 0, ByteCount, @@ -426,7 +512,7 @@ SpiProtocolFlashReadStatus ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadStatus, 0, ByteCount, @@ -439,7 +525,7 @@ SpiProtocolFlashReadStatus ( Get the SPI region base and size, based on the enum type @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 the base address which 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' @@ -451,17 +537,24 @@ EFI_STATUS EFIAPI SpiProtocolGetRegionAddress ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, OUT UINT32 *BaseAddress, OUT UINT32 *RegionSize ) { - SPI_INSTANCE *SpiInstance; - UINTN PchSpiBar0; - UINT32 ReadValue; + EFI_STATUS Status; + FLASH_REGION_TYPE FlashRegionType; + SPI_INSTANCE *SpiInstance; + UINTN PchSpiBar0; + UINT32 ReadValue; SpiInstance = SPI_INSTANCE_FROM_SPIPROTOCOL (This); + Status = GetFlashRegionType (FlashRegionGuid, &FlashRegionType); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + if (FlashRegionType >= FlashRegionMax) { return EFI_INVALID_PARAMETER; } @@ -542,7 +635,7 @@ SpiProtocolReadPchSoftStrap ( // Status = SendSpiCmd ( This, - FlashRegionDescriptor, + &gFlashRegionDescriptorGuid, FlashCycleRead, StrapFlashAddr, ByteCount, @@ -600,7 +693,7 @@ SpiProtocolReadCpuSoftStrap ( // Status = SendSpiCmd ( This, - FlashRegionDescriptor, + &gFlashRegionDescriptorGuid, FlashCycleRead, StrapFlashAddr, ByteCount, @@ -613,7 +706,7 @@ SpiProtocolReadCpuSoftStrap ( This function sends the programmed SPI command to the slave device. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @param[in] SpiRegionType The SPI 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] FlashCycleType The Flash SPI cycle type list in HSFC (Hardware Sequencing Flash Control Register) register @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -627,7 +720,7 @@ SpiProtocolReadCpuSoftStrap ( EFI_STATUS SendSpiCmd ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN FLASH_CYCLE_TYPE FlashCycleType, IN UINT32 Address, IN UINT32 ByteCount, @@ -682,7 +775,7 @@ SendSpiCmd ( goto SendSpiCmdEnd; } - Status = SpiProtocolGetRegionAddress (This, FlashRegionType, &HardwareSpiAddr, &FlashRegionSize); + Status = SpiProtocolGetRegionAddress (This, FlashRegionGuid, &HardwareSpiAddr, &FlashRegionSize); if (EFI_ERROR (Status)) { goto SendSpiCmdEnd; } diff --git a/Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h b/Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h index 2c8162ac8170..603e141e2058 100644 --- a/Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h +++ b/Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h @@ -135,7 +135,7 @@ ReleaseSpiBar0 ( Read data from the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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. @@ -149,7 +149,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashRead ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer @@ -159,7 +159,7 @@ SpiProtocolFlashRead ( Write data to the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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 containing the data sent during the SPI cycle. @@ -172,7 +172,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashWrite ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer @@ -182,7 +182,7 @@ SpiProtocolFlashWrite ( Erase some area on the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -194,7 +194,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashErase ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount ); @@ -287,7 +287,7 @@ SpiProtocolFlashReadStatus ( Get the SPI region base and size, based on the enum type @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 the base address which 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' @@ -299,7 +299,7 @@ EFI_STATUS EFIAPI SpiProtocolGetRegionAddress ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, OUT UINT32 *BaseAddress, OUT UINT32 *RegionSize ); @@ -354,7 +354,7 @@ SpiProtocolReadCpuSoftStrap ( This function sends the programmed SPI command to the slave device. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @param[in] SpiRegionType The SPI 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] FlashCycleType The Flash SPI cycle type list in HSFC (Hardware Sequencing Flash Control Register) register @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -368,7 +368,7 @@ SpiProtocolReadCpuSoftStrap ( EFI_STATUS SendSpiCmd ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN FLASH_CYCLE_TYPE FlashCycleType, IN UINT32 Address, IN UINT32 ByteCount, diff --git a/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf b/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf index b5aa13c1c56d..3a64005b5690 100644 --- a/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf +++ b/Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf @@ -2,6 +2,7 @@ # Component description file for the PchSpiCommonLib # # Copyright (c) 2019 Intel Corporation. All rights reserved. <BR> +# Copyright (c) Microsoft Corporation.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -30,3 +31,13 @@ [LibraryClasses] [Pcd] gIntelSiliconPkgTokenSpaceGuid.PcdBiosAreaBaseAddress ## CONSUMES gIntelSiliconPkgTokenSpaceGuid.PcdBiosSize ## CONSUMES + +[Guids] + gFlashRegionDescriptorGuid + gFlashRegionBiosGuid + gFlashRegionMeGuid + gFlashRegionGbeGuid + gFlashRegionPlatformDataGuid + gFlashRegionDerGuid + gFlashRegionAllGuid + gFlashRegionMaxGuid -- 2.28.0.windows.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [edk2-platforms][PATCH v4 41/41] TigerlakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID 2021-06-25 22:49 [edk2-platforms][PATCH v4 40/41] SimicsIch10Pkg/BasePchSpiCommonLib: Identify flash regions by GUID Michael Kubacki @ 2021-06-25 22:49 ` Michael Kubacki 0 siblings, 0 replies; 3+ messages in thread From: Michael Kubacki @ 2021-06-25 22:49 UTC (permalink / raw) To: devel; +Cc: Rangasai V Chaganty, Nate DeSimone, Heng Luo From: Michael Kubacki <michael.kubacki@microsoft.com> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3307 Updates the library to identify flash regions by GUID and internally map the GUID entries to values specific to TigerlakeSiliconPkg. Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Heng Luo <heng.luo@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> --- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c | 176 +++++++++++++++++--- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h | 16 +- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf | 18 +- 3 files changed, 177 insertions(+), 33 deletions(-) diff --git a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c index 954b349e7c8a..5f372a5b58cb 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c @@ -2,9 +2,12 @@ PCH SPI Common Driver implements the SPI Host Controller Compatibility Interface. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR> + Copyright (c) Microsoft Corporation.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include <Uefi/UefiBaseType.h> +#include <Guid/FlashRegion.h> #include <Library/BaseLib.h> #include <Library/IoLib.h> #include <Library/DebugLib.h> @@ -21,6 +24,125 @@ #include <Library/PchPciBdfLib.h> #include <Library/SpiAccessLib.h> +typedef enum { + FlashRegionDescriptor, + FlashRegionBios, + FlashRegionMe, + FlashRegionGbe, + FlashRegionPlatformData, + FlashRegionDer, + FlashRegionSecondaryBios, + FlashRegionMicrocodePatch, + FlashRegionEc, + FlashRegionDeviceExpansion, + FlashRegionIe, + FlashRegion10GbeA, + FlashRegion10GbeB, + FlashRegionAll = 16, + FlashRegionMax +} FLASH_REGION_TYPE; + +typedef struct { + EFI_GUID *Guid; + FLASH_REGION_TYPE Type; +} FLASH_REGION_MAPPING; + +FLASH_REGION_MAPPING mFlashRegionTypes[] = { + { + &gFlashRegionDescriptorGuid, + FlashRegionDescriptor + }, + { + &gFlashRegionBiosGuid, + FlashRegionBios + }, + { + &gFlashRegionMeGuid, + FlashRegionMe + }, + { + &gFlashRegionGbeGuid, + FlashRegionGbe + }, + { + &gFlashRegionPlatformDataGuid, + FlashRegionPlatformData + }, + { + &gFlashRegionDerGuid, + FlashRegionDer + }, + { + &gFlashRegionSecondaryBiosGuid, + FlashRegionSecondaryBios + }, + { + &gFlashRegionMicrocodePatchGuid, + FlashRegionMicrocodePatch + }, + { + &gFlashRegionEcGuid, + FlashRegionEc + }, + { + &gFlashRegionDeviceExpansionGuid, + FlashRegionDeviceExpansion + }, + { + &gFlashRegionIeGuid, + FlashRegionIe + }, + { + &gFlashRegion10GbeAGuid, + FlashRegion10GbeA + }, + { + &gFlashRegion10GbeBGuid, + FlashRegion10GbeB + }, + { + &gFlashRegionAllGuid, + FlashRegionAll + }, + { + &gFlashRegionMaxGuid, + FlashRegionMax + } +}; + +/** + Returns the type of a flash region given its GUID. + + @param[in] FlashRegionGuid Pointer to the flash region GUID. + @param[out] FlashRegionType Pointer to a buffer that will be set to the flash region type value. + + @retval EFI_SUCCESS The flash region type was found for the given flash region GUID. + @retval EFI_INVALID_PARAMETER A pointer argument passed to the function is NULL. + @retval EFI_NOT_FOUND The flash region type was not found for the given flash region GUID. + +**/ +EFI_STATUS +GetFlashRegionType ( + IN EFI_GUID *FlashRegionGuid, + OUT FLASH_REGION_TYPE *FlashRegionType + ) +{ + UINTN Index; + + if (FlashRegionGuid == NULL || FlashRegionType == NULL) { + return EFI_INVALID_PARAMETER; + } + + for (Index = 0; Index < ARRAY_SIZE (mFlashRegionTypes); Index++) { + if (CompareGuid (mFlashRegionTypes[Index].Guid, FlashRegionGuid)) { + *FlashRegionType = mFlashRegionTypes[Index].Type; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + /** Initialize an SPI protocol instance. @@ -179,7 +301,7 @@ SpiProtocolConstructor ( ASSERT (SpiInstance->CpuStrapBaseAddr != 0); if (SpiInstance->CpuStrapBaseAddr != 0x300) { - Status = SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), FlashRegionAll, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) (&Data32)); + Status = SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), &gFlashRegionAllGuid, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) (&Data32)); ASSERT_EFI_ERROR (Status); Mdtba = (UINT16)(((Data32 & B_FLASH_UMAP1_MDTBA) >> N_FLASH_UMAP1_MDTBA) << N_FLASH_UMAP1_MDTBA_REPR); DEBUG ((DEBUG_INFO, "Mdtba : %0x\n", Mdtba)); @@ -312,7 +434,7 @@ WaitForSpiCycleComplete ( This function sends the programmed SPI command to the slave device. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @param[in] SpiRegionType The SPI 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] FlashCycleType The Flash SPI cycle type list in HSFC (Hardware Sequencing Flash Control Register) register @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -327,7 +449,7 @@ STATIC EFI_STATUS SendSpiCmd ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN FLASH_CYCLE_TYPE FlashCycleType, IN UINT32 Address, IN UINT32 ByteCount, @@ -413,7 +535,7 @@ SendSpiCmd ( } } - Status = SpiProtocolGetRegionAddress (This, FlashRegionType, &HardwareSpiAddr, &FlashRegionSize); + Status = SpiProtocolGetRegionAddress (This, FlashRegionGuid, &HardwareSpiAddr, &FlashRegionSize); if (EFI_ERROR (Status)) { goto SendSpiCmdEnd; } @@ -626,7 +748,7 @@ SendSpiCmd ( Read data from the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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. @@ -640,7 +762,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashRead ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer @@ -653,7 +775,7 @@ SpiProtocolFlashRead ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleRead, Address, ByteCount, @@ -666,7 +788,7 @@ SpiProtocolFlashRead ( Write data to the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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 containing the data sent during the SPI cycle. @@ -679,7 +801,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashWrite ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer @@ -692,7 +814,7 @@ SpiProtocolFlashWrite ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleWrite, Address, ByteCount, @@ -705,7 +827,7 @@ SpiProtocolFlashWrite ( Erase some area on the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -717,7 +839,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashErase ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount ) @@ -729,7 +851,7 @@ SpiProtocolFlashErase ( // Status = SendSpiCmd ( This, - FlashRegionType, + FlashRegionGuid, FlashCycleErase, Address, ByteCount, @@ -790,7 +912,7 @@ SpiProtocolFlashReadSfdp ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadSfdp, FlashAddress, ByteCount, @@ -849,7 +971,7 @@ SpiProtocolFlashReadJedecId ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadJedecId, Address, ByteCount, @@ -890,7 +1012,7 @@ SpiProtocolFlashWriteStatus ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleWriteStatus, 0, ByteCount, @@ -931,7 +1053,7 @@ SpiProtocolFlashReadStatus ( // Status = SendSpiCmd ( This, - FlashRegionAll, + &gFlashRegionAllGuid, FlashCycleReadStatus, 0, ByteCount, @@ -944,7 +1066,7 @@ SpiProtocolFlashReadStatus ( Get the SPI region base and size, based on the enum type @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 the base address which 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' @@ -956,17 +1078,23 @@ EFI_STATUS EFIAPI SpiProtocolGetRegionAddress ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, OUT UINT32 *BaseAddress, OUT UINT32 *RegionSize ) { - SPI_INSTANCE *SpiInstance; - UINTN PchSpiBar0; - UINT32 ReadValue; + EFI_STATUS Status; + FLASH_REGION_TYPE FlashRegionType; + SPI_INSTANCE *SpiInstance; + UINTN PchSpiBar0; + UINT32 ReadValue; SpiInstance = SPI_INSTANCE_FROM_SPIPROTOCOL (This); + Status = GetFlashRegionType (FlashRegionGuid, &FlashRegionType); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } if (FlashRegionType >= FlashRegionMax) { return EFI_INVALID_PARAMETER; } @@ -1047,7 +1175,7 @@ SpiProtocolReadPchSoftStrap ( // Status = SendSpiCmd ( This, - FlashRegionDescriptor, + &gFlashRegionDescriptorGuid, FlashCycleRead, StrapFlashAddr, ByteCount, @@ -1105,7 +1233,7 @@ SpiProtocolReadCpuSoftStrap ( // Status = SendSpiCmd ( This, - FlashRegionDescriptor, + &gFlashRegionDescriptorGuid, FlashCycleRead, StrapFlashAddr, ByteCount, diff --git a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h index 3290f7712280..3038ae749ef2 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h @@ -146,7 +146,7 @@ IsSpiFlashWriteGranted ( Read data from the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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. @@ -160,7 +160,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashRead ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer @@ -170,7 +170,7 @@ SpiProtocolFlashRead ( Write data to the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within 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 containing the data sent during the SPI cycle. @@ -183,7 +183,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashWrite ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer @@ -193,7 +193,7 @@ SpiProtocolFlashWrite ( Erase some area on the flash part. @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 within a region for which BIOS has access permissions. @param[in] ByteCount Number of bytes in the data portion of the SPI cycle. @@ -205,7 +205,7 @@ EFI_STATUS EFIAPI SpiProtocolFlashErase ( IN PCH_SPI_PROTOCOL *This, - IN FLASH_REGION_TYPE FlashRegionType, + IN EFI_GUID *FlashRegionGuid, IN UINT32 Address, IN UINT32 ByteCount ); @@ -298,7 +298,7 @@ SpiProtocolFlashReadStatus ( Get the SPI region base and size, based on the enum type @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. - @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 the base address which 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' @@ -310,7 +310,7 @@ EFI_STATUS EFIAPI SpiProtocolGetRegionAddress ( 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/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf index 2686dff41e25..4981276e13e8 100644 --- a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf @@ -2,6 +2,7 @@ # Component description file for the PchSpiCommonLib # # Copyright (c) 2021, Intel Corporation. All rights reserved.<BR> +# Copyright (c) Microsoft Corporation.<BR> # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,4 +30,19 @@ [LibraryClasses] PchPciBdfLib SpiAccessLib -[Pcd] +[Guids] + gFlashRegionDescriptorGuid + gFlashRegionBiosGuid + gFlashRegionMeGuid + gFlashRegionGbeGuid + gFlashRegionPlatformDataGuid + gFlashRegionDerGuid + gFlashRegionSecondaryBiosGuid + gFlashRegionMicrocodePatchGuid + gFlashRegionEcGuid + gFlashRegionDeviceExpansionGuid + gFlashRegionIeGuid + gFlashRegion10GbeAGuid + gFlashRegion10GbeBGuid + gFlashRegionAllGuid + gFlashRegionMaxGuid -- 2.28.0.windows.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [edk2-platforms][PATCH v4 00/41] Consolidate SpiFlashCommonLib instances @ 2021-06-25 21:20 Michael Kubacki [not found] ` <20210625212120.235-42-mikuback@linux.microsoft.com> 0 siblings, 1 reply; 3+ messages in thread From: Michael Kubacki @ 2021-06-25 21:20 UTC (permalink / raw) To: devel Cc: Agyeman Prince, Chasel Chiu, Deepika Kethi Reddy, Eric Dong, Heng Luo, Jeremy Soller, Kathappan Esakkithevar, Liming Gao, Nate DeSimone, Rangasai V Chaganty From: Michael Kubacki <michael.kubacki@microsoft.com> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3307 SpiFlashCommonLib is duplicated in multiple places across the MinPlatform design in edk2-platforms. I'm planning to build some additional functionality on top of SpiFlashCommonLib and, ideally, this duplication will be consolidated into a single instance usable across all current library consumers. This patch series focuses on consolidating the various SpiFlashCommonLib instances as agreed upon in https://edk2.groups.io/g/devel/message/71701. Read the BZ for more general background around this series. I only have an UpXtreme board on hand so maintainers/reviewers of other board packages should test these changes on those boards. V4 changes: - Assigned new GUID values to the PCH SPI PPI and Protocols to differentiate from previous instances. This was done because the interface changed to identify SPI flash regions by GUID. V3 changes: - Added support to IntelSiliconPkg to identify flash regions by GUID as requested in v2 review feedback. V2 changes: - Rebased patch series on current edk2-platforms master (32183bdaa91) Note: Previous patch series only received a couple review comments after being on the mailing list for over 2 months. Please be respectful of contributors time and efforts and review in a timely manner. Cc: Agyeman Prince <prince.agyeman@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Deepika Kethi Reddy <deepika.kethi.reddy@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Heng Luo <heng.luo@intel.com> Cc: Jeremy Soller <jeremy@system76.com> Cc: Kathappan Esakkithevar <kathappan.esakkithevar@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Michael Kubacki (41): CometlakeOpenBoardPkg: Remove redundant IntelSiliconPkg.dec entry WhiskeylakeOpenBoardPkg: Remove redundant IntelSiliconPkg.dec entry CometlakeOpenBoardPkg/PeiPolicyUpdateLib: Add missing GUID to INF IntelSiliconPkg: Add BIOS area base address and size PCDs IntelSiliconPkg: Add microcode FV PCDs IntelSiliconPkg: Add PCH SPI PPI IntelSiliconPkg: Add PCH SPI Protocol IntelSiliconPkg: Add SpiFlashCommonLib IntelSiliconPkg: Add SmmSpiFlashCommonLib IntelSiliconPkg: Add MM SPI FVB services CometlakeOpenBoardPkg: Use IntelSiliconPkg BIOS area and ucode PCDs KabylakeOpenBoardPkg: Use IntelSiliconPkg BIOS area and ucode PCDs SimicsOpenBoardPkg: Use IntelSiliconPkg BIOS area and ucode PCDs TigerlakeOpenBoardPkg: Use IntelSiliconPkg BIOS area and ucode PCDs WhiskeylakeOpenBoardPkg: Use IntelSiliconPkg BIOS area and ucode PCDs CoffeelakeSiliconPkg: Use IntelSiliconPkg BIOS area and ucode PCDs KabylakeSiliconPkg: Use IntelSiliconPkg BIOS area and ucode PCDs SimicsIch10Pkg: Use IntelSiliconPkg BIOS area and ucode PCDs TigerlakeSiliconPkg: Use IntelSiliconPkg BIOS area and ucode PCDs CometlakeOpenBoardPkg: Update SpiFvbService & SpiFlashCommonLib KabylakeOpenBoardPkg: Update SpiFvbService & SpiFlashCommonLib SimicsOpenBoardPkg: Update SpiFvbService & SpiFlashCommonLib TigerlakeOpenBoardPkg: Update SpiFvbService & SpiFlashCommonLib WhiskeylakeOpenBoardPkg: Update SpiFvbService & SpiFlashCommonLib MinPlatformPkg: Remove SpiFvbService modules CoffeelakeSiliconPkg: Remove SmmSpiFlashCommonLib KabylakeSiliconPkg: Remove SmmSpiFlashCommonLib SimicsIch10Pkg: Remove SmmSpiFlashCommonLib TigerlakeOpenBoardPkg: Remove SmmSpiFlashCommonLib MinPlatformPkg: Remove SpiFlashCommonLibNull KabylakeOpenBoardPkg/PeiSerialPortLibSpiFlash: Add IntelSiliconPkg.dec CoffeelakeSiliconPkg: Remove PCH SPI PPI and Protocol from package KabylakeSiliconPkg: Remove PCH SPI PPI and Protocol from package SimicsIch10Pkg: Remove PCH SPI SMM Protocol from package TigerlakeSiliconPkg: Remove PCH SPI PPI and Protocol from package IntelSiliconPkg: Add flash region GUIDs IntelSiliconPkg: Identify flash regions by GUID CoffeelakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID KabylakeSiliconPkg: Identify flash regions by GUID SimicsIch10Pkg/BasePchSpiCommonLib: Identify flash regions by GUID TigerlakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/BasePchSpiCommonLib/SpiCommon.c | 144 ++++++++-- Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c | 196 ------------- Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c | 54 ---- {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/FvbInfo.c | 0 {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceCommon.c | 4 +- {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceMm.c | 8 +- {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c | 0 {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c | 0 Platform/Intel/TigerlakeOpenBoardPkg/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c => Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.c | 2 +- {Platform/Intel/TigerlakeOpenBoardPkg => Silicon/Intel/IntelSiliconPkg}/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c | 7 +- {Platform/Intel/MinPlatformPkg/Flash => Silicon/Intel/IntelSiliconPkg}/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.c | 12 +- Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/SecureMemoryMapConfiguration.c | 106 ++++++- Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c | 196 ------------- Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c | 54 ---- Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c | 140 +++++++-- Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c | 194 ------------- Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c | 54 ---- Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/SpiCommon.c | 165 ++++++++--- Silicon/Intel/SimicsIch10Pkg/Spi/Smm/PchSpi.c | 4 +- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/SpiCommon.c | 176 ++++++++++-- Platform/Intel/CometlakeOpenBoardPkg/BiosInfo/BiosInfo.inf | 4 +- Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc | 7 +- Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.fdf | 38 +-- Platform/Intel/CometlakeOpenBoardPkg/Policy/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf | 2 +- Platform/Intel/CometlakeOpenBoardPkg/Policy/PolicyInitDxe/PolicyInitDxe.inf | 4 +- Platform/Intel/KabylakeOpenBoardPkg/BiosInfo/BiosInfo.inf | 4 +- Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 7 +- Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf | 40 +-- Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc | 7 +- Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.fdf | 40 +-- Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 4 +- Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf | 1 + Platform/Intel/MinPlatformPkg/Include/Library/SpiFlashCommonLib.h | 98 ------- Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 2 - Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 6 - Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc | 6 +- Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf | 2 +- Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf.inc | 8 +- Platform/Intel/TigerlakeOpenBoardPkg/BiosInfo/BiosInfo.inf | 8 +- Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc | 7 +- Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.fdf | 40 +-- Platform/Intel/WhiskeylakeOpenBoardPkg/BiosInfo/BiosInfo.inf | 4 +- Platform/Intel/WhiskeylakeOpenBoardPkg/Policy/Library/PeiPolicyUpdateLib/PeiPolicyUpdateLib.inf | 1 - Platform/Intel/WhiskeylakeOpenBoardPkg/Policy/PolicyInitDxe/PolicyInitDxe.inf | 4 +- Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Library/BoardInitLib/PeiMultiBoardInitPreMemLib.inf | 2 +- Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc | 7 +- Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.fdf | 38 +-- Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/Fdf/FlashMapInclude.fdf | 4 +- Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 7 +- Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.fdf | 38 +-- Silicon/Intel/CoffeelakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/PeiCpuPolicyLib.inf | 4 +- Silicon/Intel/CoffeelakeSiliconPkg/Pch/Include/Private/Library/PchSpiCommonLib.h | 16 +- Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.inf | 1 + Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/Private/BasePchSpiCommonLib/BasePchSpiCommonLib.inf | 13 + Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf | 51 ---- Silicon/Intel/CoffeelakeSiliconPkg/Pch/Spi/Smm/PchSpiSmm.inf | 1 + Silicon/Intel/CoffeelakeSiliconPkg/SiPkg.dec | 8 - {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceCommon.h | 0 {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceMm.h | 0 {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceSmm.inf | 6 +- {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf | 6 +- Silicon/Intel/IntelSiliconPkg/Include/Guid/FlashRegion.h | 45 +++ Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Library/SpiFlashCommonLib.h | 2 +- Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Ppi/Spi.h | 4 +- Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Protocol/Spi.h | 39 +-- Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec | 37 +++ Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc | 17 ++ {Platform/Intel/TigerlakeOpenBoardPkg => Silicon/Intel/IntelSiliconPkg}/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf | 24 +- {Platform/Intel/MinPlatformPkg/Flash => Silicon/Intel/IntelSiliconPkg}/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf | 3 +- Silicon/Intel/KabylakeSiliconPkg/Cpu/Library/PeiCpuPolicyLib/PeiCpuPolicyLib.inf | 4 +- Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/HstiSiliconDxe.inf | 12 +- Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/SpiFlashCommonLib.h | 98 ------- Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Ppi/Spi.h | 26 -- Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Protocol/Spi.h | 293 ------------------- Silicon/Intel/KabylakeSiliconPkg/Pch/IncludePrivate/Library/PchSpiCommonLib.h | 20 +- Silicon/Intel/KabylakeSiliconPkg/Pch/Library/PeiSpiLib/PeiSpiLib.inf | 1 + Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf | 53 ---- Silicon/Intel/KabylakeSiliconPkg/Pch/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf | 11 + Silicon/Intel/KabylakeSiliconPkg/Pch/Spi/Smm/PchSpiSmm.inf | 1 + Silicon/Intel/KabylakeSiliconPkg/SiPkg.dec | 13 +- Silicon/Intel/SimicsIch10Pkg/Ich10Pkg.dec | 11 - Silicon/Intel/SimicsIch10Pkg/Include/Library/SpiFlashCommonLib.h | 98 ------- Silicon/Intel/SimicsIch10Pkg/Include/Protocol/Spi.h | 295 ------------------- Silicon/Intel/SimicsIch10Pkg/IncludePrivate/Library/PchSpiCommonLib.h | 46 +-- Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf | 50 ---- Silicon/Intel/SimicsIch10Pkg/LibraryPrivate/BasePchSpiCommonLib/BasePchSpiCommonLib.inf | 16 +- Silicon/Intel/SimicsIch10Pkg/Spi/Smm/PchSpiSmm.inf | 3 +- Silicon/Intel/TigerlakeSiliconPkg/Include/Protocol/Spi.h | 301 -------------------- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCommonLib.h | 16 +- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommonLib/BaseSpiCommonLib.inf | 19 +- Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/Smm/SpiSmm.inf | 1 + Silicon/Intel/TigerlakeSiliconPkg/Pch/PchInit/Dxe/PchInitDxeTgl.inf | 1 + Silicon/Intel/TigerlakeSiliconPkg/SiPkg.dec | 8 - 98 files changed, 1083 insertions(+), 2567 deletions(-) delete mode 100644 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c delete mode 100644 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/FvbInfo.c (100%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceCommon.c (96%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceMm.c (94%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c (100%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c (100%) rename Platform/Intel/TigerlakeOpenBoardPkg/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c => Silicon/Intel/IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.c (90%) rename {Platform/Intel/TigerlakeOpenBoardPkg => Silicon/Intel/IntelSiliconPkg}/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c (93%) rename {Platform/Intel/MinPlatformPkg/Flash => Silicon/Intel/IntelSiliconPkg}/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.c (83%) delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c delete mode 100644 Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SpiFlashCommon.c delete mode 100644 Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SpiFlashCommonSmmLib.c delete mode 100644 Platform/Intel/MinPlatformPkg/Include/Library/SpiFlashCommonLib.h delete mode 100644 Silicon/Intel/CoffeelakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceCommon.h (100%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceMm.h (100%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceSmm.inf (88%) rename {Platform/Intel/MinPlatformPkg => Silicon/Intel/IntelSiliconPkg/Feature}/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf (88%) create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Guid/FlashRegion.h rename Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Library/SpiFlashCommonLib.h (96%) rename Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Ppi/Spi.h (85%) rename Silicon/Intel/{CoffeelakeSiliconPkg/Pch => IntelSiliconPkg}/Include/Protocol/Spi.h (89%) rename {Platform/Intel/TigerlakeOpenBoardPkg => Silicon/Intel/IntelSiliconPkg}/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf (67%) rename {Platform/Intel/MinPlatformPkg/Flash => Silicon/Intel/IntelSiliconPkg}/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf (91%) delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Library/SpiFlashCommonLib.h delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Ppi/Spi.h delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Include/Protocol/Spi.h delete mode 100644 Silicon/Intel/KabylakeSiliconPkg/Pch/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf delete mode 100644 Silicon/Intel/SimicsIch10Pkg/Include/Library/SpiFlashCommonLib.h delete mode 100644 Silicon/Intel/SimicsIch10Pkg/Include/Protocol/Spi.h delete mode 100644 Silicon/Intel/SimicsIch10Pkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf delete mode 100644 Silicon/Intel/TigerlakeSiliconPkg/Include/Protocol/Spi.h -- 2.28.0.windows.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20210625212120.235-42-mikuback@linux.microsoft.com>]
* Re: [edk2-platforms][PATCH v4 41/41] TigerlakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID [not found] ` <20210625212120.235-42-mikuback@linux.microsoft.com> @ 2021-07-29 0:48 ` Nate DeSimone 0 siblings, 0 replies; 3+ messages in thread From: Nate DeSimone @ 2021-07-29 0:48 UTC (permalink / raw) To: mikuback@linux.microsoft.com, devel@edk2.groups.io Cc: Chaganty, Rangasai V, Luo, Heng Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com> > -----Original Message----- > From: mikuback@linux.microsoft.com <mikuback@linux.microsoft.com> > Sent: Friday, June 25, 2021 2:21 PM > To: devel@edk2.groups.io > Cc: Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Desimone, > Nathaniel L <nathaniel.l.desimone@intel.com>; Luo, Heng > <heng.luo@intel.com> > Subject: [edk2-platforms][PATCH v4 41/41] > TigerlakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID > > From: Michael Kubacki <michael.kubacki@microsoft.com> > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3307 > > Updates the library to identify flash regions by GUID and internally map the > GUID entries to values specific to TigerlakeSiliconPkg. > > Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> > Cc: Heng Luo <heng.luo@intel.com> > Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> > --- > > Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommon > Lib/SpiCommon.c | 176 +++++++++++++++++--- > > Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCom > monLib.h | 16 +- > > Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiCommon > Lib/BaseSpiCommonLib.inf | 18 +- > 3 files changed, 177 insertions(+), 33 deletions(-) > > diff --git > a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/SpiCommon.c > b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/SpiCommon.c > index 954b349e7c8a..5f372a5b58cb 100644 > --- > a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/SpiCommon.c > +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseS > +++ piCommonLib/SpiCommon.c > @@ -2,9 +2,12 @@ > PCH SPI Common Driver implements the SPI Host Controller Compatibility > Interface. > > Copyright (c) 2021, Intel Corporation. All rights reserved.<BR> > + Copyright (c) Microsoft Corporation.<BR> > + > SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include > <Uefi/UefiBaseType.h> > +#include <Guid/FlashRegion.h> > #include <Library/BaseLib.h> > #include <Library/IoLib.h> > #include <Library/DebugLib.h> > @@ -21,6 +24,125 @@ > #include <Library/PchPciBdfLib.h> > #include <Library/SpiAccessLib.h> > > +typedef enum { > + FlashRegionDescriptor, > + FlashRegionBios, > + FlashRegionMe, > + FlashRegionGbe, > + FlashRegionPlatformData, > + FlashRegionDer, > + FlashRegionSecondaryBios, > + FlashRegionMicrocodePatch, > + FlashRegionEc, > + FlashRegionDeviceExpansion, > + FlashRegionIe, > + FlashRegion10GbeA, > + FlashRegion10GbeB, > + FlashRegionAll = 16, > + FlashRegionMax > +} FLASH_REGION_TYPE; > + > +typedef struct { > + EFI_GUID *Guid; > + FLASH_REGION_TYPE Type; > +} FLASH_REGION_MAPPING; > + > +FLASH_REGION_MAPPING mFlashRegionTypes[] = { > + { > + &gFlashRegionDescriptorGuid, > + FlashRegionDescriptor > + }, > + { > + &gFlashRegionBiosGuid, > + FlashRegionBios > + }, > + { > + &gFlashRegionMeGuid, > + FlashRegionMe > + }, > + { > + &gFlashRegionGbeGuid, > + FlashRegionGbe > + }, > + { > + &gFlashRegionPlatformDataGuid, > + FlashRegionPlatformData > + }, > + { > + &gFlashRegionDerGuid, > + FlashRegionDer > + }, > + { > + &gFlashRegionSecondaryBiosGuid, > + FlashRegionSecondaryBios > + }, > + { > + &gFlashRegionMicrocodePatchGuid, > + FlashRegionMicrocodePatch > + }, > + { > + &gFlashRegionEcGuid, > + FlashRegionEc > + }, > + { > + &gFlashRegionDeviceExpansionGuid, > + FlashRegionDeviceExpansion > + }, > + { > + &gFlashRegionIeGuid, > + FlashRegionIe > + }, > + { > + &gFlashRegion10GbeAGuid, > + FlashRegion10GbeA > + }, > + { > + &gFlashRegion10GbeBGuid, > + FlashRegion10GbeB > + }, > + { > + &gFlashRegionAllGuid, > + FlashRegionAll > + }, > + { > + &gFlashRegionMaxGuid, > + FlashRegionMax > + } > +}; > + > +/** > + Returns the type of a flash region given its GUID. > + > + @param[in] FlashRegionGuid Pointer to the flash region GUID. > + @param[out] FlashRegionType Pointer to a buffer that will be set to the > flash region type value. > + > + @retval EFI_SUCCESS The flash region type was found for the > given flash region GUID. > + @retval EFI_INVALID_PARAMETER A pointer argument passed to the > function is NULL. > + @retval EFI_NOT_FOUND The flash region type was not found for > the given flash region GUID. > + > +**/ > +EFI_STATUS > +GetFlashRegionType ( > + IN EFI_GUID *FlashRegionGuid, > + OUT FLASH_REGION_TYPE *FlashRegionType > + ) > +{ > + UINTN Index; > + > + if (FlashRegionGuid == NULL || FlashRegionType == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + for (Index = 0; Index < ARRAY_SIZE (mFlashRegionTypes); Index++) { > + if (CompareGuid (mFlashRegionTypes[Index].Guid, FlashRegionGuid)) { > + *FlashRegionType = mFlashRegionTypes[Index].Type; > + return EFI_SUCCESS; > + } > + } > + > + return EFI_NOT_FOUND; > +} > + > /** > Initialize an SPI protocol instance. > > @@ -179,7 +301,7 @@ SpiProtocolConstructor ( > ASSERT (SpiInstance->CpuStrapBaseAddr != 0); > > if (SpiInstance->CpuStrapBaseAddr != 0x300) { > - Status = SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), > FlashRegionAll, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) (&Data32)); > + Status = SpiProtocolFlashRead (&(SpiInstance->SpiProtocol), > + &gFlashRegionAllGuid, R_FLASH_UMAP1, sizeof (Data32), (UINT8 *) > + (&Data32)); > ASSERT_EFI_ERROR (Status); > Mdtba = (UINT16)(((Data32 & B_FLASH_UMAP1_MDTBA) >> > N_FLASH_UMAP1_MDTBA) << N_FLASH_UMAP1_MDTBA_REPR); > DEBUG ((DEBUG_INFO, "Mdtba : %0x\n", Mdtba)); @@ -312,7 +434,7 @@ > WaitForSpiCycleComplete ( > This function sends the programmed SPI command to the slave device. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @param[in] SpiRegionType The SPI 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] FlashCycleType The Flash SPI cycle type list in HSFC > (Hardware Sequencing Flash Control Register) register > @param[in] Address The Flash Linear Address must fall within a > region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of the SPI > cycle. > @@ -327,7 +449,7 @@ STATIC > EFI_STATUS > SendSpiCmd ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN FLASH_CYCLE_TYPE FlashCycleType, > IN UINT32 Address, > IN UINT32 ByteCount, > @@ -413,7 +535,7 @@ SendSpiCmd ( > } > } > > - Status = SpiProtocolGetRegionAddress (This, FlashRegionType, > &HardwareSpiAddr, &FlashRegionSize); > + Status = SpiProtocolGetRegionAddress (This, FlashRegionGuid, > + &HardwareSpiAddr, &FlashRegionSize); > if (EFI_ERROR (Status)) { > goto SendSpiCmdEnd; > } > @@ -626,7 +748,7 @@ SendSpiCmd ( > Read data from the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within 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. > @@ -640,7 +762,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -653,7 +775,7 @@ SpiProtocolFlashRead ( > // > Status = SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleRead, > Address, > ByteCount, > @@ -666,7 +788,7 @@ SpiProtocolFlashRead ( > Write data to the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within 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 containing the > data sent during the SPI cycle. > @@ -679,7 +801,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -692,7 +814,7 @@ SpiProtocolFlashWrite ( > // > Status = SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleWrite, > Address, > ByteCount, > @@ -705,7 +827,7 @@ SpiProtocolFlashWrite ( > Erase some area on the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within a > region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of the SPI > cycle. > > @@ -717,7 +839,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ) > @@ -729,7 +851,7 @@ SpiProtocolFlashErase ( > // > Status = SendSpiCmd ( > This, > - FlashRegionType, > + FlashRegionGuid, > FlashCycleErase, > Address, > ByteCount, > @@ -790,7 +912,7 @@ SpiProtocolFlashReadSfdp ( > // > Status = SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadSfdp, > FlashAddress, > ByteCount, > @@ -849,7 +971,7 @@ SpiProtocolFlashReadJedecId ( > // > Status = SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadJedecId, > Address, > ByteCount, > @@ -890,7 +1012,7 @@ SpiProtocolFlashWriteStatus ( > // > Status = SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleWriteStatus, > 0, > ByteCount, > @@ -931,7 +1053,7 @@ SpiProtocolFlashReadStatus ( > // > Status = SendSpiCmd ( > This, > - FlashRegionAll, > + &gFlashRegionAllGuid, > FlashCycleReadStatus, > 0, > ByteCount, > @@ -944,7 +1066,7 @@ SpiProtocolFlashReadStatus ( > Get the SPI region base and size, based on the enum type > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 the base > address which 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' > > @@ -956,17 +1078,23 @@ EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > OUT UINT32 *BaseAddress, > OUT UINT32 *RegionSize > ) > { > - SPI_INSTANCE *SpiInstance; > - UINTN PchSpiBar0; > - UINT32 ReadValue; > + EFI_STATUS Status; > + FLASH_REGION_TYPE FlashRegionType; > + SPI_INSTANCE *SpiInstance; > + UINTN PchSpiBar0; > + UINT32 ReadValue; > > SpiInstance = SPI_INSTANCE_FROM_SPIPROTOCOL (This); > > + Status = GetFlashRegionType (FlashRegionGuid, &FlashRegionType); if > + (EFI_ERROR (Status)) { > + return EFI_INVALID_PARAMETER; > + } > if (FlashRegionType >= FlashRegionMax) { > return EFI_INVALID_PARAMETER; > } > @@ -1047,7 +1175,7 @@ SpiProtocolReadPchSoftStrap ( > // > Status = SendSpiCmd ( > This, > - FlashRegionDescriptor, > + &gFlashRegionDescriptorGuid, > FlashCycleRead, > StrapFlashAddr, > ByteCount, > @@ -1105,7 +1233,7 @@ SpiProtocolReadCpuSoftStrap ( > // > Status = SendSpiCmd ( > This, > - FlashRegionDescriptor, > + &gFlashRegionDescriptorGuid, > FlashCycleRead, > StrapFlashAddr, > ByteCount, > diff --git > a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCo > mmonLib.h > b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCo > mmonLib.h > index 3290f7712280..3038ae749ef2 100644 > --- > a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Library/SpiCo > mmonLib.h > +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/IncludePrivate/Libra > +++ ry/SpiCommonLib.h > @@ -146,7 +146,7 @@ IsSpiFlashWriteGranted ( > Read data from the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within 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. > @@ -160,7 +160,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashRead ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > OUT UINT8 *Buffer > @@ -170,7 +170,7 @@ SpiProtocolFlashRead ( > Write data to the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within 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 containing the > data sent during the SPI cycle. > @@ -183,7 +183,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashWrite ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount, > IN UINT8 *Buffer > @@ -193,7 +193,7 @@ SpiProtocolFlashWrite ( > Erase some area on the flash part. > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 within a > region for which BIOS has access permissions. > @param[in] ByteCount Number of bytes in the data portion of the SPI > cycle. > > @@ -205,7 +205,7 @@ EFI_STATUS > EFIAPI > SpiProtocolFlashErase ( > IN PCH_SPI_PROTOCOL *This, > - IN FLASH_REGION_TYPE FlashRegionType, > + IN EFI_GUID *FlashRegionGuid, > IN UINT32 Address, > IN UINT32 ByteCount > ); > @@ -298,7 +298,7 @@ SpiProtocolFlashReadStatus ( > Get the SPI region base and size, based on the enum type > > @param[in] This Pointer to the PCH_SPI_PROTOCOL instance. > - @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 the base > address which 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' > > @@ -310,7 +310,7 @@ EFI_STATUS > EFIAPI > SpiProtocolGetRegionAddress ( > 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/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/BaseSpiCommonLib.inf > b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/BaseSpiCommonLib.inf > index 2686dff41e25..4981276e13e8 100644 > --- > a/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseSpiComm > onLib/BaseSpiCommonLib.inf > +++ b/Silicon/Intel/TigerlakeSiliconPkg/IpBlock/Spi/LibraryPrivate/BaseS > +++ piCommonLib/BaseSpiCommonLib.inf > @@ -2,6 +2,7 @@ > # Component description file for the PchSpiCommonLib # # Copyright (c) > 2021, Intel Corporation. All rights reserved.<BR> > +# Copyright (c) Microsoft Corporation.<BR> > # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,4 +30,19 @@ > [LibraryClasses] > PchPciBdfLib > SpiAccessLib > > -[Pcd] > +[Guids] > + gFlashRegionDescriptorGuid > + gFlashRegionBiosGuid > + gFlashRegionMeGuid > + gFlashRegionGbeGuid > + gFlashRegionPlatformDataGuid > + gFlashRegionDerGuid > + gFlashRegionSecondaryBiosGuid > + gFlashRegionMicrocodePatchGuid > + gFlashRegionEcGuid > + gFlashRegionDeviceExpansionGuid > + gFlashRegionIeGuid > + gFlashRegion10GbeAGuid > + gFlashRegion10GbeBGuid > + gFlashRegionAllGuid > + gFlashRegionMaxGuid > -- > 2.28.0.windows.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-29 0:48 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-06-25 22:49 [edk2-platforms][PATCH v4 40/41] SimicsIch10Pkg/BasePchSpiCommonLib: Identify flash regions by GUID Michael Kubacki 2021-06-25 22:49 ` [edk2-platforms][PATCH v4 41/41] TigerlakeSiliconPkg/BasePchSpiCommonLib: " Michael Kubacki -- strict thread matches above, loose matches on Subject: below -- 2021-06-25 21:20 [edk2-platforms][PATCH v4 00/41] Consolidate SpiFlashCommonLib instances Michael Kubacki [not found] ` <20210625212120.235-42-mikuback@linux.microsoft.com> 2021-07-29 0:48 ` [edk2-platforms][PATCH v4 41/41] TigerlakeSiliconPkg/BasePchSpiCommonLib: Identify flash regions by GUID Nate DeSimone
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox