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 7FE6C7803E1 for ; Tue, 23 Apr 2024 14:56:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=4FZ4nXQbsU4uHHETbInhF35YU/ahlr88MMj2IvS4mhc=; 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=1713884161; v=1; b=Qsh/2IZFoJdrxsLyx8SOkJw2eJCCP2dJAVF4r9sBa/NI6bflF4HeAceWmxrnPCVkERZvwxrw qR8e9ezAuf2jtpCMAcyY0/hp8DSvfHscO31IcGmQL2/h8IR0s8Lfow6dMY6nbCZsn+uDm91gCpb 96pYCzjarUupa95xMxHHqgSU2VLo/TUTDl8IMvASR3KvwVsCwXts4Z0O0UueezVTbbE50bvtOyv RtqYBqcDZUqW5mpxZuZ1gZYquvH4YjxZqzX4jc59MceE+lIzj3Onrttn3Yf9OHk5Qj6j7m2Lblk SHax7XVNVFNwgHD5whf8m0FYFa4Qar5GHkg76sOKYkNuA== X-Received: by 127.0.0.2 with SMTP id DMnDYY7687511xh7QXU2xTso; Tue, 23 Apr 2024 07:56:01 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.12027.1713851828207576702 for ; Mon, 22 Apr 2024 22:57:08 -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 00906339; Mon, 22 Apr 2024 22:57: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 46FC53F7BD; Mon, 22 Apr 2024 22:57:06 -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] [PATCH RESEND edk2-platforms][PATCH V2 08/14] Platform/ARM: Add HostRegisterBaseAddress variable Date: Tue, 23 Apr 2024 11:26:32 +0530 Message-Id: <20240423055638.1271531-9-Sahil.Kaushal@arm.com> In-Reply-To: <20240423055638.1271531-1-Sahil.Kaushal@arm.com> References: <20240423055638.1271531-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: Tue, 23 Apr 2024 07:55:50 -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: 811idyR3zfV5y1nPYbALA0yYx7686176AA= 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="Qsh/2IZF"; 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 | 1 + Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c | 34 +++++++++++= ++++++--- Platform/ARM/Drivers/NorFlashDxe/NorFlashStandaloneMm.c | 12 ++++--- 7 files changed, 48 insertions(+), 8 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 e5017130a091..29b8b8901525 100644 --- a/Platform/ARM/Include/Library/NorFlashDeviceLib.h +++ b/Platform/ARM/Include/Library/NorFlashDeviceLib.h @@ -29,6 +29,7 @@ struct _NOR_FLASH_INSTANCE { UINT32 Signature;=0D EFI_HANDLE Handle;=0D =0D + UINTN HostRegisterBaseAddress;=0D UINTN DeviceBaseAddress;=0D UINTN RegionBaseAddress;=0D UINTN Size;=0D diff --git a/Platform/ARM/Drivers/NorFlashDxe/NorFlashDxe.c b/Platform/ARM/= Drivers/NorFlashDxe/NorFlashDxe.c index 1c12572ab663..f5c0dadf84e0 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, // HostRegisterBaseAddress ... 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 HostRegisterBase,=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->HostRegisterBaseAddress =3D HostRegisterBase;=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 HostRegisterBaseAddress;=0D +=0D + // Register host register region if available=0D + HostRegisterBaseAddress =3D PcdGet32 (PcdNorFlashRegBaseAddress);=0D +=0D + if (HostRegisterBaseAddress !=3D 0) {=0D + Status =3D gDS->AddMemorySpace (=0D + EfiGcdMemoryTypeMemoryMappedIo,=0D + HostRegisterBaseAddress,=0D + SIZE_4KB,=0D + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + Status =3D gDS->SetMemorySpaceAttributes (=0D + HostRegisterBaseAddress,=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 + HostRegisterBaseAddress,=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]->HostRegis= terBaseAddress);=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..ef9bed37d140 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, // HostRegisterBaseAddress ... 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 HostRegisterBase,=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->HostRegisterBaseAddress =3D HostRegisterBase;=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 (#118158): https://edk2.groups.io/g/devel/message/118158 Mute This Topic: https://groups.io/mt/105690943/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-