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 C09A578003C for ; Thu, 16 May 2024 15:17:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Kr/tzhSol2brs1OVGwj4bdfrUxe2uV3jbVLB+M7Cr94=; 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=1715872656; v=1; b=eA3KTJ1FNoG21cYXSrdBSxE2z2/jTYnTp/1VuvjvmzWS+H+6PjsVAlCHKEKDZ/3ik/38eNbl ii0KEBArMy1zCgSmo5+iD5sPckQ4PR1Zq2ssv9ZMTLZFT5aSThTsC9IF1ZZKNasskqODn5xqNaS y4dpUr1o73vvZGpiREGls19e1YHG0M0rnbQLK01zb4HGsOoprVLsm0/4E2L5wckKbaBEb9f2BwL zAs957s8XVVwaK1AwErgZl8Yu3mLQhSpaB6zX1qobgyHjz4OXCU7qIiLv6JYhY+JvyLcqNWKgiu Yq9LNY9b/PusKZYUl4/ZmGo5xeee22wMGk3SAhhKnU6oA== X-Received: by 127.0.0.2 with SMTP id rygKYY7687511xQ3xmysdjv9; Thu, 16 May 2024 08:17:35 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.61]) by mx.groups.io with SMTP id smtpd.web10.16678.1715872654694337476 for ; Thu, 16 May 2024 08:17:35 -0700 X-Received: from DU2PR04CA0340.eurprd04.prod.outlook.com (2603:10a6:10:2b4::12) by VI0PR08MB10760.eurprd08.prod.outlook.com (2603:10a6:800:20d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Thu, 16 May 2024 15:17:28 +0000 X-Received: from DB5PEPF00014B91.eurprd02.prod.outlook.com (2603:10a6:10:2b4:cafe::5b) by DU2PR04CA0340.outlook.office365.com (2603:10a6:10:2b4::12) 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:17:28 +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 DB5PEPF00014B91.mail.protection.outlook.com (10.167.8.229) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7587.21 via Frontend Transport; Thu, 16 May 2024 15:17:28 +0000 X-Received: ("Tessian outbound 082664cc04c1:v315"); Thu, 16 May 2024 15:17:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bf60e033bad12c52 X-CR-MTA-TID: 64aa7808 X-Received: from 334d8e2103a4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CB8B0497-9792-40F8-B962-EABB7F90458F.1; Thu, 16 May 2024 15:17:21 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 334d8e2103a4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 16 May 2024 15:17:21 +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:18 +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:18 +0000 Message-ID: <120e1da7-d461-425a-922f-2d03a10e1d64@arm.com> Date: Thu, 16 May 2024 16:17:17 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH RESEND edk2-platforms][PATCH V2 01/14] Platform/ARM/NorFlashDxe: Move DiskIo related functions out of 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-2-Sahil.Kaushal@arm.com> From: "Sami Mujawar" In-Reply-To: <20240423055638.1271531-2-Sahil.Kaushal@arm.com> X-ClientProxiedBy: LO2P265CA0350.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:d::26) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|DB8PR08MB5339:EE_|DB5PEPF00014B91:EE_|VI0PR08MB10760:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dea8ca4-d479-4b4e-7a1d-08dc75bb4c60 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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RY:;LANG:en;SCL:1;SRV:;IPV:NLI;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: DB5PEPF00014B91.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f5c107da-c8d9-4560-24b7-08dc75bb46bd X-Microsoft-Antispam-Message-Info: =?utf-8?B?eGJ3YzNwZVhPTkRQNmNWUWRpVys0UzFFZGovcG5lNUFwc3JjNm1WdXNOcXcr?= =?utf-8?B?a2JoVGp3ZndaYTd2WmVqbkljY1FHeTErR2lPaEdOLzY3ZGhXbDVWOVZ5SWM2?= =?utf-8?B?dHVXMnppb2tSNS9DVWF5aDN1M3RKd3AxSVN0RytnY3g5V0ZPdEQ2cXlBK3Rj?= =?utf-8?B?azREaXd0cWwrV0MwUDNGQ2lWNUJCcWJlU0NEYkg4eUk4NzE1L2R4UG1TaXVL?= =?utf-8?B?MmZrQW13M2NzV0JZSVhwZDZTblNYTXA5cjF5bXUyZjZRWHdHTXhscnFpQ1lk?= =?utf-8?B?MU5YQ3hmOVhicmwzWEMzUDZlbzVWYkhsZHRDcWpOdHoxNlBSamdDdE9TNms2?= =?utf-8?B?NUFnVkJzOG5UcXRPM3VWUGlwbWhFS0NLeTlyYXhrWmxJT0lwQmJUL2ltTEF4?= =?utf-8?B?RlNZaytKSDBHVzdUcFhnaTVjdjI2dGFLUEZyY21TcWRpZmtDMnhlKzRWeE4w?= =?utf-8?B?bmFlMzRyb3NvampuVjdEOEpUTTBYYVIwUHRZcVA1WVN2eWFRL3FxWEJlUlk1?= =?utf-8?B?T1hyRDRFemRBdS9vRmJyeU1PY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FM3dVczBIVktPU2tIY2d3NHYrODYwSFc4aTA0aVBEdlUweVRtc3dq?= =?utf-8?B?S04ydFNRSWNDWHFpbk5QSmVOZC85cm9DdTkvaTZMb2c2THVPNTVRZXptQnZY?= =?utf-8?B?ZFFzQnlvckQ2c0g4RXVONnFrYWFRMVZ2UzZLSjB5a0FpWUdpd1BFVmR2YTF6?= =?utf-8?B?Zm05U3VzcnB5bVpYRHlDYkkwRDdtTWxaVzdnNVo2YmpPa0RkRHhOUXFnbGNS?= =?utf-8?B?TDZUdlFKMS9QYVdvSnZ3NkJjeC9UOForRzB1K1V0ZFhMSDZvcHZpTGRoUFhh?= =?utf-8?B?OUU5NXpVaW83UjF4Szh0N0Fma2lBSG94YUV6UldUNzNib0NDYi81VTlGZktT?= =?utf-8?B?bmRhQTZ5UXBBVVNFeVVhUFQ2NVg0eHFIei96VjUrQzlaZDZCRXZCdzNwZERG?= =?utf-8?Q?Oj639lkapfLw7?= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 15:17:28.0493 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dea8ca4-d479-4b4e-7a1d-08dc75bb4c60 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: DB5PEPF00014B91.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB10760 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:17:35 -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: ootdeRfnSpAmZOaVyJAAXc3Yx7686176AA= 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=eA3KTJ1F; 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 > > Moving these functions from NorFlash.c to NorFlashBlockIoDxe.c as > they are not dependent on any particular flash implementation. > > Signed-off-by: sahil > --- > Platform/ARM/Drivers/NorFlashDxe/NorFlash.c | 129 -----------= --------- > Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c | 129 +++++++++++= +++++++++ > 2 files changed, 129 insertions(+), 129 deletions(-) > > diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c b/Platform/ARM/D= rivers/NorFlashDxe/NorFlash.c > index 1b431073ee93..60854ef2a7d0 100644 > --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c > +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlash.c > @@ -807,135 +807,6 @@ NorFlashWriteSingleBlock ( > return EFI_SUCCESS; > > } > > =20 > > -/* > > - Although DiskIoDxe will automatically install the DiskIO protocol when= ever > > - we install the BlockIO protocol, its implementation is sub-optimal as = it reads > > - and writes entire blocks using the BlockIO protocol. In fact we can ac= cess > > - NOR flash with a finer granularity than that, so we can improve perfor= mance > > - by directly producing the DiskIO protocol. > > -*/ > > - > > -/** > > - Read BufferSize bytes from Offset into Buffer. > > - > > - @param This Protocol instance pointer. > > - @param MediaId Id of the media, changes every time the = media is replaced. > > - @param Offset The starting byte offset to read from > > - @param BufferSize Size of Buffer > > - @param Buffer Buffer containing read data > > - > > - @retval EFI_SUCCESS The data was read correctly from the dev= ice. > > - @retval EFI_DEVICE_ERROR The device reported an error while perfo= rming the read. > > - @retval EFI_NO_MEDIA There is no media in the device. > > - @retval EFI_MEDIA_CHANGED The MediaId does not match the current d= evice. > > - @retval EFI_INVALID_PARAMETER The read request contains device address= es that are not > > - valid for the device. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -NorFlashDiskIoReadDisk ( > > - IN EFI_DISK_IO_PROTOCOL *This, > > - IN UINT32 MediaId, > > - IN UINT64 DiskOffset, > > - IN UINTN BufferSize, > > - OUT VOID *Buffer > > - ) > > -{ > > - NOR_FLASH_INSTANCE *Instance; > > - UINT32 BlockSize; > > - UINT32 BlockOffset; > > - EFI_LBA Lba; > > - > > - Instance =3D INSTANCE_FROM_DISKIO_THIS (This); > > - > > - if (MediaId !=3D Instance->Media.MediaId) { > > - return EFI_MEDIA_CHANGED; > > - } > > - > > - BlockSize =3D Instance->Media.BlockSize; > > - Lba =3D (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &Blo= ckOffset); > > - > > - return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer); > > -} > > - > > -/** > > - Writes a specified number of bytes to a device. > > - > > - @param This Indicates a pointer to the calling context. > > - @param MediaId ID of the medium to be written. > > - @param Offset The starting byte offset on the logical block I/O d= evice to write. > > - @param BufferSize The size in bytes of Buffer. The number of bytes to= write to the device. > > - @param Buffer A pointer to the buffer containing the data to be w= ritten. > > - > > - @retval EFI_SUCCESS The data was written correctly to the de= vice. > > - @retval EFI_WRITE_PROTECTED The device can not be written to. > > - @retval EFI_DEVICE_ERROR The device reported an error while perfo= rming the write. > > - @retval EFI_NO_MEDIA There is no media in the device. > > - @retval EFI_MEDIA_CHANGED The MediaId does not match the current d= evice. > > - @retval EFI_INVALID_PARAMETER The write request contains device addres= ses that are not > > - valid for the device. > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -NorFlashDiskIoWriteDisk ( > > - IN EFI_DISK_IO_PROTOCOL *This, > > - IN UINT32 MediaId, > > - IN UINT64 DiskOffset, > > - IN UINTN BufferSize, > > - IN VOID *Buffer > > - ) > > -{ > > - NOR_FLASH_INSTANCE *Instance; > > - UINT32 BlockSize; > > - UINT32 BlockOffset; > > - EFI_LBA Lba; > > - UINTN RemainingBytes; > > - UINTN WriteSize; > > - EFI_STATUS Status; > > - > > - Instance =3D INSTANCE_FROM_DISKIO_THIS (This); > > - > > - if (MediaId !=3D Instance->Media.MediaId) { > > - return EFI_MEDIA_CHANGED; > > - } > > - > > - BlockSize =3D Instance->Media.BlockSize; > > - Lba =3D (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &Blo= ckOffset); > > - > > - RemainingBytes =3D BufferSize; > > - > > - // Write either all the remaining bytes, or the number of bytes that b= ring > > - // us up to a block boundary, whichever is less. > > - // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the nex= t > > - // block boundary (even if it is already on one). > > - WriteSize =3D MIN (RemainingBytes, ((DiskOffset | (BlockSize - 1)) + 1= ) - DiskOffset); > > - > > - do { > > - if (WriteSize =3D=3D BlockSize) { > > - // Write a full block > > - Status =3D NorFlashWriteFullBlock (Instance, Lba, Buffer, BlockSiz= e / sizeof (UINT32)); > > - } else { > > - // Write a partial block > > - Status =3D NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &= WriteSize, Buffer); > > - } > > - > > - if (EFI_ERROR (Status)) { > > - return Status; > > - } > > - > > - // Now continue writing either all the remaining bytes or single blo= cks. > > - RemainingBytes -=3D WriteSize; > > - Buffer =3D (UINT8 *)Buffer + WriteSize; > > - Lba++; > > - BlockOffset =3D 0; > > - WriteSize =3D MIN (RemainingBytes, BlockSize); > > - } while (RemainingBytes); > > - > > - return Status; > > -} > > - > > EFI_STATUS > > NorFlashReset ( > > IN NOR_FLASH_INSTANCE *Instance > > diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c b/Plat= form/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c > index 9d4732c6905a..9b8c76a171d4 100644 > --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c > +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c > @@ -121,3 +121,132 @@ NorFlashBlockIoFlushBlocks ( > // Nothing to do so just return without error > > return EFI_SUCCESS; > > } > > + > > +/* > > + Although DiskIoDxe will automatically install the DiskIO protocol when= ever > > + we install the BlockIO protocol, its implementation is sub-optimal as = it reads > > + and writes entire blocks using the BlockIO protocol. In fact we can ac= cess > > + NOR flash with a finer granularity than that, so we can improve perfor= mance > > + by directly producing the DiskIO protocol. > > +*/ > > + > > +/** > > + Read BufferSize bytes from Offset into Buffer. > > + > > + @param This Protocol instance pointer. > > + @param MediaId Id of the media, changes every time the = media is replaced. > > + @param Offset The starting byte offset to read from > > + @param BufferSize Size of Buffer > > + @param Buffer Buffer containing read data > > + > > + @retval EFI_SUCCESS The data was read correctly from the dev= ice. > > + @retval EFI_DEVICE_ERROR The device reported an error while perfo= rming the read. > > + @retval EFI_NO_MEDIA There is no media in the device. > > + @retval EFI_MEDIA_CHANGED The MediaId does not match the current d= evice. > > + @retval EFI_INVALID_PARAMETER The read request contains device address= es that are not > > + valid for the device. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +NorFlashDiskIoReadDisk ( > > + IN EFI_DISK_IO_PROTOCOL *This, > > + IN UINT32 MediaId, > > + IN UINT64 DiskOffset, > > + IN UINTN BufferSize, > > + OUT VOID *Buffer > > + ) > > +{ > > + NOR_FLASH_INSTANCE *Instance; > > + UINT32 BlockSize; > > + UINT32 BlockOffset; > > + EFI_LBA Lba; > > + > > + Instance =3D INSTANCE_FROM_DISKIO_THIS (This); > > + > > + if (MediaId !=3D Instance->Media.MediaId) { > > + return EFI_MEDIA_CHANGED; > > + } > > + > > + BlockSize =3D Instance->Media.BlockSize; > > + Lba =3D (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &Blo= ckOffset); > > + > > + return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer); > > +} > > + > > +/** > > + Writes a specified number of bytes to a device. > > + > > + @param This Indicates a pointer to the calling context. > > + @param MediaId ID of the medium to be written. > > + @param Offset The starting byte offset on the logical block I/O d= evice to write. > > + @param BufferSize The size in bytes of Buffer. The number of bytes to= write to the device. > > + @param Buffer A pointer to the buffer containing the data to be w= ritten. > > + > > + @retval EFI_SUCCESS The data was written correctly to the de= vice. > > + @retval EFI_WRITE_PROTECTED The device can not be written to. > > + @retval EFI_DEVICE_ERROR The device reported an error while perfo= rming the write. > > + @retval EFI_NO_MEDIA There is no media in the device. > > + @retval EFI_MEDIA_CHANGED The MediaId does not match the current d= evice. > > + @retval EFI_INVALID_PARAMETER The write request contains device addres= ses that are not > > + valid for the device. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +NorFlashDiskIoWriteDisk ( > > + IN EFI_DISK_IO_PROTOCOL *This, > > + IN UINT32 MediaId, > > + IN UINT64 DiskOffset, > > + IN UINTN BufferSize, > > + IN VOID *Buffer > > + ) > > +{ > > + NOR_FLASH_INSTANCE *Instance; > > + UINT32 BlockSize; > > + UINT32 BlockOffset; > > + EFI_LBA Lba; > > + UINTN RemainingBytes; > > + UINTN WriteSize; > > + EFI_STATUS Status; > > + > > + Instance =3D INSTANCE_FROM_DISKIO_THIS (This); > > + > > + if (MediaId !=3D Instance->Media.MediaId) { > > + return EFI_MEDIA_CHANGED; > > + } > > + > > + BlockSize =3D Instance->Media.BlockSize; > > + Lba =3D (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &Blo= ckOffset); > > + > > + RemainingBytes =3D BufferSize; > > + > > + // Write either all the remaining bytes, or the number of bytes that b= ring > > + // us up to a block boundary, whichever is less. > > + // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the nex= t > > + // block boundary (even if it is already on one). > > + WriteSize =3D MIN (RemainingBytes, ((DiskOffset | (BlockSize - 1)) + 1= ) - DiskOffset); > > + > > + do { > > + if (WriteSize =3D=3D BlockSize) { > > + // Write a full block > > + Status =3D NorFlashWriteFullBlock (Instance, Lba, Buffer, BlockSiz= e / sizeof (UINT32)); > > + } else { > > + // Write a partial block > > + Status =3D NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &= WriteSize, Buffer); > > + } > > + > > + if (EFI_ERROR (Status)) { > > + return Status; > > + } > > + > > + // Now continue writing either all the remaining bytes or single blo= cks. > > + RemainingBytes -=3D WriteSize; > > + Buffer =3D (UINT8 *)Buffer + WriteSize; > > + Lba++; > > + BlockOffset =3D 0; > > + WriteSize =3D MIN (RemainingBytes, BlockSize); > > + } while (RemainingBytes); > > + > > + return Status; > > +} > -=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 (#118957): https://edk2.groups.io/g/devel/message/118957 Mute This Topic: https://groups.io/mt/105690936/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-