diff --git a/BootloaderCommonPkg/Include/Library/FirmwareUpdateLib.h b/BootloaderCommonPkg/Include/Library/FirmwareUpdateLib.h index ca3449a8..e0dec154 100644 --- a/BootloaderCommonPkg/Include/Library/FirmwareUpdateLib.h +++ b/BootloaderCommonPkg/Include/Library/FirmwareUpdateLib.h @@ -387,6 +387,28 @@ BootMediaWrite ( OUT UINT8 *Buffer ); + +/** + This function writes blocks to the SPI device based on flash region type. + + @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor. + @param[in] Address The block address in the FlashRegionAll to read from on the SPI. + @param[in] ByteCount Size of the Buffer in bytes. + @param[out] Buffer Pointer to caller-allocated buffer containing the data received during the SPI cycle. + + @retval EFI_SUCCESS Write completes successfully. + @retval others Device error, the command aborts abnormally. + +**/ +EFI_STATUS +EFIAPI +BootMediaWriteByType ( + IN FLASH_REGION_TYPE FlashRegionType, + IN UINT64 Address, + IN UINT32 ByteCount, + OUT UINT8 *Buffer + ); + /** Erase the data on the BootMedia. diff --git a/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c b/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c index e22d7484..896c1d6b 100644 --- a/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c +++ b/PayloadPkg/FirmwareUpdate/FirmwareUpdateHelper.c @@ -113,7 +113,7 @@ BootMediaReadByType ( } /** - This function writes blocks from the SPI device. + This function writes blocks to the SPI device. @param[in] Address The block address in the FlashRegionAll to read from on the SPI. @param[in] ByteCount Size of the Buffer in bytes. @@ -134,6 +134,31 @@ BootMediaWrite ( return mFwuSpiService->SpiWrite (FlashRegionBios, (UINT32)Address, ByteCount, Buffer); } +/** + This function writes blocks to the SPI device based on flash region type. + + @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor. + @param[in] Address The block address in the FlashRegionAll to read from on the SPI. + @param[in] ByteCount Size of the Buffer in bytes. + @param[out] Buffer Pointer to caller-allocated buffer containing the data received during the SPI cycle. + + @retval EFI_SUCCESS Write completes successfully. + @retval others Device error, the command aborts abnormally. + +**/ +EFI_STATUS +EFIAPI +BootMediaWriteByType ( + IN FLASH_REGION_TYPE FlashRegionType, + IN UINT64 Address, + IN UINT32 ByteCount, + OUT UINT8 *Buffer + ) +{ + return mFwuSpiService->SpiWrite (FlashRegionType, (UINT32)Address, ByteCount, Buffer); +} + + /** This function erases blocks from the SPI device. diff --git a/Silicon/ElkhartlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c b/Silicon/ElkhartlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c index beb6837c..51a8ed65 100644 --- a/Silicon/ElkhartlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c +++ b/Silicon/ElkhartlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c @@ -450,7 +450,7 @@ SetFlashDescriptorLock ( // // Write to flash descriptor master access region // - Status = BootMediaReadByType (FlashRegionDescriptor, (UINT32) B_FLASH_FMBA, sizeof(FlashDescMasterAccess), (UINT8 *) FlashDescMasterAccess); + Status = BootMediaWriteByType (FlashRegionDescriptor, (UINT32) B_FLASH_FMBA, sizeof(FlashDescMasterAccess), (UINT8 *) FlashDescMasterAccess); if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "SPI Lock write failed 0x%x\n", Status)); } diff --git a/Silicon/TigerlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c b/Silicon/TigerlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c index 8d6959a7..c617c25f 100644 --- a/Silicon/TigerlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c +++ b/Silicon/TigerlakePkg/Library/FirmwareUpdateLib/FirmwareUpdateLib.c @@ -459,7 +459,7 @@ SetFlashDescriptorLock ( // // Write to flash descriptor master access region // - Status = BootMediaReadByType (FlashRegionDescriptor, (UINT32) B_FLASH_FMBA, sizeof(FlashDescMasterAccess), (UINT8 *) FlashDescMasterAccess); + Status = BootMediaWriteByType (FlashRegionDescriptor, (UINT32) B_FLASH_FMBA, sizeof(FlashDescMasterAccess), (UINT8 *) FlashDescMasterAccess); if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "SPI Lock write failed 0x%x\n", Status)); }