From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id CEA06D8027A for ; Wed, 29 May 2024 08:55:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=rHCjcKfMhlsheD270TZnqdU7MksEA7vIiBNUkcBHma4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1716972937; v=1; b=GNXjQ7EV7HTh+BAAgSL2l/OrwC7S9aVKagoDi0j5P4RkyYbGT98x+Zp6tIT6Q+KhKWG7aYQ+ DpT072AEqbcR7eMEPT//wAdoGlqHM1XACBl4NMZ8oa+Vl5g6Brh6MqsfEFd1HsD7I2msx/SBsIG 07W7XYAAEn9NBjxeEoQ7xgHOJjxMuyCKuhx3ipLFm8iysAzEXaAqj9BKa+JeLjbbRS87EGZfnLo MuVq0cVIq89nJilMtBz32BWc25poDkZ0Oq2WBXMGWSxQyQa943YHzYPCFxp+8C5GbX8/DltfMVX Adlvxg1JP3EBfKyRw0cwIX0DK+s1q5QcyCr7Cks60ORLQ== X-Received: by 127.0.0.2 with SMTP id CLguYY7687511xod46P1Ba8J; Wed, 29 May 2024 01:55:36 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.9243.1716972935886140552 for ; Wed, 29 May 2024 01:55:36 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C59A72F4; Wed, 29 May 2024 01:55:59 -0700 (PDT) X-Received: from usa.arm.com (a077434.arm.com [10.162.46.143]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E15643F762; Wed, 29 May 2024 01:55:33 -0700 (PDT) From: "Sahil Kaushal" To: devel@edk2.groups.io Cc: Ard Biesheuvel , =?UTF-8?q?Leif=20Lindholm=20=C2=A0?= , Sami Mujawar , =?UTF-8?q?sahil=20=C2=A0?= Subject: [edk2-devel] [edk2-platforms][PATCH V4 04/17] Platform/ARM/NorFlashDxe: Move flash specific functions to NorFlash.c Date: Wed, 29 May 2024 14:25:04 +0530 Message-Id: <20240529085517.1074417-5-Sahil.Kaushal@arm.com> In-Reply-To: <20240529085517.1074417-1-Sahil.Kaushal@arm.com> References: <20240529085517.1074417-1-Sahil.Kaushal@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 29 May 2024 01:55:36 -0700 Resent-From: sahil.kaushal@arm.com Reply-To: devel@edk2.groups.io,sahil.kaushal@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: DO1o0lFDnjqIAeKnLRTlrhd3x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=GNXjQ7EV; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) From: sahil Refactoring done in this patch has two major parts: 1. Moving out NorFlashUnlockAndEraseSingleBlock and NorFlashWriteFullBlock functions from NorFlashDxe.c and NorFlashStandaloneMm.c to NorFlash.c files. 2. At the same time, we are adding NorFlashLock and NorFlashUnlock functions which will take care of TPL related operations needed by functions mentioned in point 1. These functions are implemented in NorFlashDxe.c but are just dummy placeholder functions in NorFlashStandaloneMm.c file. Signed-off-by: sahil --- Platform/ARM/Drivers/NorFlashDxe/NorFlash.h | 26 +++ Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h | 14 -- Platform/ARM/Drivers/NorFlashDxe/NorFlash.c | 136 ++++++++++= +++- Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c | 193 ++++------= ---------- Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c | 151 +++-------= ----- 5 files changed, 225 insertions(+), 295 deletions(-) diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h b/Platform/ARM/D= rivers/NorFlashDxe/NorFlash.h index e0ebb1e2fd35..bd5c6a949cf0 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h @@ -220,4 +220,30 @@ NorFlashWriteSingleWord ( IN UINT32 WriteData ); =20 +EFI_STATUS +NorFlashWriteFullBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINT32 *DataBuffer, + IN UINT32 BlockSizeInWords + ); + +EFI_STATUS +NorFlashUnlockAndEraseSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ); + +VOID +EFIAPI +NorFlashLock ( + IN EFI_TPL *OriginalTPL + ); + +VOID +EFIAPI +NorFlashUnlock ( + IN EFI_TPL OriginalTPL + ); + #endif /* __NOR_FLASH_H__ */ diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h b/Platform= /ARM/Drivers/NorFlashDxe/NorFlashCommon.h index e329e0727617..c0a3b5861532 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h @@ -31,20 +31,6 @@ // // NorFlashDxe.c // -EFI_STATUS -NorFlashWriteFullBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN EFI_LBA Lba, - IN UINT32 *DataBuffer, - IN UINT32 BlockSizeInWords - ); - -EFI_STATUS -NorFlashUnlockAndEraseSingleBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN UINTN BlockAddress - ); - EFI_STATUS NorFlashCreateInstance ( IN UINTN NorFlashDeviceBase, diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c b/Platform/ARM/D= rivers/NorFlashDxe/NorFlash.c index 4e5a97c83c7b..15000a692b02 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c @@ -10,7 +10,6 @@ #include =20 #include "NorFlash.h" -#include "NorFlashCommon.h" =20 // // Global variable declarations @@ -817,3 +816,138 @@ NorFlashReset ( SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); return EFI_SUCCESS; } + +/** + * This function unlock and erase an entire NOR Flash block. +**/ +EFI_STATUS +NorFlashUnlockAndEraseSingleBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN UINTN BlockAddress + ) +{ + EFI_STATUS Status; + UINTN Index; + EFI_TPL OriginalTPL; + + NorFlashLock (&OriginalTPL); + + Index =3D 0; + // The block erase might fail a first time (SW bug ?). Retry it ... + do { + // Unlock the block if we have to + Status =3D NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddr= ess); + if (EFI_ERROR (Status)) { + break; + } + + Status =3D NorFlashEraseSingleBlock (Instance, BlockAddress); + Index++; + } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status =3D=3D EFI_WRITE_P= ROTECTED)); + + if (Index =3D=3D NOR_FLASH_ERASE_RETRY) { + DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=3D0x%08x: Block = Locked Error (try to erase %d times)\n", BlockAddress, Index)); + } + + NorFlashUnlock (OriginalTPL); + + return Status; +} + +EFI_STATUS +NorFlashWriteFullBlock ( + IN NOR_FLASH_INSTANCE *Instance, + IN EFI_LBA Lba, + IN UINT32 *DataBuffer, + IN UINT32 BlockSizeInWords + ) +{ + EFI_STATUS Status; + UINTN WordAddress; + UINT32 WordIndex; + UINTN BufferIndex; + UINTN BlockAddress; + UINTN BuffersInBlock; + UINTN RemainingWords; + EFI_TPL OriginalTPL; + UINTN Cnt; + + Status =3D EFI_SUCCESS; + + // Get the physical address of the block + BlockAddress =3D GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, L= ba, BlockSizeInWords * 4); + + // Start writing from the first address at the start of the block + WordAddress =3D BlockAddress; + + NorFlashLock (&OriginalTPL); + + Status =3D NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and= Erase the single block at 0x%X\n", BlockAddress)); + goto EXIT; + } + + // To speed up the programming operation, NOR Flash is programmed usin= g the Buffered Programming method. + + // Check that the address starts at a 32-word boundary, i.e. last 7 bi= ts must be zero + if ((WordAddress & BOUNDARY_OF_32_WORDS) =3D=3D 0x00) { + // First, break the entire block into buffer-sized chunks. + BuffersInBlock =3D (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SI= ZE_IN_BYTES; + + // Then feed each buffer chunk to the NOR Flash + // If a buffer does not contain any data, don't write it. + for (BufferIndex =3D 0; + BufferIndex < BuffersInBlock; + BufferIndex++, WordAddress +=3D P30_MAX_BUFFER_SIZE_IN_BYTES, D= ataBuffer +=3D P30_MAX_BUFFER_SIZE_IN_WORDS + ) + { + // Check the buffer to see if it contains any data (not set all 1s= ). + for (Cnt =3D 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) { + if (~DataBuffer[Cnt] !=3D 0 ) { + // Some data found, write the buffer. + Status =3D NorFlashWriteBuffer ( + Instance, + WordAddress, + P30_MAX_BUFFER_SIZE_IN_BYTES, + DataBuffer + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } + + break; + } + } + } + + // Finally, finish off any remaining words that are less than the ma= ximum size of the buffer + RemainingWords =3D BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS; + + if (RemainingWords !=3D 0) { + Status =3D NorFlashWriteBuffer (Instance, WordAddress, (RemainingW= ords * 4), DataBuffer); + if (EFI_ERROR (Status)) { + goto EXIT; + } + } + } else { + // For now, use the single word programming algorithm + // It is unlikely that the NOR Flash will exist in an address which = falls within a 32 word boundary range, + // i.e. which ends in the range 0x......01 - 0x......7F. + for (WordIndex =3D 0; WordIndex < BlockSizeInWords; WordIndex++, Dat= aBuffer++, WordAddress =3D WordAddress + 4) { + Status =3D NorFlashWriteSingleWord (Instance, WordAddress, *DataBu= ffer); + if (EFI_ERROR (Status)) { + goto EXIT; + } + } + } + +EXIT: + NorFlashUnlock (OriginalTPL); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] faile= d at address 0x%08x. Exit Status =3D \"%r\".\n", WordAddress, Status)); + } + + return Status; +} diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c b/Platform/AR= M/Drivers/NorFlashDxe/NorFlashDxe.c index b1e01169c24e..4bad6e9b2a6b 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c @@ -174,161 +174,6 @@ NorFlashCreateInstance ( return Status; } =20 -/** - * This function unlock and erase an entire NOR Flash block. - **/ -EFI_STATUS -NorFlashUnlockAndEraseSingleBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN UINTN BlockAddress - ) -{ - EFI_STATUS Status; - UINTN Index; - EFI_TPL OriginalTPL; - - if (!EfiAtRuntime ()) { - // Raise TPL to TPL_HIGH to stop anyone from interrupting us. - OriginalTPL =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); - } else { - // This initialization is only to prevent the compiler to complain a= bout the - // use of uninitialized variables - OriginalTPL =3D TPL_HIGH_LEVEL; - } - - Index =3D 0; - // The block erase might fail a first time (SW bug ?). Retry it ... - do { - // Unlock the block if we have to - Status =3D NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddr= ess); - if (EFI_ERROR (Status)) { - break; - } - - Status =3D NorFlashEraseSingleBlock (Instance, BlockAddress); - Index++; - } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status =3D=3D EFI_WRITE_P= ROTECTED)); - - if (Index =3D=3D NOR_FLASH_ERASE_RETRY) { - DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=3D0x%08x: Block = Locked Error (try to erase %d times)\n", BlockAddress, Index)); - } - - if (!EfiAtRuntime ()) { - // Interruptions can resume. - gBS->RestoreTPL (OriginalTPL); - } - - return Status; -} - -EFI_STATUS -NorFlashWriteFullBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN EFI_LBA Lba, - IN UINT32 *DataBuffer, - IN UINT32 BlockSizeInWords - ) -{ - EFI_STATUS Status; - UINTN WordAddress; - UINT32 WordIndex; - UINTN BufferIndex; - UINTN BlockAddress; - UINTN BuffersInBlock; - UINTN RemainingWords; - EFI_TPL OriginalTPL; - UINTN Cnt; - - Status =3D EFI_SUCCESS; - - // Get the physical address of the block - BlockAddress =3D GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, L= ba, BlockSizeInWords * 4); - - // Start writing from the first address at the start of the block - WordAddress =3D BlockAddress; - - if (!EfiAtRuntime ()) { - // Raise TPL to TPL_HIGH to stop anyone from interrupting us. - OriginalTPL =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); - } else { - // This initialization is only to prevent the compiler to complain a= bout the - // use of uninitialized variables - OriginalTPL =3D TPL_HIGH_LEVEL; - } - - Status =3D NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and= Erase the single block at 0x%X\n", BlockAddress)); - goto EXIT; - } - - // To speed up the programming operation, NOR Flash is programmed usin= g the Buffered Programming method. - - // Check that the address starts at a 32-word boundary, i.e. last 7 bi= ts must be zero - if ((WordAddress & BOUNDARY_OF_32_WORDS) =3D=3D 0x00) { - // First, break the entire block into buffer-sized chunks. - BuffersInBlock =3D (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SI= ZE_IN_BYTES; - - // Then feed each buffer chunk to the NOR Flash - // If a buffer does not contain any data, don't write it. - for (BufferIndex =3D 0; - BufferIndex < BuffersInBlock; - BufferIndex++, WordAddress +=3D P30_MAX_BUFFER_SIZE_IN_BYTES, D= ataBuffer +=3D P30_MAX_BUFFER_SIZE_IN_WORDS - ) - { - // Check the buffer to see if it contains any data (not set all 1s= ). - for (Cnt =3D 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) { - if (~DataBuffer[Cnt] !=3D 0 ) { - // Some data found, write the buffer. - Status =3D NorFlashWriteBuffer ( - Instance, - WordAddress, - P30_MAX_BUFFER_SIZE_IN_BYTES, - DataBuffer - ); - if (EFI_ERROR (Status)) { - goto EXIT; - } - - break; - } - } - } - - // Finally, finish off any remaining words that are less than the ma= ximum size of the buffer - RemainingWords =3D BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS; - - if (RemainingWords !=3D 0) { - Status =3D NorFlashWriteBuffer (Instance, WordAddress, (RemainingW= ords * 4), DataBuffer); - if (EFI_ERROR (Status)) { - goto EXIT; - } - } - } else { - // For now, use the single word programming algorithm - // It is unlikely that the NOR Flash will exist in an address which = falls within a 32 word boundary range, - // i.e. which ends in the range 0x......01 - 0x......7F. - for (WordIndex =3D 0; WordIndex < BlockSizeInWords; WordIndex++, Dat= aBuffer++, WordAddress =3D WordAddress + 4) { - Status =3D NorFlashWriteSingleWord (Instance, WordAddress, *DataBu= ffer); - if (EFI_ERROR (Status)) { - goto EXIT; - } - } - } - -EXIT: - if (!EfiAtRuntime ()) { - // Interruptions can resume. - gBS->RestoreTPL (OriginalTPL); - } - - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] faile= d at address 0x%08x. Exit Status =3D \"%r\".\n", WordAddress, Status)); - } - - return Status; -} - EFI_STATUS EFIAPI NorFlashInitialise ( @@ -549,3 +394,41 @@ NorFlashVirtualNotifyEvent ( =20 return; } + +/** + Lock all pending read/write to Nor flash device + + @param[in] *OriginalTPL Pointer to Nor flash device Original T= PL. +**/ +VOID +EFIAPI +NorFlashLock ( + IN EFI_TPL *OriginalTPL + ) +{ + if (!EfiAtRuntime ()) { + // Raise TPL to TPL_HIGH to stop anyone from interrupting us. + *OriginalTPL =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); + } else { + // This initialization is only to prevent the compiler to complain a= bout the + // use of uninitialized variables + *OriginalTPL =3D TPL_HIGH_LEVEL; + } +} + +/** + Unlock all pending read/write to Nor flash device + + @param[in] OriginalTPL Nor flash device Original TPL. +**/ +VOID +EFIAPI +NorFlashUnlock ( + IN EFI_TPL OriginalTPL + ) +{ + if (!EfiAtRuntime ()) { + // Interruptions can resume. + gBS->RestoreTPL (OriginalTPL); + } +} diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c b/Pl= atform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c index f2919265139b..5bff524e5e18 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c @@ -153,131 +153,6 @@ NorFlashCreateInstance ( return Status; } =20 -/** - * This function unlock and erase an entire NOR Flash block. - **/ -EFI_STATUS -NorFlashUnlockAndEraseSingleBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN UINTN BlockAddress - ) -{ - EFI_STATUS Status; - UINTN Index; - - Index =3D 0; - // The block erase might fail a first time (SW bug ?). Retry it ... - do { - // Unlock the block if we have to - Status =3D NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddr= ess); - if (EFI_ERROR (Status)) { - break; - } - - Status =3D NorFlashEraseSingleBlock (Instance, BlockAddress); - Index++; - } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status =3D=3D EFI_WRITE_P= ROTECTED)); - - if (Index =3D=3D NOR_FLASH_ERASE_RETRY) { - DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=3D0x%08x: Block = Locked Error (try to erase %d times)\n", BlockAddress, Index)); - } - - return Status; -} - -EFI_STATUS -NorFlashWriteFullBlock ( - IN NOR_FLASH_INSTANCE *Instance, - IN EFI_LBA Lba, - IN UINT32 *DataBuffer, - IN UINT32 BlockSizeInWords - ) -{ - EFI_STATUS Status; - UINTN WordAddress; - UINT32 WordIndex; - UINTN BufferIndex; - UINTN BlockAddress; - UINTN BuffersInBlock; - UINTN RemainingWords; - UINTN Cnt; - - Status =3D EFI_SUCCESS; - - // Get the physical address of the block - BlockAddress =3D GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, L= ba, BlockSizeInWords * 4); - - // Start writing from the first address at the start of the block - WordAddress =3D BlockAddress; - - Status =3D NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and= Erase the single block at 0x%X\n", BlockAddress)); - goto EXIT; - } - - // To speed up the programming operation, NOR Flash is programmed usin= g the Buffered Programming method. - - // Check that the address starts at a 32-word boundary, i.e. last 7 bi= ts must be zero - if ((WordAddress & BOUNDARY_OF_32_WORDS) =3D=3D 0x00) { - // First, break the entire block into buffer-sized chunks. - BuffersInBlock =3D (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SI= ZE_IN_BYTES; - - // Then feed each buffer chunk to the NOR Flash - // If a buffer does not contain any data, don't write it. - for (BufferIndex =3D 0; - BufferIndex < BuffersInBlock; - BufferIndex++, WordAddress +=3D P30_MAX_BUFFER_SIZE_IN_BYTES, D= ataBuffer +=3D P30_MAX_BUFFER_SIZE_IN_WORDS - ) - { - // Check the buffer to see if it contains any data (not set all 1s= ). - for (Cnt =3D 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) { - if (~DataBuffer[Cnt] !=3D 0 ) { - // Some data found, write the buffer. - Status =3D NorFlashWriteBuffer ( - Instance, - WordAddress, - P30_MAX_BUFFER_SIZE_IN_BYTES, - DataBuffer - ); - if (EFI_ERROR (Status)) { - goto EXIT; - } - - break; - } - } - } - - // Finally, finish off any remaining words that are less than the ma= ximum size of the buffer - RemainingWords =3D BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS; - - if (RemainingWords !=3D 0) { - Status =3D NorFlashWriteBuffer (Instance, WordAddress, (RemainingW= ords * 4), DataBuffer); - if (EFI_ERROR (Status)) { - goto EXIT; - } - } - } else { - // For now, use the single word programming algorithm - // It is unlikely that the NOR Flash will exist in an address which = falls within a 32 word boundary range, - // i.e. which ends in the range 0x......01 - 0x......7F. - for (WordIndex =3D 0; WordIndex < BlockSizeInWords; WordIndex++, Dat= aBuffer++, WordAddress =3D WordAddress + 4) { - Status =3D NorFlashWriteSingleWord (Instance, WordAddress, *DataBu= ffer); - if (EFI_ERROR (Status)) { - goto EXIT; - } - } - } - -EXIT: - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] faile= d at address 0x%08x. Exit Status =3D \"%r\".\n", WordAddress, Status)); - } - - return Status; -} - EFI_STATUS EFIAPI NorFlashInitialise ( @@ -382,3 +257,29 @@ NorFlashFvbInitialize ( =20 return Status; } + +/** + Lock all pending read/write to Nor flash device + + @param[in] OriginalTPL Nor flash device Original TPL. +**/ +VOID +EFIAPI +NorFlashLock ( + IN EFI_TPL *OriginalTPL + ) +{ +} + +/** + Unlock all pending read/write to Nor flash device + + @param[in] OriginalTPL Nor flash device Original TPL. +**/ +VOID +EFIAPI +NorFlashUnlock ( + IN EFI_TPL OriginalTPL + ) +{ +} --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119319): https://edk2.groups.io/g/devel/message/119319 Mute This Topic: https://groups.io/mt/106365454/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-