From nobody Sun May 5 05:21:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616111533; cv=none; d=zohomail.com; s=zohoarc; b=XYzDLNCe8X8l7uV2GC0R1rHJUDPceM8l9e9tH9sHQ8mtM+8Xd0BSQq5tG2XF//SiLQeiY2ZNAA7vfzP9CBrKAiEfnqrc5t6AytsA+AcQm+eZZZrOMBvorQjHUG709109r95pD1FODnCgz9qYVclRXwVHfn0HewEuVB/I5UcmK5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616111533; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x13jOv6p5ZKtBsoiPdNatA0i4cn/Vn7K24BQ9Ry81WM=; b=C79P7ejeEcBRbbsYx5+veMDD+Hi+etEp1fiPyULRl8ag98j3CdDc/EC1OaekMrHAqPRuY3j6zJQ2vkMih7QG24dvdICjmb6aadNn06F0PLvvQI8L7ZuigbkaIySwlj/SGiDKPJ2y4JPFXcseffmxSdoEBMBOwa1g/VgNEQjYmzc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616111533695214.62680323672396; Thu, 18 Mar 2021 16:52:13 -0700 (PDT) Received: from localhost ([::1]:54876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN2R2-0000rX-Gu for importer@patchew.org; Thu, 18 Mar 2021 19:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN2Pq-0007y0-9o; Thu, 18 Mar 2021 19:50:58 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:59369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN2Po-00029X-7Y; Thu, 18 Mar 2021 19:50:58 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 60F125C01BB; Thu, 18 Mar 2021 19:50:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 18 Mar 2021 19:50:55 -0400 Received: from ravenlin.tomodachi (119-18-31-135.77121f.mel.static.aussiebb.net [119.18.31.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 9A81F1080066; Thu, 18 Mar 2021 19:50:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kivikakk.ee; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=x13jOv6p5ZKtB soiPdNatA0i4cn/Vn7K24BQ9Ry81WM=; b=VBXA5g9VyE9OXYlKIyhbX9SzTtQvP ULl6+s3KihcJWwGhycpo4Z5iEWlrWndvDQ+ND7RpALZw1oMvl1URSOINUfpiAeFL 6cxC5pvW459n79trmrz61TcAyJMRD8HMgmENKpydsRgUOLgXCvIvZAl9GC7d1NMZ v5BBrO9HcwlXJpDmB12UTMwjppZWEizYE4E70Ln3oNfy6Br+ee/lZ4+qZemEM2EG get4k97PaJlre/1NObxwnlxwwVFiHNg5HObOeTlxLUtfJsbxv+ez04AplAqRgVG1 z+9u5Zx6qxjMZZUU6+1NXDOjzVfwtho3wve5txiFqgUcfySlo39/Yea3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=x13jOv6p5ZKtBsoiPdNatA0i4cn/Vn7K24BQ9Ry81WM=; b=JC3DZ+Fw W0gkF3RoUJEmLEXqdCBv3X8EHDXU+DQBpeOo4apmNOAhCj1uo5Z7gOomV3rCMWyJ /ulX7M+GR66GPFO6nKxsfwpOeg36sJ6QCo1C2su0whwqN1MZ+9C+XZvnVV9+RPmE AK7j8+662wB+dVHovvmBWPJ+c+wHQBs7l/A0ipAMLOkUCHDK8NsSaYv5/rOTt7up O1HAPxWEqxAMB5K6vNqNWQRWCE8p9dgf3M6r8p9h3lmBXjZ4MIfRHBYKkLka8uBn IfS3+5kiD/WqLWDdUZCYcC1YytEpSu3Zla8PRwTGVX+4xuEilO1Nt8FKsp3jucGS Qmu3ECDt+ry4mg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefjedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetshhhvghr rghhucevohhnnhhorhcuoegrshhhvgeskhhivhhikhgrkhhkrdgvvgeqnecuggftrfgrth htvghrnhepudffkefffeevteeffeejgedugefhgfetieetledttdekvdegffduieefgeek teefnecukfhppeduudelrddukedrfedurddufeehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghshhgvsehkihhvihhkrghkkhdrvggv X-ME-Proxy: From: Asherah Connor To: qemu-devel@nongnu.org Subject: [PATCH v4 1/2] hw/riscv: Add fw_cfg support to virt Date: Fri, 19 Mar 2021 10:50:40 +1100 Message-Id: <20210318235041.17175-2-ashe@kivikakk.ee> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318235041.17175-1-ashe@kivikakk.ee> References: <20210318235041.17175-1-ashe@kivikakk.ee> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.25; envelope-from=ashe@kivikakk.ee; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-riscv@nongnu.org, Sagar Karandikar , Bastian Koppelmann , Asherah Connor , Alistair Francis , Palmer Dabbelt , Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Provides fw_cfg for the virt machine on riscv. This enables using e.g. ramfb later. Signed-off-by: Asherah Connor Reviewed-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v4: * Adapt for changes made in c65d7080d8 "hw/riscv: migrate fdt field to generic MachineState". Changes in v3: * Document why fw_cfg is done when it is. * Move VIRT_FW_CFG before VIRT_FLASH. Changes in v2: * Add DMA support (needed for writes). hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 30 ++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index d139074b02..1de18cdcf1 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -33,6 +33,7 @@ config RISCV_VIRT select SIFIVE_PLIC select SIFIVE_TEST select VIRTIO_MMIO + select FW_CFG_DMA =20 config SIFIVE_E bool diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 0b39101a5e..e96ec4cbbc 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -53,6 +53,7 @@ static const MemMapEntry virt_memmap[] =3D { [VIRT_PLIC] =3D { 0xc000000, VIRT_PLIC_SIZE(VIRT_CPUS_MAX * 2)= }, [VIRT_UART0] =3D { 0x10000000, 0x100 }, [VIRT_VIRTIO] =3D { 0x10001000, 0x1000 }, + [VIRT_FW_CFG] =3D { 0x10100000, 0x18 }, [VIRT_FLASH] =3D { 0x20000000, 0x4000000 }, [VIRT_PCIE_ECAM] =3D { 0x30000000, 0x10000000 }, [VIRT_PCIE_MMIO] =3D { 0x40000000, 0x40000000 }, @@ -507,6 +508,28 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion= *sys_mem, return dev; } =20 +static FWCfgState *create_fw_cfg(const MachineState *mc) +{ + hwaddr base =3D virt_memmap[VIRT_FW_CFG].base; + hwaddr size =3D virt_memmap[VIRT_FW_CFG].size; + FWCfgState *fw_cfg; + char *nodename; + + fw_cfg =3D fw_cfg_init_mem_wide(base + 8, base, 8, base + 16, + &address_space_memory); + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)mc->smp.cpus); + + nodename =3D g_strdup_printf("/fw-cfg@%" PRIx64, base); + qemu_fdt_add_subnode(mc->fdt, nodename); + qemu_fdt_setprop_string(mc->fdt, nodename, + "compatible", "qemu,fw-cfg-mmio"); + qemu_fdt_setprop_sized_cells(mc->fdt, nodename, "reg", + 2, base, 2, size); + qemu_fdt_setprop(mc->fdt, nodename, "dma-coherent", NULL, 0); + g_free(nodename); + return fw_cfg; +} + static void virt_machine_init(MachineState *machine) { const MemMapEntry *memmap =3D virt_memmap; @@ -688,6 +711,13 @@ static void virt_machine_init(MachineState *machine) start_addr =3D virt_memmap[VIRT_FLASH].base; } =20 + /* + * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the dev= ice + * tree cannot be altered and we get FDT_ERR_NOSPACE. + */ + s->fw_cfg =3D create_fw_cfg(machine); + rom_set_fw(s->fw_cfg); + /* Compute the fdt load address in dram */ fdt_load_addr =3D riscv_load_fdt(memmap[VIRT_DRAM].base, machine->ram_size, machine->fdt); diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 632da52018..349fee1f89 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -40,6 +40,7 @@ struct RISCVVirtState { RISCVHartArrayState soc[VIRT_SOCKETS_MAX]; DeviceState *plic[VIRT_SOCKETS_MAX]; PFlashCFI01 *flash[2]; + FWCfgState *fw_cfg; =20 int fdt_size; }; @@ -53,6 +54,7 @@ enum { VIRT_PLIC, VIRT_UART0, VIRT_VIRTIO, + VIRT_FW_CFG, VIRT_FLASH, VIRT_DRAM, VIRT_PCIE_MMIO, --=20 2.20.1 From nobody Sun May 5 05:21:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616111534; cv=none; d=zohomail.com; s=zohoarc; b=QA/JtL/kZMwd057oUNJ9VEW9wjwflauz91FgaukDIn03OGgAx5LWSf3DRPith2ljiMh30juZ4nFrU6XqkduZFowijd8mvwiFrh33zVyyDBeiBX4j73PE6XGTURbd/RIuxH8mdtXjEFrftT+bib7NrA205ETqwv6/JtPg5AWKdV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616111534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RpHArvaZL0gvPutuy5/hQCYXJVo7chw2rZOu8hkWLq8=; b=U9NcCmfu9ymPzIs1mBR4hCrl5QoAnofgS1qLJFhHv5PYsbmQ8sMSPoRHuyBUypKDcIqnTXyUWv1nUHItfALvaSxn4cgcs0N5u7kTWjXripTKtWuZjVSqGHIO+Va7hz943kM9IVFSNUqe/VN0XReBdlFTjBh8rEcuXpVUUbNHVoA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616111534534994.0127500086417; Thu, 18 Mar 2021 16:52:14 -0700 (PDT) Received: from localhost ([::1]:54984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN2R3-0000tx-Gz for importer@patchew.org; Thu, 18 Mar 2021 19:52:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN2Pu-00085C-Vq; Thu, 18 Mar 2021 19:51:03 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN2Ps-0002BV-AJ; Thu, 18 Mar 2021 19:51:02 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6D2315C01BB; Thu, 18 Mar 2021 19:50:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 18 Mar 2021 19:50:59 -0400 Received: from ravenlin.tomodachi (119-18-31-135.77121f.mel.static.aussiebb.net [119.18.31.135]) by mail.messagingengine.com (Postfix) with ESMTPA id ABCE61080057; Thu, 18 Mar 2021 19:50:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kivikakk.ee; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=RpHArvaZL0gvP utuy5/hQCYXJVo7chw2rZOu8hkWLq8=; b=J1KOQXAYVXf2sFhFEYnU6dEV9bp4S pMfoD1QFqccv4w8DX83RUeQDYLHCOZN8NE7g/zLfJ/c+YXVSh8aLQOmCrS2z34bl gRyaryO3FiXlVHlZGia8q1R1ZPx2Oz3jKrbSBU88nbDml67qPlEmAHYsXSWLFDNE CpAVZT1ezvKIGJasOT4Udok1pp/YsqWlHrk/9PLFOVfAID8zsMN0uD7d7U7m8CHo 8L0JnFlYTOv/6k0/tgILnXcWpjNJQMgawxeGwt4g57d1dj3VGZzK0bPcmkDrBiS1 owmK/8uZKdu1T02kMfl4GpGqVp3XUhW/QMnrl9M0YC+cpJgXGLFj/3ojw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=RpHArvaZL0gvPutuy5/hQCYXJVo7chw2rZOu8hkWLq8=; b=dZaKwSey gn5QLXvlzFBpSvWOBjw6lVpf5qtgLp5llntgkG1B5wh/iw/Ms8Ats2hsOQTaX+Gm 5hmyu3tC3mD3NyMmCwYQHjaggfPetufJIcVTHjXVXvTEjvrAZq7zx2w04fDBElJa qCPZMChwZcBGNWQkH4D9XzlxHZ7c2xE6bkS92Rp8AaiFkGwm2ZFmwOycx6nGZ1rt KF4VHPhUfErRjRl2V5OyzopWjdxv1v9vru94YIc75sOyBYDjrfl3izIOEJbWP72L wyh8DUc8c5TiLTg155cXMkDM+LRt6/hKbRVmDqkPuVsY3IYdSuLyiYM6jAN2poFs gE65P1HzpymvDg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefjedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetshhhvghr rghhucevohhnnhhorhcuoegrshhhvgeskhhivhhikhgrkhhkrdgvvgeqnecuggftrfgrth htvghrnhepudffkefffeevteeffeejgedugefhgfetieetledttdekvdegffduieefgeek teefnecukfhppeduudelrddukedrfedurddufeehnecuvehluhhsthgvrhfuihiivgepud enucfrrghrrghmpehmrghilhhfrhhomheprghshhgvsehkihhvihhkrghkkhdrvggv X-ME-Proxy: From: Asherah Connor To: qemu-devel@nongnu.org Subject: [PATCH v4 2/2] hw/riscv: allow ramfb on virt Date: Fri, 19 Mar 2021 10:50:41 +1100 Message-Id: <20210318235041.17175-3-ashe@kivikakk.ee> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210318235041.17175-1-ashe@kivikakk.ee> References: <20210318235041.17175-1-ashe@kivikakk.ee> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.25; envelope-from=ashe@kivikakk.ee; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-riscv@nongnu.org, Sagar Karandikar , Bastian Koppelmann , Asherah Connor , Alistair Francis , Palmer Dabbelt , Bin Meng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Allow ramfb on virt. This lets `-device ramfb' work. Signed-off-by: Asherah Connor Reviewed-by: Bin Meng Reviewed-by: Alistair Francis --- (no changes since v2) Changes in v2: * Add ramfb as allowed on riscv virt machine class. hw/riscv/virt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index e96ec4cbbc..c0dc69ff33 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -42,6 +42,7 @@ #include "sysemu/sysemu.h" #include "hw/pci/pci.h" #include "hw/pci-host/gpex.h" +#include "hw/display/ramfb.h" =20 static const MemMapEntry virt_memmap[] =3D { [VIRT_DEBUG] =3D { 0x0, 0x100 }, @@ -781,6 +782,8 @@ static void virt_machine_class_init(ObjectClass *oc, vo= id *data) mc->cpu_index_to_instance_props =3D riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id =3D riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported =3D true; + + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); } =20 static const TypeInfo virt_machine_typeinfo =3D { --=20 2.20.1