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 BDB08D806DD for ; Thu, 23 May 2024 10:56:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BoOxYmwdOSKc7x+/oy0css45oxo+iBP9+ea3q2j32lE=; 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=1716461773; v=1; b=zu32CSYnsB4xNdEox5zrjz/Ay7ix0oBoK6EOwfYeoFdKJ+aYuVrkMw/xfUZlx+vP0fJyjJTq q/K2pjjirVS5dhwNSIFXJMRYxsCpR+Hp62KOE4UOOFY2eX4bkvoUpw8ek+BBicaKiW7JL2PJZL3 nq4TlO1A3GIjsu05Czx6+52UIeAnFK7FiiIld0WZJZVy5y8BP6cxntWR8x95sVqz3TIIb9PsBOy MBLkogIWIaZwUvfKBbraiPr5lZZGUdF2TwMb7bdDFPsQaiGxzcBZI5LYD9kS707pVDo2owVrBff bsG/TsldsufBoPdVO28nNeHa4tpZxz6kwaBny46ZnmEIg== X-Received: by 127.0.0.2 with SMTP id ltoqYY7687511xdtNWfTKijU; Thu, 23 May 2024 03:56:13 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.12642.1716461772431247306 for ; Thu, 23 May 2024 03:56:12 -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 25A76DA7; Thu, 23 May 2024 03:56:36 -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 62FB43F766; Thu, 23 May 2024 03:56:10 -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 V3 10/17] Platform/ARM: Add HostControllerBaseAddress variable Date: Thu, 23 May 2024 16:25:04 +0530 Message-Id: <20240523105511.13189-11-Sahil.Kaushal@arm.com> In-Reply-To: <20240523105511.13189-1-Sahil.Kaushal@arm.com> References: <20240523105511.13189-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: Thu, 23 May 2024 03:56:12 -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: 1QUrll3ngo2ZnKrcP357WuD0x7686176AA= 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=zu32CSYn; 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 This variable holds the QSPI controller's base address. It is defined in ARM.dec as well with the default value of 0x0. In case a platform is not using it, they can just ignore this variable and the default value of 0x0 will be propogated and the variable will not be used. Signed-off-by: sahil --- Platform/ARM/ARM.dec | 3 ++ Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf | 3 ++ Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf | 2 ++ Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h | 1 + Platform/ARM/Include/Library/NorFlashDeviceLib.h | 11 ++++--- Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c | 34 +++++++++++= ++++++--- Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c | 12 ++++--- 7 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Platform/ARM/ARM.dec b/Platform/ARM/ARM.dec index 86d1fcb4878e..a5e28c372903 100644 --- a/Platform/ARM/ARM.dec +++ b/Platform/ARM/ARM.dec @@ -26,3 +26,6 @@ =0D [PcdsFeatureFlag.common]=0D gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0x0= 000001=0D +=0D +[PcdsFixedAtBuild.common]=0D + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress|0x0|UINT32|0x000000= 02=0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf b/Platform/AR= M/Drivers/NorFlashDxe/NorFlashDxe.inf index de160025b632..6522968d6c5a 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf @@ -65,5 +65,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize=0D =0D +[FixedPcd]=0D + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress=0D +=0D [Depex]=0D gEfiCpuArchProtocolGuid=0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf b/Pl= atform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf index d9e7de07165c..eb86d423f106 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf @@ -59,5 +59,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize=0D =0D + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress=0D +=0D [Depex]=0D TRUE=0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h b/Platform/A= RM/Drivers/NorFlashDxe/NorFlashCommon.h index 7fcb949843e8..98464e4868b1 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h @@ -34,6 +34,7 @@ //=0D EFI_STATUS=0D NorFlashCreateInstance (=0D + IN UINTN HostRegisterBase,=0D IN UINTN NorFlashDeviceBase,=0D IN UINTN NorFlashRegionBase,=0D IN UINTN NorFlashSize,=0D diff --git a/Platform/ARM/Include/Library/NorFlashDeviceLib.h b/Platform/AR= M/Include/Library/NorFlashDeviceLib.h index 6833c1ddc456..348136630e78 100644 --- a/Platform/ARM/Include/Library/NorFlashDeviceLib.h +++ b/Platform/ARM/Include/Library/NorFlashDeviceLib.h @@ -36,10 +36,13 @@ struct _NOR_FLASH_INSTANCE { UINT32 Signature; ///< NOR Flash instanc= e signature.=0D EFI_HANDLE Handle; ///< NOR Flash instanc= e handle.=0D =0D - UINTN DeviceBaseAddress; ///< NOR Flash= device base address.=0D - UINTN RegionBaseAddress; ///< NOR Flash= region base address.=0D - UINTN Size; ///< NOR Flash= region size.=0D - EFI_LBA StartLba; ///< Region st= art LBA.=0D + UINTN HostControllerBaseAddress; ///< N= OR Flash host controller base address.=0D + ///< T= his field is optional if no host=0D + ///< c= ontroller is present.=0D + UINTN DeviceBaseAddress; ///< N= OR Flash device base address.=0D + UINTN RegionBaseAddress; ///< N= OR Flash region base address.=0D + UINTN Size; ///< N= OR Flash region size.=0D + EFI_LBA StartLba; ///< R= egion start LBA.=0D =0D EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; ///< Instance's = Block IO protocol handle.=0D EFI_BLOCK_IO_MEDIA Media; ///< Instance's = Media information.=0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c b/Platform/ARM/= Drivers/NorFlashDxe/NorFlashDxe.c index 1c12572ab663..e01b05d91978 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c @@ -1,6 +1,6 @@ /** @file NorFlashDxe.c=0D =0D - Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
=0D + Copyright (c) 2011 - 2024, Arm Limited. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -30,6 +30,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { NOR_FLASH_SIGNATURE, // Signature=0D NULL, // Handle ... NEED TO BE FILLED=0D =0D + 0, // Optional HostControllerBaseAddress ... NEED TO BE FILLED=0D 0, // DeviceBaseAddress ... NEED TO BE FILLED=0D 0, // RegionBaseAddress ... NEED TO BE FILLED=0D 0, // Size ... NEED TO BE FILLED=0D @@ -99,6 +100,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { =0D EFI_STATUS=0D NorFlashCreateInstance (=0D + IN UINTN HostControllerBase,=0D IN UINTN NorFlashDeviceBase,=0D IN UINTN NorFlashRegionBase,=0D IN UINTN NorFlashSize,=0D @@ -118,9 +120,10 @@ NorFlashCreateInstance ( return EFI_OUT_OF_RESOURCES;=0D }=0D =0D - Instance->DeviceBaseAddress =3D NorFlashDeviceBase;=0D - Instance->RegionBaseAddress =3D NorFlashRegionBase;=0D - Instance->Size =3D NorFlashSize;=0D + Instance->HostControllerBaseAddress =3D HostControllerBase;=0D + Instance->DeviceBaseAddress =3D NorFlashDeviceBase;=0D + Instance->RegionBaseAddress =3D NorFlashRegionBase;=0D + Instance->Size =3D NorFlashSize;=0D =0D Instance->BlockIoProtocol.Media =3D &Instance->Media;=0D Instance->Media.MediaId =3D Index;=0D @@ -184,6 +187,27 @@ NorFlashInitialise ( UINT32 Index;=0D NOR_FLASH_DESCRIPTION *NorFlashDevices;=0D BOOLEAN ContainVariableStorage;=0D + EFI_PHYSICAL_ADDRESS HostControllerBaseAddress;=0D +=0D + // Host controller base address region if available=0D + HostControllerBaseAddress =3D PcdGet32 (PcdNorFlashRegBaseAddress);=0D +=0D + if (HostControllerBaseAddress !=3D 0) {=0D + Status =3D gDS->AddMemorySpace (=0D + EfiGcdMemoryTypeMemoryMappedIo,=0D + HostControllerBaseAddress,=0D + SIZE_4KB,=0D + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + Status =3D gDS->SetMemorySpaceAttributes (=0D + HostControllerBaseAddress,=0D + SIZE_4KB,=0D + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D =0D Status =3D NorFlashPlatformInitialization ();=0D if (EFI_ERROR (Status)) {=0D @@ -215,6 +239,7 @@ NorFlashInitialise ( }=0D =0D Status =3D NorFlashCreateInstance (=0D + HostControllerBaseAddress,=0D NorFlashDevices[Index].DeviceBaseAddress,=0D NorFlashDevices[Index].RegionBaseAddress,=0D NorFlashDevices[Index].Size,=0D @@ -368,6 +393,7 @@ NorFlashVirtualNotifyEvent ( UINTN Index;=0D =0D for (Index =3D 0; Index < mNorFlashDeviceCount; Index++) {=0D + EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->HostContr= ollerBaseAddress);=0D EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->DeviceBas= eAddress);=0D EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->RegionBas= eAddress);=0D =0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c b/Plat= form/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c index 85198b98e8a8..16fe3762e125 100644 --- a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c +++ b/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c @@ -1,6 +1,6 @@ /** @file NorFlashStandaloneMm.c=0D =0D - Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
=0D + Copyright (c) 2011 - 2024, Arm Limited. All rights reserved.
=0D Copyright (c) 2020, Linaro, Ltd. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -24,6 +24,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { NOR_FLASH_SIGNATURE, // Signature=0D NULL, // Handle ... NEED TO BE FILLED=0D =0D + 0, // Optional HostControllerBaseAddress ... NEED TO BE FILLED=0D 0, // DeviceBaseAddress ... NEED TO BE FILLED=0D 0, // RegionBaseAddress ... NEED TO BE FILLED=0D 0, // Size ... NEED TO BE FILLED=0D @@ -93,6 +94,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { =0D EFI_STATUS=0D NorFlashCreateInstance (=0D + IN UINTN HostControllerBase,=0D IN UINTN NorFlashDeviceBase,=0D IN UINTN NorFlashRegionBase,=0D IN UINTN NorFlashSize,=0D @@ -112,9 +114,10 @@ NorFlashCreateInstance ( return EFI_OUT_OF_RESOURCES;=0D }=0D =0D - Instance->DeviceBaseAddress =3D NorFlashDeviceBase;=0D - Instance->RegionBaseAddress =3D NorFlashRegionBase;=0D - Instance->Size =3D NorFlashSize;=0D + Instance->HostControllerBaseAddress =3D HostControllerBase;=0D + Instance->DeviceBaseAddress =3D NorFlashDeviceBase;=0D + Instance->RegionBaseAddress =3D NorFlashRegionBase;=0D + Instance->Size =3D NorFlashSize;=0D =0D Instance->BlockIoProtocol.Media =3D &Instance->Media;=0D Instance->Media.MediaId =3D Index;=0D @@ -194,6 +197,7 @@ NorFlashInitialise ( }=0D =0D Status =3D NorFlashCreateInstance (=0D + PcdGet32 (PcdNorFlashRegBaseAddress),=0D NorFlashDevices[Index].DeviceBaseAddress,=0D NorFlashDevices[Index].RegionBaseAddress,=0D NorFlashDevices[Index].Size,=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119152): https://edk2.groups.io/g/devel/message/119152 Mute This Topic: https://groups.io/mt/106260148/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-