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 33A3E94176C for ; Thu, 16 May 2024 15:18:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=pRQsj53NP06HE4pRqmBMmXHgdswa8kxueKWBAN4G4J4=; c=relaxed/simple; d=groups.io; h=Received-SPF:Authentication-Results-Original:Message-ID:Date:User-Agent:Subject:To:Cc:References:From:In-Reply-To:MIME-Version:NoDisclaimer:Original-Authentication-Results:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1715872688; v=1; b=bCmkNcEFLR1AZV95irzCdZ/qpJsY+JpEz3qU/OMYBiQjviPZSLUJ5rE79nKb4fJkj8syeinz zRDxWlKuDn6ps4GLOqxdbd8MNeaWiOzDSqRg6sho2TygWBczywCOGdaZQMAegLE6BVT7Me7JzyY 0Qu+XCOI+MASpa0N01vR0S/4UGnm4vGIQBUY7wCJ2VUPV3gvncT6knKzIDRWh/pcsaIE4vLx8zX AHjtlkfPfTVnHzqD8gCsizqwM7ZDA/LoTziYPuB+VK5w/kETiRgmQ1xbcjt8biQ9HwdYrJA/ARo c7MSh01zXkIGNPoGwnIx7w/15OJI6a7HwhE/MQLfMQ9Tg== X-Received: by 127.0.0.2 with SMTP id scxuYY7687511xenZJDOC9t5; Thu, 16 May 2024 08:18:08 -0700 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.53]) by mx.groups.io with SMTP id smtpd.web10.16697.1715872687346627802 for ; Thu, 16 May 2024 08:18:07 -0700 X-Received: from DB8PR03CA0010.eurprd03.prod.outlook.com (2603:10a6:10:be::23) by AS4PR08MB8119.eurprd08.prod.outlook.com (2603:10a6:20b:58b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Thu, 16 May 2024 15:18:02 +0000 X-Received: from DB1PEPF000509FA.eurprd03.prod.outlook.com (2603:10a6:10:be:cafe::20) by DB8PR03CA0010.outlook.office365.com (2603:10a6:10:be::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28 via Frontend Transport; Thu, 16 May 2024 15:18:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB1PEPF000509FA.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Thu, 16 May 2024 15:18:02 +0000 X-Received: ("Tessian outbound b7675f20d34d:v315"); Thu, 16 May 2024 15:18:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4fb1cf3002b60585 X-CR-MTA-TID: 64aa7808 X-Received: from 177db59601d4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AB66F43C-B492-44AE-935E-220C22B3EA52.1; Thu, 16 May 2024 15:17:55 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 177db59601d4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 16 May 2024 15:17:55 +0000 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by DB8PR08MB5339.eurprd08.prod.outlook.com (2603:10a6:10:114::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 15:17:53 +0000 X-Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::1e13:dc65:224e:219c]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::1e13:dc65:224e:219c%5]) with mapi id 15.20.7587.028; Thu, 16 May 2024 15:17:53 +0000 Message-ID: <671f4b3b-7ae8-49db-9e6e-91916af9991e@arm.com> Date: Thu, 16 May 2024 16:17:50 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH RESEND edk2-platforms][PATCH V2 04/14] Platform/ARM/NorFlashDxe: Move flash specific functions to NorFlash.c To: Sahil Kaushal , devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , sahil , "nd@arm.com" References: <20240423055638.1271531-1-Sahil.Kaushal@arm.com> <20240423055638.1271531-5-Sahil.Kaushal@arm.com> From: "Sami Mujawar" In-Reply-To: <20240423055638.1271531-5-Sahil.Kaushal@arm.com> X-ClientProxiedBy: LO2P265CA0379.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::31) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|DB8PR08MB5339:EE_|DB1PEPF000509FA:EE_|AS4PR08MB8119:EE_ X-MS-Office365-Filtering-Correlation-Id: 95331c47-a2c8-4447-efd6-08dc75bb60a7 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230031|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?d2tPSitqRn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SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5339 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509FA.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a81120d1-55c0-43f1-6d49-08dc75bb5ba4 X-Microsoft-Antispam-Message-Info: =?utf-8?B?aDEyUCs2eWtQNm9wQ2tBSm1NSURyVkhsd0ViTTU2cVA0MWtLWFA4NDBZWkVV?= =?utf-8?B?elJEUDlQWFFudGtONmx2LzkyVTVrYnZHbmo0NlpPUDRzV3lFNkIyZlEwLytz?= =?utf-8?B?R1N5QldCb2NXVHBYYUJxQyt2dW1weGNFampMWnZTUVUyUVd6SXB1QVNEQ0dG?= =?utf-8?B?ckQ5NGIwM2F2TTM4RGFSZStVa1lObHYwUHFCRnozMmZBb3hIT0pjczVIQTNy?= =?utf-8?B?WDN0UUwyTzVOQTZMNVhuTmF5a2ljSm9Ib2svaWtBRVV6V1g0Y3dXTEh6T1Fh?= =?utf-8?B?MW9OOXlmTVNvQ05paEo3MUxENDY3QkZnSXJJbVlvd3doV2x0Zm9lRjI0N3l6?= =?utf-8?B?MzZObnYwRE4xNUllQkJnU0FwaXNkMWlVNENwNGVXZlpDYUdBWFVMVG02RXJp?= =?utf-8?B?UCtYbmtYb0VKdXkzQ3dGTEs2RVk4R3JkbW5OMUpqdmhWZElQVkFHZkdFVHpr?= =?utf-8?B?M0F1QmU0eGJoWFJMa0xZWmNKa0dFSFA5cUtSWEllQjdxK3Y3UTFrRDZPK2c2?= =?utf-8?B?Qlh4dGpwazB0ZFVHREtnejNLekFSeVBhQllOd3ZmMGZZRXRnWUdzcjNia0x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ESUdBVC9BRUVsYzUwUjlR?= =?utf-8?B?b21LSkRaY2hMdXUrL0RXY0xVV0t1ckQ0UHhKM2ovbjRuTWltT1lCTy9qcGsv?= =?utf-8?B?bk9RQ0NwK2VvY3Rnd2hwVndFb1p0ekhqK0JjcG5IcDFPWFpSaFJoMjl6K0lP?= =?utf-8?B?ZExaQk5lOVZmQk41bFU0WXc2dVB5N2pnLzNWYk5aVmQ5bEY5OEx6Z0tYVXhm?= =?utf-8?B?ZlBjbkpXQkM0dGVkSVNkUlk5Q1pvYTh6d1VIa0VMOHQ1d05JNG1Tdmhocnkv?= =?utf-8?B?WmhLSGJuOGdwRUJPc3dqVXZvRGRrMnJBOHZOM0ZidFBQc1dqM0Z3VkZjcml6?= =?utf-8?Q?mGi7v5/UhRyaekyTnt2KdMi2yB5pqaN3axHPw=3D?= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 15:18:02.0720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95331c47-a2c8-4447-efd6-08dc75bb60a7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509FA.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8119 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: Thu, 16 May 2024 08:18:07 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rrksYmM3kM1TEX5tOIhivXBVx7686176AA= Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed 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=bCmkNcEF; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Sahil, Thank you for this patch. These changes look good to me. Reviewed-by: Sami Mujawar Regards, Sami Mujawar On 23/04/2024 06:56 am, Sahil Kaushal wrote: > 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 > > + ) > > +{ > > +} > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118960): https://edk2.groups.io/g/devel/message/118960 Mute This Topic: https://groups.io/mt/105690939/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-