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 00194D811BC for ; Tue, 21 May 2024 08:38:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=kZj7KHkO3VhCMlRV9IDU7N8Hm7W1igrWk6Uz6Sjrdtg=; 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:Content-Transfer-Encoding; s=20240206; t=1716280686; v=1; b=akNrdR6Pvtf62xBT7xrbrHObkFtcixlKP9aCX8CrirciH7sEVqt+wYivl2KI4tsB6Cp4VlBx HabfrBlAy9LKSkDPf+A1DaX/ZQhcOQtXO66M97c/2ZlaPRYwBXjhxQQZbwFaYmUDTDVMotd7e5Y Jwwiktkwskfwgg/Wnc9S9zF3sxvXBe1d+c9cg/xN+imsP16gsmWKT9OuV6mcjvRODj4tpev1OIl o97EJ8BWpZHSQxartz/tRwP5ami31hukD7eUPjlMqcqaOoMDFc9eCo7bB3ZszKf1NZjI/lI8kG2 LRgiZd6EWAYtg0EFY7/cZ0LjxQuDnT2pCK4fCrvclwCtQ== X-Received: by 127.0.0.2 with SMTP id 6pinYY7687511xnL6Xj0d8Sa; Tue, 21 May 2024 01:38:06 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.14927.1716280680582227036 for ; Tue, 21 May 2024 01:38:00 -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 376C71042 for ; Tue, 21 May 2024 01:38:24 -0700 (PDT) X-Received: from mail-pj1-f42.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 2177D3F641 for ; Tue, 21 May 2024 01:38:00 -0700 (PDT) X-Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2bd9284dd31so25491a91.3 for ; Tue, 21 May 2024 01:38:00 -0700 (PDT) X-Gm-Message-State: 4vgHXGr8t2Vvzlt5Aw0jA5kZx7686176AA= X-Google-Smtp-Source: AGHT+IEBY7uzF8luOREMu3DsoD7AC0cAlbvoVJs1peq7Lg9MW8KgEhMfON91ffVJrH2MJnpN1I0eLFapvcM0cLMRxyU= X-Received: by 2002:a17:90a:9f8c:b0:2b1:99fd:91f3 with SMTP id 98e67ed59e1d1-2b6cd0e7afdmr27050639a91.41.1716280679298; Tue, 21 May 2024 01:37:59 -0700 (PDT) MIME-Version: 1.0 References: <20240423055638.1271531-1-Sahil.Kaushal@arm.com> <20240423055638.1271531-6-Sahil.Kaushal@arm.com> In-Reply-To: From: "sahil" Date: Tue, 21 May 2024 14:07:47 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH RESEND edk2-platforms][PATCH V2 05/14] Platform/ARM: Create NorFlashDeviceLib library interface for flash specific functions To: devel@edk2.groups.io, sami.mujawar@arm.com Cc: Sahil Kaushal , Ard Biesheuvel , Leif Lindholm 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: Tue, 21 May 2024 01:38:00 -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: text/plain; charset="UTF-8" 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=akNrdR6P; 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) Hi Sami, Thank you for reviewing the patches. Please find my comments inline below marked as [SAHIL]. Also, for the documentation headers, I will try to add in NorFlashDeviceLib.h and keep it consistent with CadenceQspiNorFlashDeviceLib. On Thu, 16 May 2024 at 20:48, Sami Mujawar via groups.io wrote: > > Hi Sahil, > > Thank you for this patch. > > I have some feedback marked inline as [SAMI]. > > Other than that, is is possible to add documentation header for the funct= ions and data streuctures in this file, please? > > With that fixed, > > Reviewed-by: Sami Mujawar > > Regards, > > Sami Mujawar > > On 23/04/2024 06:56 am, Sahil Kaushal wrote: > > From: sahil > > NorFlashDeviceLib can be used to provide implementations of different > NOR Flash to NorFlashDxe, i.e. NorFlashDxe links with NorFlashDeviceLib > and the platforms can specify their respective NorFlashDeviceLib > instances. > > This patch splits NorFlash.h and moves out the function prototypes and > macros that are expected by NorFlashDxe to be implemented by any > Nor Flash implementation to NorFlashDeviceLib.h file. > > Signed-off-by: sahil > --- > Platform/ARM/ARM.dec | 1 + > Platform/ARM/Drivers/NorFlashDxe/NorFlash.h | 143 +---------------= -- > Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h | 1 + > Platform/ARM/Include/Library/NorFlashDeviceLib.h | 156 ++++++++++++++++= ++++ > 4 files changed, 159 insertions(+), 142 deletions(-) > > diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec > index be7e6dc83fde..86d1fcb4878e 100644 > --- a/Platform/ARM/ARM.dec > +++ b/Platform/ARM/ARM.dec > @@ -17,6 +17,7 @@ > > > [LibraryClasses] > > BdsLib|Include/Library/BdsLib.h > > + NorFlashDeviceLib|Include/Library/NorFlashDeviceLib.h > > NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h > > > > [Guids] > > diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h b/Platform/ARM/D= rivers/NorFlashDxe/NorFlash.h > index bd5c6a949cf0..6cb1f64b9875 100644 > --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h > +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlash.h > @@ -20,6 +20,7 @@ > > > #include > > #include > > +#include > > > > #define NOR_FLASH_ERASE_RETRY 10 > > > > @@ -40,7 +41,6 @@ > #define CREATE_NOR_ADDRESS(BaseAddr, OffsetAddr) ((BaseAddr) + ((O= ffsetAddr) << 2)) > > #define CREATE_DUAL_CMD(Cmd) ( ( Cmd << 16) | = ( Cmd & LOW_16_BITS) ) > > #define SEND_NOR_COMMAND(BaseAddr, Offset, Cmd) MmioWrite32 (CREA= TE_NOR_ADDRESS(BaseAddr,Offset), CREATE_DUAL_CMD(Cmd)) > > -#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) ( BaseAddr + (UIN= TN)((Lba) * LbaSize) ) > > > > // Status Register Bits > > #define P30_SR_BIT_WRITE (BIT7 << 16 | BIT7) > > @@ -105,145 +105,4 @@ > #define P30_CMD_READ_CONFIGURATION_REGISTER_SETUP 0x0060 > > #define P30_CMD_READ_CONFIGURATION_REGISTER 0x0003 > > > > -typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; > > - > > -#pragma pack (1) > > -typedef struct { > > - VENDOR_DEVICE_PATH Vendor; > > - UINT8 Index; > > - EFI_DEVICE_PATH_PROTOCOL End; > > -} NOR_FLASH_DEVICE_PATH; > > -#pragma pack () > > - > > -struct _NOR_FLASH_INSTANCE { > > - UINT32 Signature; > > - EFI_HANDLE Handle; > > - > > - UINTN DeviceBaseAddress; > > - UINTN RegionBaseAddress; > > - UINTN Size; > > - EFI_LBA StartLba; > > - > > - EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; > > - EFI_BLOCK_IO_MEDIA Media; > > - EFI_DISK_IO_PROTOCOL DiskIoProtocol; > > - > > - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; > > - VOID *ShadowBuffer; > > - > > - NOR_FLASH_DEVICE_PATH DevicePath; > > -}; > > - > > -EFI_STATUS > > -NorFlashReadCfiData ( > > - IN UINTN DeviceBaseAddress, > > - IN UINTN CFI_Offset, > > - IN UINT32 NumberOfBytes, > > - OUT UINT32 *Data > > - ); > > [SAMI] Where is this function implemented ? [SAHIL] This function is not implemented anywhere. It is the same for NorFlashWrite() as well. I have migrated them as-is from NorFlash.h but If needed I can push a patch removing both from the library interface. Shall I push it? [/SAHIL] > > - > > -EFI_STATUS > > -NorFlashWriteBuffer ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN UINTN TargetAddress, > > - IN UINTN BufferSizeInBytes, > > - IN UINT32 *Buffer > > - ); > > - > > -// > > -// NorFlash.c > > -// > > -EFI_STATUS > > -NorFlashWriteSingleBlock ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN EFI_LBA Lba, > > - IN UINTN Offset, > > - IN OUT UINTN *NumBytes, > > - IN UINT8 *Buffer > > - ); > > - > > -EFI_STATUS > > -NorFlashWriteBlocks ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN EFI_LBA Lba, > > - IN UINTN BufferSizeInBytes, > > - IN VOID *Buffer > > - ); > > - > > -EFI_STATUS > > -NorFlashReadBlocks ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN EFI_LBA Lba, > > - IN UINTN BufferSizeInBytes, > > - OUT VOID *Buffer > > - ); > > - > > -EFI_STATUS > > -NorFlashRead ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN EFI_LBA Lba, > > - IN UINTN Offset, > > - IN UINTN BufferSizeInBytes, > > - OUT VOID *Buffer > > - ); > > - > > -EFI_STATUS > > -NorFlashWrite ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN EFI_LBA Lba, > > - IN UINTN Offset, > > - IN OUT UINTN *NumBytes, > > - IN UINT8 *Buffer > > - ); > > - > > -EFI_STATUS > > -NorFlashReset ( > > - IN NOR_FLASH_INSTANCE *Instance > > - ); > > - > > -EFI_STATUS > > -NorFlashEraseSingleBlock ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN UINTN BlockAddress > > - ); > > - > > -EFI_STATUS > > -NorFlashUnlockSingleBlockIfNecessary ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN UINTN BlockAddress > > - ); > > [SAMI] Should this be a STATIC function in the Device Library implementat= ions? Would it make more sense to have NorFlashBlockIsLocked() exposed via = this library interface instead. > > Also, would it make sense to integrate the check to see if the block is l= ocked in the NorFlashUnlockSingleBlock() instead and expose it via the libr= ary interface? > > [/SAMI] [SAHIL] I think it is okay to just expose NorFlashUnlockSingleBlockIfNecessary() through the interface as it takes care of both NorFlashBlockIsLocked() and NorFlashUnlockSingleBlock(). Also, at the moment these functions are not used anywhere outside the library implementations. But if we still want to make it STATIC and expose other functions, do you want me to expose both NorFlashBlockIsLocked() and NorFlashUnlockSingleBlock()? Or just NorFlashUnlockSingleBlock() with the NorFlashBlockIsLocked() check in it? [/SAHIL] > > - > > -EFI_STATUS > > -NorFlashWriteSingleWord ( > > - IN NOR_FLASH_INSTANCE *Instance, > > - IN UINTN WordAddress, > > - IN UINT32 WriteData > > - ); > > [SAMI] Should this function be made STATIC in the Device Library implemen= tations? [SAHIL] I will push a new patch making NorFlashWriteBuffer() and NorFlashWriteSingleWord () STATIC. > > - > > -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 c0a3b5861532..7fcb949843e8 100644 > --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h > +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h > @@ -19,6 +19,7 @@ > #include > > > > #include > > +#include > > #include > > #include > > #include > > diff --git a/Platform/ARM/Include/Library/NorFlashDeviceLib.h b/Platform/= ARM/Include/Library/NorFlashDeviceLib.h > new file mode 100644 > index 000000000000..e5017130a091 > --- /dev/null > +++ b/Platform/ARM/Include/Library/NorFlashDeviceLib.h > @@ -0,0 +1,156 @@ > +/** @file NorFlashDeviceLib.h > > + > > + Copyright (c) 2011 - 2024, Arm Limited. All rights reserved.
> > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef NOR_FLASH_DEVICE_LIB_H_ > > +#define NOR_FLASH_DEVICE_LIB_H_ > > + > > +#include > > +#include > > +#include > > + > > +typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; > > + > > +#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) ( BaseAddr + (UIN= TN)((Lba) * LbaSize) ) > > + > > +#pragma pack (1) > > +typedef struct { > > + VENDOR_DEVICE_PATH Vendor; > > + UINT8 Index; > > + EFI_DEVICE_PATH_PROTOCOL End; > > +} NOR_FLASH_DEVICE_PATH; > > +#pragma pack () > > + > > +struct _NOR_FLASH_INSTANCE { > > + UINT32 Signature; > > + EFI_HANDLE Handle; > > + > > + UINTN DeviceBaseAddress; > > + UINTN RegionBaseAddress; > > + UINTN Size; > > + EFI_LBA StartLba; > > + > > + EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; > > + EFI_BLOCK_IO_MEDIA Media; > > + EFI_DISK_IO_PROTOCOL DiskIoProtocol; > > + > > + EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; > > + VOID *ShadowBuffer; > > + > > + NOR_FLASH_DEVICE_PATH DevicePath; > > +}; > > + > > +EFI_STATUS > > +NorFlashReadCfiData ( > > + IN UINTN DeviceBaseAddress, > > + IN UINTN CFI_Offset, > > + IN UINT32 NumberOfBytes, > > + OUT UINT32 *Data > > + ); > > + > > +EFI_STATUS > > +NorFlashWriteBuffer ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN UINTN TargetAddress, > > + IN UINTN BufferSizeInBytes, > > + IN UINT32 *Buffer > > + ); > > + > > +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 > > +NorFlashWriteSingleBlock ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN Offset, > > + IN OUT UINTN *NumBytes, > > + IN UINT8 *Buffer > > + ); > > + > > +EFI_STATUS > > +NorFlashWriteBlocks ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN BufferSizeInBytes, > > + IN VOID *Buffer > > + ); > > + > > +EFI_STATUS > > +NorFlashReadBlocks ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN BufferSizeInBytes, > > + OUT VOID *Buffer > > + ); > > + > > +EFI_STATUS > > +NorFlashRead ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN Offset, > > + IN UINTN BufferSizeInBytes, > > + OUT VOID *Buffer > > + ); > > + > > +EFI_STATUS > > +NorFlashWrite ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN EFI_LBA Lba, > > + IN UINTN Offset, > > + IN OUT UINTN *NumBytes, > > + IN UINT8 *Buffer > > + ); > > + > > +EFI_STATUS > > +NorFlashReset ( > > + IN NOR_FLASH_INSTANCE *Instance > > + ); > > + > > +EFI_STATUS > > +NorFlashEraseSingleBlock ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN UINTN BlockAddress > > + ); > > + > > +EFI_STATUS > > +NorFlashUnlockSingleBlockIfNecessary ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN UINTN BlockAddress > > + ); > > + > > +EFI_STATUS > > +NorFlashWriteSingleWord ( > > + IN NOR_FLASH_INSTANCE *Instance, > > + IN UINTN WordAddress, > > + IN UINT32 WriteData > > + ); > > + > > +VOID > > +EFIAPI > > +NorFlashLock ( > > + IN EFI_TPL *OriginalTPL > > + ); > > + > > +VOID > > +EFIAPI > > +NorFlashUnlock ( > > + IN EFI_TPL OriginalTPL > > + ); > > + > > +#endif /* NOR_FLASH_DEVICE_LIB_H_ */ > > IMPORTANT NOTICE: The contents of this email and any attachments are conf= idential and may also be privileged. If you are not the intended recipient,= please notify the sender immediately and do not disclose the contents to a= ny other person, use it for any purpose, or store or copy the information i= n any medium. Thank you. >=20 -=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 (#119098): https://edk2.groups.io/g/devel/message/119098 Mute This Topic: https://groups.io/mt/105690940/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-