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 E9BF9740032 for ; Wed, 29 May 2024 08:55:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+6Xg5fyXTphZkQzZ1uDa4cqi7bYQybVaP15QEYzJxGU=; 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=1716972953; v=1; b=20q/0Ug1qUBKsqg1rCJVw1N0ctwgtgAgkX/C05HToiMX/GWY2pPPb0tuX5t9wi70QAA0moHW HlRwUja+Jc+OGixy2RHPPsRa9e0LRldoHEUUFC9bfWhNOnPFhrHXD/54d14rqyxDKzkbbP0SpeG dfs9OFki9/6rBxnlRFkJC8LuiVnb4uxnBU40G42wyvH93wEFkRGW0pQV50l7/IvoIewhjaacDKg zzSGHkKKybLS1LlQuGhI7w5Ds0AcyGH7b5Ayz+cNJEunX3HKJiAPse26iURXLI/ak69/JmeRuka i0/nq91QbUwKeYvI9Bs514FdA+y/pFSY+76GbPB2bEJww== X-Received: by 127.0.0.2 with SMTP id 9cBWYY7687511xHlHXhmJnEe; Wed, 29 May 2024 01:55:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.9179.1716972949148413421 for ; Wed, 29 May 2024 01:55:49 -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 18DBF2F4; Wed, 29 May 2024 01:56:13 -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 34D203F762; Wed, 29 May 2024 01:55:46 -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 V4 10/17] Platform/ARM: Add HostControllerBaseAddress variable Date: Wed, 29 May 2024 14:25:10 +0530 Message-Id: <20240529085517.1074417-11-Sahil.Kaushal@arm.com> In-Reply-To: <20240529085517.1074417-1-Sahil.Kaushal@arm.com> References: <20240529085517.1074417-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: Wed, 29 May 2024 01:55:49 -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: Rkzs2Uhpwc6y1UppujO8Ze3xx7686176AA= 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="20q/0Ug1"; 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 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 @@ [Guids] =20 [PcdsFeatureFlag.common] gPlatformArmTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0= x0000001 + +[PcdsFixedAtBuild.common] + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress|0x0|UINT32|0x0000= 0002 diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.inf b/Platform/= ARM/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 @@ [Pcd.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =20 +[FixedPcd] + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress + [Depex] gEfiCpuArchProtocolGuid diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf b/= Platform/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 @@ [FixedPcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =20 + gPlatformArmTokenSpaceGuid.PcdNorFlashRegBaseAddress + [Depex] TRUE diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashCommon.h b/Platform= /ARM/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 @@ // EFI_STATUS NorFlashCreateInstance ( + IN UINTN HostRegisterBase, IN UINTN NorFlashDeviceBase, IN UINTN NorFlashRegionBase, IN UINTN NorFlashSize, diff --git a/Platform/ARM/Include/Library/NorFlashDeviceLib.h b/Platform/= ARM/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 insta= nce signature. EFI_HANDLE Handle; ///< NOR Flash insta= nce handle. =20 - UINTN DeviceBaseAddress; ///< NOR Fla= sh device base address. - UINTN RegionBaseAddress; ///< NOR Fla= sh region base address. - UINTN Size; ///< NOR Fla= sh region size. - EFI_LBA StartLba; ///< Region = start LBA. + UINTN HostControllerBaseAddress; ///<= NOR Flash host controller base address. + ///<= This field is optional if no host + ///<= controller is present. + UINTN DeviceBaseAddress; ///<= NOR Flash device base address. + UINTN RegionBaseAddress; ///<= NOR Flash region base address. + UINTN Size; ///<= NOR Flash region size. + EFI_LBA StartLba; ///<= Region start LBA. =20 EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; ///< Instance'= s Block IO protocol handle. EFI_BLOCK_IO_MEDIA Media; ///< Instance'= s Media information. diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c b/Platform/AR= M/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 =20 - Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2011 - 2024, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -30,6 +30,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { NOR_FLASH_SIGNATURE, // Signature NULL, // Handle ... NEED TO BE FILLED =20 + 0, // Optional HostControllerBaseAddress ... NEED TO BE FILLED 0, // DeviceBaseAddress ... NEED TO BE FILLED 0, // RegionBaseAddress ... NEED TO BE FILLED 0, // Size ... NEED TO BE FILLED @@ -99,6 +100,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { =20 EFI_STATUS NorFlashCreateInstance ( + IN UINTN HostControllerBase, IN UINTN NorFlashDeviceBase, IN UINTN NorFlashRegionBase, IN UINTN NorFlashSize, @@ -118,9 +120,10 @@ NorFlashCreateInstance ( return EFI_OUT_OF_RESOURCES; } =20 - Instance->DeviceBaseAddress =3D NorFlashDeviceBase; - Instance->RegionBaseAddress =3D NorFlashRegionBase; - Instance->Size =3D NorFlashSize; + Instance->HostControllerBaseAddress =3D HostControllerBase; + Instance->DeviceBaseAddress =3D NorFlashDeviceBase; + Instance->RegionBaseAddress =3D NorFlashRegionBase; + Instance->Size =3D NorFlashSize; =20 Instance->BlockIoProtocol.Media =3D &Instance->Media; Instance->Media.MediaId =3D Index; @@ -184,6 +187,27 @@ NorFlashInitialise ( UINT32 Index; NOR_FLASH_DESCRIPTION *NorFlashDevices; BOOLEAN ContainVariableStorage; + EFI_PHYSICAL_ADDRESS HostControllerBaseAddress; + + // Host controller base address region if available + HostControllerBaseAddress =3D PcdGet32 (PcdNorFlashRegBaseAddress); + + if (HostControllerBaseAddress !=3D 0) { + Status =3D gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + HostControllerBaseAddress, + SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + Status =3D gDS->SetMemorySpaceAttributes ( + HostControllerBaseAddress, + SIZE_4KB, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + } =20 Status =3D NorFlashPlatformInitialization (); if (EFI_ERROR (Status)) { @@ -215,6 +239,7 @@ NorFlashInitialise ( } =20 Status =3D NorFlashCreateInstance ( + HostControllerBaseAddress, NorFlashDevices[Index].DeviceBaseAddress, NorFlashDevices[Index].RegionBaseAddress, NorFlashDevices[Index].Size, @@ -368,6 +393,7 @@ NorFlashVirtualNotifyEvent ( UINTN Index; =20 for (Index =3D 0; Index < mNorFlashDeviceCount; Index++) { + EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->HostCon= trollerBaseAddress); EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->DeviceB= aseAddress); EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->RegionB= aseAddress); =20 diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c b/Pl= atform/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 =20 - Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2011 - 2024, Arm Limited. All rights reserved.
Copyright (c) 2020, Linaro, Ltd. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -24,6 +24,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { NOR_FLASH_SIGNATURE, // Signature NULL, // Handle ... NEED TO BE FILLED =20 + 0, // Optional HostControllerBaseAddress ... NEED TO BE FILLED 0, // DeviceBaseAddress ... NEED TO BE FILLED 0, // RegionBaseAddress ... NEED TO BE FILLED 0, // Size ... NEED TO BE FILLED @@ -93,6 +94,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate =3D { =20 EFI_STATUS NorFlashCreateInstance ( + IN UINTN HostControllerBase, IN UINTN NorFlashDeviceBase, IN UINTN NorFlashRegionBase, IN UINTN NorFlashSize, @@ -112,9 +114,10 @@ NorFlashCreateInstance ( return EFI_OUT_OF_RESOURCES; } =20 - Instance->DeviceBaseAddress =3D NorFlashDeviceBase; - Instance->RegionBaseAddress =3D NorFlashRegionBase; - Instance->Size =3D NorFlashSize; + Instance->HostControllerBaseAddress =3D HostControllerBase; + Instance->DeviceBaseAddress =3D NorFlashDeviceBase; + Instance->RegionBaseAddress =3D NorFlashRegionBase; + Instance->Size =3D NorFlashSize; =20 Instance->BlockIoProtocol.Media =3D &Instance->Media; Instance->Media.MediaId =3D Index; @@ -194,6 +197,7 @@ NorFlashInitialise ( } =20 Status =3D NorFlashCreateInstance ( + PcdGet32 (PcdNorFlashRegBaseAddress), NorFlashDevices[Index].DeviceBaseAddress, NorFlashDevices[Index].RegionBaseAddress, NorFlashDevices[Index].Size, --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119325): https://edk2.groups.io/g/devel/message/119325 Mute This Topic: https://groups.io/mt/106365460/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-