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 3813874003E for ; Thu, 9 May 2024 06:25:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=4SnPNmmNJtoPM4tHAgtU3KJ7iBo7AFJrAR5dEWi9fVA=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1715235927; v=1; b=soBNZQ1LUBUbjkuRQqfOqJhq7ds6WF3MNZqzZTUdLdXa31m1zpJNtfH7ueXieIgrJRIR0YeJ LHmT8j4N/q6D8QJwe5IuZ6aTMMIUHg/YViP6adWZd4xGvHeo96f88AQU63c71mzRS9u7ffyxmyD BZL92J8PXKRMXJxfpevkyfnXg/P3BvypYVHh0w+wWbk6gSfdZRKxsCh6hUrTh3EiRExhoyXcs87 vwf3mBVZB3r4It3n/SqNcA29M7eMvQxJa9Rl9goAccK5wFPH/R1qaDSaha5FOxAWoVMSnahrmod +mguDayH0xcPib5JgFfYLaWuvIAX3QDPNFwr8XP6mlHHA== X-Received: by 127.0.0.2 with SMTP id jnG8YY7687511xVrI2VCdexS; Wed, 08 May 2024 23:25:27 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.3859.1715235926663806374 for ; Wed, 08 May 2024 23:25:26 -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 BD3C81476 for ; Wed, 8 May 2024 23:25:51 -0700 (PDT) X-Received: from mail-pg1-f179.google.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15B5D3F6A8 for ; Wed, 8 May 2024 23:25:26 -0700 (PDT) X-Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-61aef9901deso446542a12.1 for ; Wed, 08 May 2024 23:25:26 -0700 (PDT) X-Gm-Message-State: izBJ4avYhejJvVKnAutL0fU0x7686176AA= X-Google-Smtp-Source: AGHT+IHUKnrBhcT6t37HyaebciLmhj0j81Ju+SteBJ3D9pzJGGKQ0vcne0ZDe3FFDgIWccU1IWE5mSJsgYqZ2iTKkVc= X-Received: by 2002:a05:6a21:1f1f:b0:1a7:9cf6:6044 with SMTP id adf61e73a8af0-1afc8d5bf4amr4306313637.27.1715235925316; Wed, 08 May 2024 23:25:25 -0700 (PDT) MIME-Version: 1.0 References: <20240423055638.1271531-1-Sahil.Kaushal@arm.com> <20240423055638.1271531-13-Sahil.Kaushal@arm.com> <8f292b6a-4c18-48c5-8e20-5eb9c86538e0@arm.com> In-Reply-To: <8f292b6a-4c18-48c5-8e20-5eb9c86538e0@arm.com> From: "sahil" Date: Thu, 9 May 2024 11:55:13 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH RESEND edk2-platforms][PATCH V2 12/14] Platform/ARM: Add CadenceQspiNorFlashDeviceLib for NorFlashDxe To: devel@edk2.groups.io, pierre.gondois@arm.com Cc: sahil.kaushal@arm.com, Ard Biesheuvel , Leif Lindholm , Sami Mujawar , "levi.yun" 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, 08 May 2024 23:25:27 -0700 Resent-From: sahil@arm.com Reply-To: devel@edk2.groups.io,sahil@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="00000000000008e7030617ff7caf" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=soBNZQ1L; 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 --00000000000008e7030617ff7caf Content-Type: text/plain; charset="UTF-8" Hi Pierre, Thanks for reviewing the patchset. Please find my comment inline below. On Thu, 2 May 2024 at 18:47, PierreGondois via groups.io wrote: > > Hello Sahil, > > On 4/23/24 07:56, Sahil Kaushal via groups.io wrote: > > From: sahil > > > > In N1Sdp platform, the SoC is connected to IOFPGA which has a > > Cadence Quad SPI (QSPI) controller. This QSPI controller manages > > the flash chip device via QSPI bus. > > > > This patch adds CadenceQspiNorFlashDeviceLib which is used to > > manage and access the above configuration. > > > > Signed-off-by: sahil > > --- > > Platform/ARM/Library/CadenceQspiNorFlashDeviceLib/CadenceQspiNorFlashDeviceLib.inf | 32 + > > Platform/ARM/Library/CadenceQspiNorFlashDeviceLib/CadenceQspiNorFlashDeviceLib.h | 44 + > > Platform/ARM/Library/CadenceQspiNorFlashDeviceLib/CadenceQspiNorFlashDeviceLib.c | 1011 ++++++++++++++++++++ > > 3 files changed, 1087 insertions(+) > > > > [snip] > > > + > > +/** > > + Converts milliseconds into number of ticks of the performance counter. > > + > > + @param[in] Milliseconds Milliseconds to convert into ticks. > > + > > + @retval Milliseconds expressed as number of ticks. > > + > > +**/ > > +STATIC > > +UINT64 > > +MilliSecondsToTicks ( > > + IN UINTN Milliseconds > > + ) > > +{ > > + CONST UINT64 NanoSecondsPerTick = GetTimeInNanoSecond (1); > > + > > + return (Milliseconds * 1000000) / NanoSecondsPerTick; > > Should use DivU64x64Remainder() here: > { > UINT64 NanoSecondsPerTick; > UINT64 NanoSeconds; > > NanoSecondsPerTick = GetTimeInNanoSecond (1); > NanoSeconds = MultU64x32 (Milliseconds, 1000000); > > return DivU64x64Remainder (NanoSeconds, NanoSecondsPerTick, NULL); > } > > > +} > > + > > +/** > > + Poll Status register for NOR flash erase/write completion. > > + > > + @param[in] Instance NOR flash Instance. > > + > > + @retval EFI_SUCCESS Request is executed successfully. > > + @retval EFI_TIMEOUT Operation timed out. > > + @retval EFI_DEVICE_ERROR Controller operartion failed. > > operartion -> typo > (same at another place I think) > > [snip] > > > + > > +/** > > + Read from nor flash. > > + > > + @param[in] Instance NOR flash Instance of variable store region. > > + @param[in] Lba The starting logical block index to read from. > > + @param[in] Offset Offset into the block at which to begin reading. > > + @param[in] BufferSizeInBytes The number of bytes to read. > > + @param[out] Buffer The pointer to a caller-allocated buffer that > > + should copied with read data. > > + > > + @retval EFI_SUCCESS The read is completed. > > + @retval EFI_INVALID_PARAMETER Invalid parameters passed. > > +**/ > > +EFI_STATUS > > +NorFlashRead ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN Offset, > > + IN UINTN BufferSizeInBytes, > > + OUT VOID *Buffer > > + ) > > +{ > > + UINTN StartAddress; > > + > > + // The buffer must be valid > > + if (Buffer == NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + // Return if we do not have any byte to read > > + if (BufferSizeInBytes == 0) { > > + return EFI_SUCCESS; > > + } > > + > > + if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > > > + Instance->Size) > > + { > > + DEBUG (( > > + DEBUG_ERROR, > > + "NorFlashRead: ERROR - Read will exceed device size.\n" > > + )); > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + // Get the address to start reading from > > + StartAddress = GET_NOR_BLOCK_ADDRESS ( > > + Instance->RegionBaseAddress, > > + Lba, > > + Instance->Media.BlockSize > > + ); > > + > > + // Readout the data > > + CopyMem (Buffer, (UINTN *)(StartAddress + Offset), BufferSizeInBytes); > > The original code at: > Platform/ARM/Library/P30NorFlashDeviceLib/P30NorFlashDeviceLib.c > > implements and uses AlignedCopyMem()/NorFlashWriteBuffer() which seems > to be more efficient. > Just to be sure I understand correctly, is the maximal read/write size > of 4 bytes ? Meaning that these functions are not needed ? > > --- > > NorFlashWriteBuffer() is not implemented here IIUC won't be implemtned as not > needed. Maybe in an additional patch, the function could be removed from the > library interface at: > Platform/ARM/Include/Library/NorFlashDeviceLib.h > and made static in: > Platform/ARM/Library/P30NorFlashDeviceLib/P30NorFlashDeviceLib.c > CopyMem() and AlignedCopyMem() have nearly identical implementations, therefore I think we can continue using CopyMem() here. For NorFlashWriteBuffer(), in the P30 spec, it looks like buffered programming is one of the features of the IP whereas there is no such feature in cadence IP. So, I think there is no need for NorFlashWriteBuffer() for Cadence controller Library. I will push another patch in the next patchset to remove NorFlashWriteBuffer() from the NorFlashDeviceLib.h header file. > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Write a full or portion of a block. > > + > > + @param[in] Instance NOR flash Instance of variable store region. > > + @param[in] Lba The starting logical block index to write to. > > + @param[in] Offset Offset into the block at which to begin writing. > > + @param[in, out] NumBytes The total size of the buffer. > > + @param[in] Buffer The pointer to a caller-allocated buffer that > > + contains the source for the write. > > + > > + @retval EFI_SUCCESS The write is completed. > > + @retval EFI_OUT_OF_RESOURCES Invalid Buffer passed. > > + @retval EFI_BAD_BUFFER_SIZE Buffer size not enough. > > + @retval EFI_DEVICE_ERROR The device reported an error. > > +**/ > > +EFI_STATUS > > +NorFlashWriteSingleBlock ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN Offset, > > + IN OUT UINTN *NumBytes, > > + IN UINT8 *Buffer > > + ) > > +{ > > + EFI_STATUS Status; > > + UINT32 Tmp; > > + UINT32 TmpBuf; > > + UINT32 WordToWrite; > > + UINT32 Mask; > > + BOOLEAN DoErase; > > + UINTN BytesToWrite; > > + UINTN CurOffset; > > + UINTN WordAddr; > > + UINTN BlockSize; > > + UINTN BlockAddress; > > + UINTN PrevBlockAddress; > > + > > + if (Buffer == NULL) { > > + DEBUG (( > > + DEBUG_ERROR, > > + "NorFlashWriteSingleBlock: ERROR - Buffer is invalid\n" > > + )); > > + return EFI_OUT_OF_RESOURCES; > > EFI_INVALID_PARAMETER instead I think > > > + } > > + > > + PrevBlockAddress = 0; > > + > > + DEBUG (( > > + DEBUG_INFO, > > + "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, " > > + "*NumBytes=0x%x, Buffer @ 0x%08x)\n", > > + Lba, > > + Offset, > > + *NumBytes, > > + Buffer > > + )); > > + > > + // Localise the block size to avoid de-referencing pointers all the time > > Localise -> Locate > > > + BlockSize = Instance->Media.BlockSize; > > + > > [snip] > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118730): https://edk2.groups.io/g/devel/message/118730 Mute This Topic: https://groups.io/mt/105690947/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- --00000000000008e7030617ff7caf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Pierre, Thanks for reviewing the=C2=A0patchset. Please = find my comment inline below.

On Thu, 2 May 2024 at 18:47, PierreGon= dois via groups.io <pierre.gondois=3Darm.com@groups.io> wrote:
>=
> Hello Sahil,
>
> On 4/23/24 07:56, Sahil Kaushal via <= a href=3D"http://groups.io">groups.io wrote:
> > From: sahil &= lt;sahil@arm.com>
> >
&= gt; > In N1Sdp platform, the SoC is connected to IOFPGA which has a
&= gt; > Cadence Quad SPI (QSPI) controller. This QSPI controller manages> > the flash chip device via QSPI bus.
> >
> > T= his patch adds CadenceQspiNorFlashDeviceLib which is used to
> > m= anage and access the above configuration.
> >
> > Signed-= off-by: sahil <sahil@arm.com>> > ---
> > =C2=A0 Platform/ARM/Library/CadenceQspiNorFlash= DeviceLib/CadenceQspiNorFlashDeviceLib.inf | =C2=A0 32 +
> > =C2= =A0 Platform/ARM/Library/CadenceQspiNorFlashDeviceLib/CadenceQspiNorFlashDe= viceLib.h =C2=A0 | =C2=A0 44 +
> > =C2=A0 Platform/ARM/Library/Cad= enceQspiNorFlashDeviceLib/CadenceQspiNorFlashDeviceLib.c =C2=A0 | 1011 ++++= ++++++++++++++++
> > =C2=A0 3 files changed, 1087 insertions(+)> >
>
> [snip]
>
> > +
> > +/**<= br>> > + =C2=A0Converts milliseconds into number of ticks of the perf= ormance counter.
> > +
> > + =C2=A0@param[in] Millisecond= s =C2=A0Milliseconds to convert into ticks.
> > +
> > + = =C2=A0@retval Milliseconds expressed as number of ticks.
> > +
= > > +**/
> > +STATIC
> > +UINT64
> > +Mill= iSecondsToTicks (
> > + =C2=A0IN UINTN =C2=A0Milliseconds
> = > + =C2=A0)
> > +{
> > + =C2=A0CONST UINT64 =C2=A0Nano= SecondsPerTick =3D GetTimeInNanoSecond (1);
> > +
> > + = =C2=A0return (Milliseconds * 1000000) / NanoSecondsPerTick;
>
>= Should use DivU64x64Remainder() here:
> {
> =C2=A0 =C2=A0UINT6= 4 =C2=A0NanoSecondsPerTick;
> =C2=A0 =C2=A0UINT64 =C2=A0NanoSeconds;<= br>>
> =C2=A0 =C2=A0NanoSecondsPerTick =3D GetTimeInNanoSecond (1)= ;
> =C2=A0 =C2=A0NanoSeconds =3D MultU64x32 (Milliseconds, 1000000);<= br>>
> =C2=A0 =C2=A0return DivU64x64Remainder (NanoSeconds, NanoSe= condsPerTick, NULL);
> }
>
> > +}
> > +
&g= t; > +/**
> > + =C2=A0Poll Status register for NOR flash erase/= write completion.
> > +
> > + =C2=A0@param[in] =C2=A0 =C2= =A0 =C2=A0Instance =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NOR flash Instance.> > +
> > + =C2=A0@retval =C2=A0 =C2=A0 =C2=A0 =C2=A0 EFI_= SUCCESS =C2=A0 =C2=A0 =C2=A0 =C2=A0Request is executed successfully.
>= ; > + =C2=A0@retval =C2=A0 =C2=A0 =C2=A0 =C2=A0 EFI_TIMEOUT =C2=A0 =C2= =A0 =C2=A0 =C2=A0Operation timed out.
> > + =C2=A0@retval =C2=A0 = =C2=A0 =C2=A0 =C2=A0 EFI_DEVICE_ERROR =C2=A0 Controller operartion failed.<= br>>
> operartion -> typo
> (same at another place I thin= k)
>
> [snip]
>
> > +
> > +/**
> = > + =C2=A0Read from nor flash.
> > +
> > + =C2=A0@para= m[in] =C2=A0 =C2=A0 Instance =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 NOR flash Instance of variable store region.
> > + =C2=A0@para= m[in] =C2=A0 =C2=A0 Lba =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0The starting logical block index to read from.
> = > + =C2=A0@param[in] =C2=A0 =C2=A0 Offset =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 Offset into the block at which to begin reading= .
> > + =C2=A0@param[in] =C2=A0 =C2=A0 BufferSizeInBytes =C2=A0 = =C2=A0 =C2=A0The number of bytes to read.
> > + =C2=A0@param[out] = =C2=A0 =C2=A0Buffer =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= The pointer to a caller-allocated buffer that
> > + =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0should copied with read= data.
> > +
> > + =C2=A0@retval =C2=A0 =C2=A0 =C2=A0 =C2= =A0EFI_SUCCESS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The read is complet= ed.
> > + =C2=A0@retval =C2=A0 =C2=A0 =C2=A0 =C2=A0EFI_INVALID_PAR= AMETER =C2=A0Invalid parameters passed.
> > +**/
> > +EFI= _STATUS
> > +NorFlashRead (
> > + =C2=A0IN NOR_FLASH_INST= ANCE =C2=A0*Instance,
> > + =C2=A0IN EFI_LBA =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 Lba,
> > + =C2=A0IN UINTN =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Offset,
> > + =C2=A0IN UINTN =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BufferSizeInBytes,
> &g= t; + =C2=A0OUT VOID =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *Buffe= r
> > + =C2=A0)
> > +{
> > + =C2=A0UINTN =C2=A0S= tartAddress;
> > +
> > + =C2=A0// The buffer must be vali= d
> > + =C2=A0if (Buffer =3D=3D NULL) {
> > + =C2=A0 =C2= =A0return EFI_INVALID_PARAMETER;
> > + =C2=A0}
> > +
&= gt; > + =C2=A0// Return if we do not have any byte to read
> > = + =C2=A0if (BufferSizeInBytes =3D=3D 0) {
> > + =C2=A0 =C2=A0retur= n EFI_SUCCESS;
> > + =C2=A0}
> > +
> > + =C2=A0i= f (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) >=
> > + =C2=A0 =C2=A0 =C2=A0Instance->Size)
> > + =C2= =A0{
> > + =C2=A0 =C2=A0DEBUG ((
> > + =C2=A0 =C2=A0 =C2= =A0DEBUG_ERROR,
> > + =C2=A0 =C2=A0 =C2=A0"NorFlashRead: ERRO= R - Read will exceed device size.\n"
> > + =C2=A0 =C2=A0 =C2= =A0));
> > + =C2=A0 =C2=A0return EFI_INVALID_PARAMETER;
> &g= t; + =C2=A0}
> > +
> > + =C2=A0// Get the address to star= t reading from
> > + =C2=A0StartAddress =3D GET_NOR_BLOCK_ADDRESS = (
> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Instance->RegionBaseAddress,
> > + =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Lba,
> > + =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Instance->Media.BlockS= ize
> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 );
> > +
> > + =C2=A0// Readout the data
> &= gt; + =C2=A0CopyMem (Buffer, (UINTN *)(StartAddress + Offset), BufferSizeIn= Bytes);
>
> The original code at:
> =C2=A0 =C2=A0Platform= /ARM/Library/P30NorFlashDeviceLib/P30NorFlashDeviceLib.c
>
> im= plements and uses AlignedCopyMem()/NorFlashWriteBuffer() which seems
>= ; to be more efficient.
> Just to be sure I understand correctly, is = the maximal read/write size
> of 4 bytes ? Meaning that these functio= ns are not needed ?
>
> ---
>
> NorFlashWriteBuffer= () is not implemented here IIUC won't be implemtned as not
> need= ed. Maybe in an additional patch, the function could be removed from the> library interface at:
> =C2=A0 =C2=A0Platform/ARM/Include/Libra= ry/NorFlashDeviceLib.h
> and made static in:
> =C2=A0 =C2=A0Pla= tform/ARM/Library/P30NorFlashDeviceLib/P30NorFlashDeviceLib.c
>
Co= pyMem() and AlignedCopyMem() have nearly identical implementations, therefo= re I think we can
continue using CopyMem() here.

For NorFlashWrit= eBuffer(), in the P30 spec, it looks like buffered programming is one of th= e features
of the IP whereas there is no such feature in cadence IP. So,= I think there is no need for
NorFlashWriteBuffer() for Cadence controll= er Library.

I will push another patch in the next patchset to remove= =C2=A0NorFlashWriteBuffer() from the
NorFlashDeviceLib.h header file.<= br>
> > +
> > + =C2=A0return EFI_SUCCESS;
> > +}=
> > +
> > +/**
> > + =C2=A0Write a full or port= ion of a block.
> > +
> > + =C2=A0@param[in] =C2=A0 =C2= =A0 =C2=A0 Instance =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0NOR fla= sh Instance of variable store region.
> > + =C2=A0@param[in] =C2= =A0 =C2=A0 =C2=A0 Lba =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 The starting logical block index to write to.
> > + =C2= =A0@param[in] =C2=A0 =C2=A0 =C2=A0 Offset =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Offset into the block at which to begin writing.> > + =C2=A0@param[in, out] =C2=A0NumBytes =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0The total size of the buffer.
> > + =C2=A0= @param[in] =C2=A0 =C2=A0 =C2=A0 Buffer =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0The pointer to a caller-allocated buffer that
> &= gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cont= ains the source for the write.
> > +
> > + =C2=A0@retval = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0EFI_SUCCESS =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 The write is completed.
> > + =C2=A0@retval =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0EFI_OUT_OF_RESOURCES =C2=A0Invalid Buffer passed.
&g= t; > + =C2=A0@retval =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0EFI_BAD_BUFFER_SI= ZE =C2=A0 Buffer size not enough.
> > + =C2=A0@retval =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0EFI_DEVICE_ERROR =C2=A0 =C2=A0 =C2=A0The device rep= orted an error.
> > +**/
> > +EFI_STATUS
> > +No= rFlashWriteSingleBlock (
> > + =C2=A0IN =C2=A0 =C2=A0 =C2=A0 =C2= =A0NOR_FLASH_INSTANCE =C2=A0*Instance,
> > + =C2=A0IN =C2=A0 =C2= =A0 =C2=A0 =C2=A0EFI_LBA =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Lba,
= > > + =C2=A0IN =C2=A0 =C2=A0 =C2=A0 =C2=A0UINTN =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 Offset,
> > + =C2=A0IN OUT =C2=A0 =C2= =A0UINTN =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *NumBytes,
>= ; > + =C2=A0IN =C2=A0 =C2=A0 =C2=A0 =C2=A0UINT8 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 *Buffer
> > + =C2=A0)
> > +{
= > > + =C2=A0EFI_STATUS =C2=A0Status;
> > + =C2=A0UINT32 =C2= =A0 =C2=A0 =C2=A0Tmp;
> > + =C2=A0UINT32 =C2=A0 =C2=A0 =C2=A0TmpBu= f;
> > + =C2=A0UINT32 =C2=A0 =C2=A0 =C2=A0WordToWrite;
> >= ; + =C2=A0UINT32 =C2=A0 =C2=A0 =C2=A0Mask;
> > + =C2=A0BOOLEAN =C2= =A0 =C2=A0 DoErase;
> > + =C2=A0UINTN =C2=A0 =C2=A0 =C2=A0 BytesTo= Write;
> > + =C2=A0UINTN =C2=A0 =C2=A0 =C2=A0 CurOffset;
> &= gt; + =C2=A0UINTN =C2=A0 =C2=A0 =C2=A0 WordAddr;
> > + =C2=A0UINTN= =C2=A0 =C2=A0 =C2=A0 BlockSize;
> > + =C2=A0UINTN =C2=A0 =C2=A0 = =C2=A0 BlockAddress;
> > + =C2=A0UINTN =C2=A0 =C2=A0 =C2=A0 PrevBl= ockAddress;
> > +
> > + =C2=A0if (Buffer =3D=3D NULL) {> > + =C2=A0 =C2=A0DEBUG ((
> > + =C2=A0 =C2=A0 =C2=A0DEBU= G_ERROR,
> > + =C2=A0 =C2=A0 =C2=A0"NorFlashWriteSingleBlock:= ERROR - Buffer is invalid\n"
> > + =C2=A0 =C2=A0 =C2=A0));> > + =C2=A0 =C2=A0return EFI_OUT_OF_RESOURCES;
>
> EFI= _INVALID_PARAMETER instead I think
>
> > + =C2=A0}
> &= gt; +
> > + =C2=A0PrevBlockAddress =3D 0;
> > +
> &= gt; + =C2=A0DEBUG ((
> > + =C2=A0 =C2=A0DEBUG_INFO,
> > += =C2=A0 =C2=A0"NorFlashWriteSingleBlock(Parameters: Lba=3D%ld, Offset= =3D0x%x, "
> > + =C2=A0 =C2=A0"*NumBytes=3D0x%x, Buffer = @ 0x%08x)\n",
> > + =C2=A0 =C2=A0Lba,
> > + =C2=A0 = =C2=A0Offset,
> > + =C2=A0 =C2=A0*NumBytes,
> > + =C2=A0 = =C2=A0Buffer
> > + =C2=A0 =C2=A0));
> > +
> > + = =C2=A0// Localise the block size to avoid de-referencing pointers all the t= ime
>
> Localise -> Locate
>
> > + =C2=A0Bloc= kSize =3D Instance->Media.BlockSize;
> > +
>
> [sni= p]
>
>
>
>
>
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#118730) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--00000000000008e7030617ff7caf--