From patchwork Tue Nov 3 15:21:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39418697 for ; Tue, 3 Nov 2020 15:41:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA4E5206CA for ; Tue, 3 Nov 2020 15:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Xw1g51n1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA4E5206CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyR3-0004o0-RF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:41:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJO-0001LU-BQ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:30 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJK-0001FT-U8 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417607; x=1635953607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bxfmTayuMlAkbdWAwkDMu9qmrbCTEm5F3jlbPoZ/kFE=; b=Xw1g51n1RRvtIQV0X+Vqlai9/4IvAui2mYWAdR3ZJ7+QjWjKc61HiI64 txJagizXtDkXpa385yTspJsEzL5HOSVtJdvNgXcWeT6VFB8xQg+DNzIzQ EMKA0YMkBz6MCetFQe+uuLzPjpsl5ERsVPdug1E+sCyZEM+MQQ8niT8B8 jBnuYKgH6CQS8a8itaO7a1VgJuS9u2L2eNz5bSgeK3zE9Irs3DROG4bXZ LmIbECBNLtBBcVMk3SMSqLFXnzZur8Y+q9GY4DUCsmHKO+VTsBjixNoOY 4eZiQN8IY4i24SeCcNMqTO8O1y/DIVvmcUYNqIEVJDR5Dw4APwx1AEQP+ w==; IronPort-SDR: 5Cp4p1Qn5d0EpSlKfMYxYvjbm1ILCuxccATXY6EAVFyPEtxkqVYyH/fi2XasuyWU6t2aMm7Vx4 ITiL3j2MiCYfbC9b35mj0ARWHM6e6mNW6Lqa8IO9/qttcaR9H90fHB4vl7U82g13jpgQSZOlc9 BERmpS7YBaqQojAT7H+U6Q6oQhAGAuSiaXKx9UGDrr7VRyTMem3KLB0nTezFFFLDUfKejQkIJQ 3TvWxwKUvJwXidgd2xd6ty/gwxLrYiYLZpwSnrQIfayzJk5Etbt67ujYnVFliJwo13LP+vOqvS T44= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867448" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:24 +0800 IronPort-SDR: LqLRVBZfHp+arN0o7N2LidaP5jag88m2mZKfUOxaSayg4kvj+GTgdFH+L4inRPNB9b1dL3ngR1 rtRmKhua3B6onEVKv3I1IvSiWyFijhNaAVK26yLlzsT/E6NhbRWkz2Py1/NrDTiWFs7EwcPvrV 3xp3k98+u2aN53greBh/Q2Qn9wGZGhEbtmpTpeOGbf0Aw986vo9RwzN6dhEps+EXuXu1aN9G5e I0gQb79otCuYywbYSEP4WR7/pYqN+r5td+PdnKLV6CNGnQcbBDvmn93uQ5mtbK0Ue5QcstoP59 PIds6T4rWktwhKi9ItzGcyyu Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:32 -0800 IronPort-SDR: d7jjGrTv0QmwftNlaBPkEXcnyaFEz5TG72GXJ28q/ou8fugFd7V/vOMFUyIGFPJae5MjiR+Tgx J1z6cefoCOJHDDehALb98kyr48SVDXE355J1rhUjmkNvYqHJoZxU4r/ehJEkYEQqeFFHcQ1Cog Ovh9dir0joI0JZAxnHqlFJclnOj4jewETTsqjA8wJPVSKyJu2+jnCzsj0IE2PsTWmJGOkWXDRz ajbtlTbAQPeLAwGET0gEqyOHnb4aSWdlUZ6s9dqCjX/ZK9jvfZ/5OkXmFPe5XORH8K3ZuFbm33 eZQ= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:24 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 01/19] hw/riscv: sifive_u: Allow passing custom DTB Date: Tue, 3 Nov 2020 07:21:32 -0800 Message-Id: <20201103152150.2677566-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Anup Patel , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Anup Patel Extend sifive_u machine to allow passing custom DTB using "-dtb" command-line parameter. This will help users pass modified DTB or Linux SiFive DTB to sifive_u machine. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Message-id: 20201022053225.2596110-1-anup.patel@wdc.com Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b2472c6627..2f19a9cda2 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -100,14 +100,25 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, int cpu; uint32_t *cells; char *nodename; + const char *dtb_filename; char ethclk_names[] = "pclk\0hclk"; uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1; uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle; - fdt = s->fdt = create_device_tree(&s->fdt_size); - if (!fdt) { - error_report("create_device_tree() failed"); - exit(1); + dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb"); + if (dtb_filename) { + fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size); + if (!fdt) { + error_report("load_device_tree() failed"); + exit(1); + } + goto update_bootargs; + } else { + fdt = s->fdt = create_device_tree(&s->fdt_size); + if (!fdt) { + error_report("create_device_tree() failed"); + exit(1); + } } qemu_fdt_setprop_string(fdt, "/", "model", "SiFive HiFive Unleashed A00"); @@ -390,13 +401,14 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_add_subnode(fdt, "/chosen"); qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename); - if (cmdline) { - qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline); - } - qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename); g_free(nodename); + +update_bootargs: + if (cmdline) { + qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline); + } } static void sifive_u_machine_reset(void *opaque, int n, int level) From patchwork Tue Nov 3 15:21:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B5C592C for ; Tue, 3 Nov 2020 15:35:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA66720735 for ; Tue, 3 Nov 2020 15:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="qtf8U7+z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA66720735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyLJ-0003Rp-TW for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:35:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJO-0001ME-MJ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:30 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJL-0001Fa-68 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417607; x=1635953607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TzxgUt8qZfaREE4D9HrT8ndkP8t5MJfPtFf4kMe2y/8=; b=qtf8U7+zQnBuRL4wOWzd49aJhtDQgsjptwNezzqhTvtJPp/6Xydv9Zq0 ZJ+RfxTEZMhpWu2hIi3PzfCJHz1+Qn4JGEe4u5nH9AUyXqAAHtuDpis80 rtTWNX8RsKDs346MIpRUWWKjoF42wil2ijDKJ0aJVvLzORdGqn2vzw1Q2 imqmYV3G+ECRNpOzFtwX7nVQjrmJWbP4wVpKNrgDNvwLj+7Ua8RM9uP5E eQAGWPi6gIgQk2Nf1ZbbesPQ3ybh/gKo/uESUHRez50r9vEW8kJ05eoDn TQh9UPyGJ4GAMaJPrZafzNxuG+F4npfp3GvDcn69EL+i35qdpVDhFzatR Q==; IronPort-SDR: RFCaP+H0TMDknHLA0k+KnvOyuTtkyvrebUrMRyn+PGtgucrtWHT81z5szAg4BaDgweWmEngzjk 3mOUGti4JmPvqDGGvxOlArIZMoWLCPly1ArOKI0hJ67C+waEwcg+eOx7JaM2/EwrYWxgwlOzHK JohXtpjwy2pdHb7Ze8FCflGxiVIOonumd616YIOx/RXCmKi81VTi2kIiIPm0+BJ+KMPO8z99Gp PsixK8TEVwnQdUsuG9esmSC+45GdX2I4xtF7ZCqpukqnqTHUjYDk4h9vR47HCHglFi5S2nSyY5 lEc= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867450" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:24 +0800 IronPort-SDR: WWfRwdT+RgOZoqgRPAoROpkkg4+ywi7w+a6SJhGr4km9kZrQyfGyHQME7XIeYr33bleHolyphp tf0snJpjK7ldC5bn6f4eD3/miQ8FpkVe7RmdYiMk0JVIIKjHSE4vzdV4dMMyKNEcngia1vtDoa AYbpYYBNJfuJfmpiGYw2tPsTSdjhy2skjCallDTbYWySmpIlA5mFrivWen5UcYx0Fr/Sbq89pk 4LEZEO9kuwbrTaZ8qp60AALI/8TWfqILlDYI5Y79idW1m1Hi+o+JCrxlbv85qbEvy5HBqdH0Iq I2BZlmeqCyw9xQnWBB91TV/A Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:32 -0800 IronPort-SDR: 9SxSLGmg9J+s8zAFGmKh7pwsbxWynnMIeHFyv4C6l9Dftkl7X5p8npuKZdA1xA3aNSCnK0/m1T Rpaq+dAiQYJEDv46gv6zotd7OpR7BEexpjMnGaLUCJ+Y8ZSV6LrdWIJg/bFQjK4rUgLIp4h9BD Lj4tpFzV8ZNkDvIUOUeXcbqgw3rpG7du4O31l9RRmDNCiblVvi5fR6yiwMn3f+SntAWqHF/RAd monrF3/mSH6kXHu3SvMJt6W7MXY9IOYHEpAVHEGiKfpwBnf/a32Fhx0rinQyASUEZjdg+x5FJ/ BGQ= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:24 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 02/19] hw/riscv: virt: Allow passing custom DTB Date: Tue, 3 Nov 2020 07:21:33 -0800 Message-Id: <20201103152150.2677566-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Anup Patel , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Anup Patel Extend virt machine to allow passing custom DTB using "-dtb" command-line parameter. This will help users pass modified DTB to virt machine. Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Message-id: 20201022053225.2596110-2-anup.patel@wdc.com Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 6bfd10dfc7..25cea7aa67 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -181,6 +181,7 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, { void *fdt; int i, cpu, socket; + const char *dtb_filename; MachineState *mc = MACHINE(s); uint64_t addr, size; uint32_t *clint_cells, *plic_cells; @@ -194,10 +195,20 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, hwaddr flashsize = virt_memmap[VIRT_FLASH].size / 2; hwaddr flashbase = virt_memmap[VIRT_FLASH].base; - fdt = s->fdt = create_device_tree(&s->fdt_size); - if (!fdt) { - error_report("create_device_tree() failed"); - exit(1); + dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb"); + if (dtb_filename) { + fdt = s->fdt = load_device_tree(dtb_filename, &s->fdt_size); + if (!fdt) { + error_report("load_device_tree() failed"); + exit(1); + } + goto update_bootargs; + } else { + fdt = s->fdt = create_device_tree(&s->fdt_size); + if (!fdt) { + error_report("create_device_tree() failed"); + exit(1); + } } qemu_fdt_setprop_string(fdt, "/", "model", "riscv-virtio,qemu"); @@ -418,9 +429,6 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_add_subnode(fdt, "/chosen"); qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", name); - if (cmdline) { - qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline); - } g_free(name); name = g_strdup_printf("/soc/rtc@%lx", (long)memmap[VIRT_RTC].base); @@ -441,6 +449,11 @@ static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, 2, flashbase + flashsize, 2, flashsize); qemu_fdt_setprop_cell(s->fdt, name, "bank-width", 4); g_free(name); + +update_bootargs: + if (cmdline) { + qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline); + } } static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, From patchwork Tue Nov 3 15:21:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B918A92A for ; Tue, 3 Nov 2020 15:55:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AA3620786 for ; Tue, 3 Nov 2020 15:55:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Y5XsapLn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AA3620786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyer-0007XD-W1 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:55:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJQ-0001PL-6z for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:32 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJN-0001EJ-GZ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417610; x=1635953610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PVCZQUTeCw2di1b+MS8hAMMWVCYqpu2LLmTnEQBfmSQ=; b=Y5XsapLn7t2iDM11OAifYwJFO4Xi060CFoCcRxLAwhrQ1IDE+R0qDak2 Sxwl7aWde5JR5XqrzWpr4zaXqn9lv8Zg1JKOyby7eGIMhO4a+wCOh7+hy KbdS+XkHQkGpJKNZf5QA6fibocbYGcISzxOJb+LYFxnakjQTB//iMUGRa O+yWYvzbNUUQLQ4I7FAC10rwjyIB/Y6xFgqbGgXSJ3/E2qui+VpqHeKjo qjfBfU098kodCQNTF/9HeEVVCQKhZBrczE4OyLrXU+gV5bsMHK/TWlCJN qYAU+4aK5Ix+pjiV6wuRhHXJKu05BTGoY5iXPS8t6R0Z39gVUQckzNO0q w==; IronPort-SDR: Gs3Dngyo5mJysqnta+SqGY0LCnrYRl3tYw6+X3iCRa8QD7K5poSHrUjNdKWomb1r2eU2n9Tf6r iLa7MUMz70IDM/gNQhkxAGS6SlbzsDTPKW5XaQEbHgcAG7lR70D77UjegZaFif0dvFSkl3MDxD /6wYYo49ljdRZiYqL+oGhr1+92kPj5z+dNO+TZfC8N2rv00So3RlG30ZK/m+TCBfagJZqNq4BQ O7mBSlirIv9eVeJ6q9C0EkVqTCJQprpiBqUunaa/o0sPZ26IbDgBHZgeSVR+tKtD4emH7HCuVq 9kI= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867454" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:24 +0800 IronPort-SDR: Zi4p46t85+hShEKgKVOdrahJwtWDpWfMEjQmftiU6bYzPHMd7uljgZVfcMC+Rhjv5wbzyc/0wq Yyt9oPiCQJh/v/C0QTEaQu65tZ7ycGffCmztLwqm5iidXW8WU5uGQl2mQOzJlMI+w1kUatpGzd W0DAC2+e8w4aRX5dV7znFrvobGYv9e6pQOryAGTlImgwpSpJwSln+G+yoIusfmsngtxC5PrvNR 3KuY93oKYFCZDKO7SNbJArCwjKVu0kZFxBCci2nIn9zkYtikf1A6c4JPUW1If3dA0f8FCRbnaw ic3Zs2UpBfs+PlapQ167gUK+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:33 -0800 IronPort-SDR: t5vYzcgZjs4mosSPNQ3ZPZHc8/wvMMfZndxWUn4rCMgDPc0J8xwWYmmNfya137FA4XOFlPy2XK fQiZOtd5WjKcFtWd1swgdb/jXUjXBr0yH8ZmkRFMTVd6C9GOfQpRTr4cHWoxxQ19+WEQ9lpQui YGKpry+YJheJss+nYihZpsAsxGndoqqVh68mhiHBQjVRXZQOyeZg1G1YicbGun98GF0nmYEXeZ EsCZ/OvHyApinNbBvdlR0Zmj7LZoJsESB+YKOLXt8KbffPp7oBxDHcE4K+xK8yr+SLseFi0gg1 aYk= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:25 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 03/19] target/riscv: Merge m/vsstatus and m/vsstatush into one uint64_t unit Date: Tue, 3 Nov 2020 07:21:34 -0800 Message-Id: <20201103152150.2677566-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang mstatus/mstatush and vsstatus/vsstatush are two halved for RISCV32. This patch expands mstatus and vsstatus to uint64_t instead of target_ulong so that it can be saved as one unit and reduce some ifdefs in the code. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Signed-off-by: Alistair Francis Reviewed-by: Alistair Francis Message-id: 20201026115530.304-2-jiangyifei@huawei.com --- target/riscv/cpu.h | 24 +++++++++++------------- target/riscv/cpu_bits.h | 19 ++++--------------- target/riscv/cpu.c | 8 +++++--- target/riscv/cpu_helper.c | 35 +++++++---------------------------- target/riscv/csr.c | 18 ++++++++++-------- target/riscv/op_helper.c | 11 ++++------- 6 files changed, 41 insertions(+), 74 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index de4705bb57..87b68affa8 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -144,14 +144,14 @@ struct CPURISCVState { target_ulong resetvec; target_ulong mhartid; - target_ulong mstatus; + /* + * For RV32 this is 32-bit mstatus and 32-bit mstatush. + * For RV64 this is a 64-bit mstatus. + */ + uint64_t mstatus; target_ulong mip; -#ifdef TARGET_RISCV32 - target_ulong mstatush; -#endif - uint32_t miclaim; target_ulong mie; @@ -183,16 +183,17 @@ struct CPURISCVState { uint64_t htimedelta; /* Virtual CSRs */ - target_ulong vsstatus; + /* + * For RV32 this is 32-bit vsstatus and 32-bit vsstatush. + * For RV64 this is a 64-bit vsstatus. + */ + uint64_t vsstatus; target_ulong vstvec; target_ulong vsscratch; target_ulong vsepc; target_ulong vscause; target_ulong vstval; target_ulong vsatp; -#ifdef TARGET_RISCV32 - target_ulong vsstatush; -#endif target_ulong mtval2; target_ulong mtinst; @@ -204,10 +205,7 @@ struct CPURISCVState { target_ulong scause_hs; target_ulong stval_hs; target_ulong satp_hs; - target_ulong mstatus_hs; -#ifdef TARGET_RISCV32 - target_ulong mstatush_hs; -#endif + uint64_t mstatus_hs; target_ulong scounteren; target_ulong mcounteren; diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index bd36062877..daedad8691 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -4,10 +4,10 @@ #define TARGET_RISCV_CPU_BITS_H #define get_field(reg, mask) (((reg) & \ - (target_ulong)(mask)) / ((mask) & ~((mask) << 1))) -#define set_field(reg, mask, val) (((reg) & ~(target_ulong)(mask)) | \ - (((target_ulong)(val) * ((mask) & ~((mask) << 1))) & \ - (target_ulong)(mask))) + (uint64_t)(mask)) / ((mask) & ~((mask) << 1))) +#define set_field(reg, mask, val) (((reg) & ~(uint64_t)(mask)) | \ + (((uint64_t)(val) * ((mask) & ~((mask) << 1))) & \ + (uint64_t)(mask))) /* Floating point round mode */ #define FSR_RD_SHIFT 5 @@ -381,19 +381,8 @@ #define MSTATUS_TVM 0x00100000 /* since: priv-1.10 */ #define MSTATUS_TW 0x20000000 /* since: priv-1.10 */ #define MSTATUS_TSR 0x40000000 /* since: priv-1.10 */ -#if defined(TARGET_RISCV64) #define MSTATUS_GVA 0x4000000000ULL #define MSTATUS_MPV 0x8000000000ULL -#elif defined(TARGET_RISCV32) -#define MSTATUS_GVA 0x00000040 -#define MSTATUS_MPV 0x00000080 -#endif - -#ifdef TARGET_RISCV32 -# define MSTATUS_MPV_ISSET(env) get_field(env->mstatush, MSTATUS_MPV) -#else -# define MSTATUS_MPV_ISSET(env) get_field(env->mstatus, MSTATUS_MPV) -#endif #define MSTATUS64_UXL 0x0000000300000000ULL #define MSTATUS64_SXL 0x0000000C00000000ULL diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 0bbfd7f457..dd05a220c7 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -216,13 +216,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc); #ifndef CONFIG_USER_ONLY qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", env->mstatus); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus); #ifdef TARGET_RISCV32 - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ", env->mstatush); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ", + (target_ulong)(env->mstatus >> 32)); #endif if (riscv_has_ext(env, RVH)) { qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatus); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus ", env->vsstatus); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus ", + (target_ulong)env->vsstatus); } qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4652082df1..3eb3a034db 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -110,27 +110,19 @@ bool riscv_cpu_fp_enabled(CPURISCVState *env) void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) { - target_ulong mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS | - MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE; + uint64_t mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS | + MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE | + MSTATUS64_UXL; bool current_virt = riscv_cpu_virt_enabled(env); g_assert(riscv_has_ext(env, RVH)); -#if defined(TARGET_RISCV64) - mstatus_mask |= MSTATUS64_UXL; -#endif - if (current_virt) { /* Current V=1 and we are about to change to V=0 */ env->vsstatus = env->mstatus & mstatus_mask; env->mstatus &= ~mstatus_mask; env->mstatus |= env->mstatus_hs; -#if defined(TARGET_RISCV32) - env->vsstatush = env->mstatush; - env->mstatush |= env->mstatush_hs; -#endif - env->vstvec = env->stvec; env->stvec = env->stvec_hs; @@ -154,11 +146,6 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) env->mstatus &= ~mstatus_mask; env->mstatus |= env->vsstatus; -#if defined(TARGET_RISCV32) - env->mstatush_hs = env->mstatush; - env->mstatush |= env->vsstatush; -#endif - env->stvec_hs = env->stvec; env->stvec = env->vstvec; @@ -727,7 +714,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, if (riscv_has_ext(env, RVH) && env->priv == PRV_M && access_type != MMU_INST_FETCH && get_field(env->mstatus, MSTATUS_MPRV) && - MSTATUS_MPV_ISSET(env)) { + get_field(env->mstatus, MSTATUS_MPV)) { riscv_cpu_set_two_stage_lookup(env, true); } @@ -799,7 +786,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, if (riscv_has_ext(env, RVH) && env->priv == PRV_M && access_type != MMU_INST_FETCH && get_field(env->mstatus, MSTATUS_MPRV) && - MSTATUS_MPV_ISSET(env)) { + get_field(env->mstatus, MSTATUS_MPV)) { riscv_cpu_set_two_stage_lookup(env, false); } @@ -862,7 +849,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; bool force_hs_execp = riscv_cpu_force_hs_excep_enabled(env); - target_ulong s; + uint64_t s; /* cs->exception is 32-bits wide unlike mcause which is XLEN-bits wide * so we mask off the MSB and separate into trap type and cause. @@ -995,19 +982,11 @@ void riscv_cpu_do_interrupt(CPUState *cs) if (riscv_cpu_virt_enabled(env)) { riscv_cpu_swap_hypervisor_regs(env); } -#ifdef TARGET_RISCV32 - env->mstatush = set_field(env->mstatush, MSTATUS_MPV, - riscv_cpu_virt_enabled(env)); - if (riscv_cpu_virt_enabled(env) && tval) { - env->mstatush = set_field(env->mstatush, MSTATUS_GVA, 1); - } -#else env->mstatus = set_field(env->mstatus, MSTATUS_MPV, - riscv_cpu_virt_enabled(env)); + riscv_cpu_virt_enabled(env)); if (riscv_cpu_virt_enabled(env) && tval) { env->mstatus = set_field(env->mstatus, MSTATUS_GVA, 1); } -#endif mtval2 = env->guest_phys_fault_addr; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index aaef6c6f20..e33f6cdc11 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -446,8 +446,8 @@ static int validate_vm(CPURISCVState *env, target_ulong vm) static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) { - target_ulong mstatus = env->mstatus; - target_ulong mask = 0; + uint64_t mstatus = env->mstatus; + uint64_t mask = 0; int dirty; /* flush tlb on mstatus fields that affect VM */ @@ -480,19 +480,20 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) #ifdef TARGET_RISCV32 static int read_mstatush(CPURISCVState *env, int csrno, target_ulong *val) { - *val = env->mstatush; + *val = env->mstatus >> 32; return 0; } static int write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { - if ((val ^ env->mstatush) & (MSTATUS_MPV)) { + uint64_t valh = (uint64_t)val << 32; + uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; + + if ((valh ^ env->mstatus) & (MSTATUS_MPV)) { tlb_flush(env_cpu(env)); } - val &= MSTATUS_MPV | MSTATUS_GVA; - - env->mstatush = val; + env->mstatus = (env->mstatus & ~mask) | (valh & mask); return 0; } @@ -1105,7 +1106,8 @@ static int read_vsstatus(CPURISCVState *env, int csrno, target_ulong *val) static int write_vsstatus(CPURISCVState *env, int csrno, target_ulong val) { - env->vsstatus = val; + uint64_t mask = (target_ulong)-1; + env->vsstatus = (env->vsstatus & ~mask) | (uint64_t)val; return 0; } diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 4ce73575a7..e20d56dcb8 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -78,7 +78,8 @@ target_ulong helper_csrrc(CPURISCVState *env, target_ulong src, target_ulong helper_sret(CPURISCVState *env, target_ulong cpu_pc_deb) { - target_ulong prev_priv, prev_virt, mstatus; + uint64_t mstatus; + target_ulong prev_priv, prev_virt; if (!(env->priv >= PRV_S)) { riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); @@ -147,18 +148,14 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb) riscv_raise_exception(env, RISCV_EXCP_INST_ADDR_MIS, GETPC()); } - target_ulong mstatus = env->mstatus; + uint64_t mstatus = env->mstatus; target_ulong prev_priv = get_field(mstatus, MSTATUS_MPP); - target_ulong prev_virt = MSTATUS_MPV_ISSET(env); + target_ulong prev_virt = get_field(env->mstatus, MSTATUS_MPV); mstatus = set_field(mstatus, MSTATUS_MIE, get_field(mstatus, MSTATUS_MPIE)); mstatus = set_field(mstatus, MSTATUS_MPIE, 1); mstatus = set_field(mstatus, MSTATUS_MPP, PRV_U); -#ifdef TARGET_RISCV32 - env->mstatush = set_field(env->mstatush, MSTATUS_MPV, 0); -#else mstatus = set_field(mstatus, MSTATUS_MPV, 0); -#endif env->mstatus = mstatus; riscv_cpu_set_mode(env, prev_priv); From patchwork Tue Nov 3 15:21:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878123 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECB2A92C for ; Tue, 3 Nov 2020 15:35:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A423020735 for ; Tue, 3 Nov 2020 15:35:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="BJnPBrZV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A423020735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyLH-0003MU-MG for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:35:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJT-0001Vg-0k for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:35 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJO-0001FT-L0 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417611; x=1635953611; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cMeZtoj9DB4HkpjRauvIaJM+wOrM0RhLa9f8ywoWSAE=; b=BJnPBrZVcQVcxeZbrUQHpA8onZ6cN28wYQSSVzYWBGRqr3PPzE5rNyK8 Gv3Bqz89e1HqA6NvzDLmC2Qw/y0Gz2dOTgyh+SpXkYRz9R4oiWExBQ7kg mRyeD6aNeBnPKIfcfpMz23Sh7CRfOIwytBrqRv6qoRx65KBRKKVoHJnc9 EXgfBDP949CFFPl/aV0mpXSL4/vxgp44xT8T+VW1K8PSplEUb2q35ZQyI Y2DsQtmChre14sveEAiqfhlXnFxOvKxrIEYvmID78pHX6LwflTwwWfEYR 6m5Lv0vtAJoDcI75j66X2NEqFL7SSSR7VWqryLQLAYljiess9wi1v+mq8 A==; IronPort-SDR: YUQElEpCtaL2lBp9fZ9Hs+aDVZB4/uHCMPcUvEJ61BwaHr089c+PppaSVNRZBcxxK0rf4/Hphv ri/pQ++yP3Cfw20ySKTzyIcVydTsalqzV6hBhqF4QQeKUn+6nCuZp2iWffCIgWlXj+LWZI0SVl 1qwY+UlmOerC+NVrwwzyeKYZHjr+voJFL2U3J+1b/XhLNyGqsLLls8t4xOs3rdsXtZdomc5sq+ UXmciehh0Ws+0/Ac4XHwJeEZIk0gsyMwmRXqc+9NBu2ubuEH1K67qfFoT9kkrhcCQOB3KDm4zW 31g= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867455" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:24 +0800 IronPort-SDR: jNK5cTJTu7bM4AVRQIjLK5ik8VyjEoJog9YBWejKKn1lLa/3+9/watmV4+pQ+E1hNWbicrOJjg r341CFVYJKNLswg1eucJE+aItT0ZEQ+As0Z9lD0ESXyfmnTo6HW/bKGAaO/PVajjl0aahYl68h oZjCVTXwL5T4Qs6tmR8miOqE4x0FfjTK8w/DhLjFqFsJwqfFctSgJkDNXscH30FXb7qdJ6tfSy JVrgrLQ8vuUdNRWSw/fccBg+VPXC4hgcgL32GQ7CVkDoGXVdbCuvPkWsGrGZ+Nto7GEAzQkkQ3 /s1LfhBWWmNXImDUm/ST0ADk Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:33 -0800 IronPort-SDR: chYPQj2SrOYmYMZYFMEHHCc0hg92fTGAoBhlXHngo/w0uj3JD89H+mSgoE87NdDGzJRy4v9OSq bZTD6/5/G+uRcRRM6TRLcbNvj+4/GGAOWbbKzpfs5exkaW3P0xp0R5CxFbJ3PmxgFd6O8hoNQm efFbThapH7FoPYW39An6GyZ7yRhsoMhK1IvsVbtCyafRoLH+CxpArUHM39lltykkKFqX4kFmnZ zdC0ily8Aqa40Av2Vqi1JZkikyKc1kqqfDEyUOCs6fYJCnxaaeBrC/IToov7nxkDYsUGqrHaCs 8wM= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:25 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 04/19] target/riscv: Add basic vmstate description of CPU Date: Tue, 3 Nov 2020 07:21:35 -0800 Message-Id: <20201103152150.2677566-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang Add basic CPU state description to the newly created machine.c Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis Message-id: 20201026115530.304-3-jiangyifei@huawei.com Signed-off-by: Alistair Francis --- target/riscv/internals.h | 4 +++ target/riscv/cpu.c | 8 +---- target/riscv/machine.c | 74 ++++++++++++++++++++++++++++++++++++++++ target/riscv/meson.build | 3 +- 4 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 target/riscv/machine.c diff --git a/target/riscv/internals.h b/target/riscv/internals.h index f1a546dba6..b15ad394bb 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -38,6 +38,10 @@ target_ulong fclass_d(uint64_t frs1); #define SEW32 2 #define SEW64 3 +#ifndef CONFIG_USER_ONLY +extern const VMStateDescription vmstate_riscv_cpu; +#endif + static inline uint64_t nanbox_s(float32 f) { return f | MAKE_64BIT_MASK(32, 32); diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index dd05a220c7..6a0264fc6b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -22,6 +22,7 @@ #include "qemu/ctype.h" #include "qemu/log.h" #include "cpu.h" +#include "internals.h" #include "exec/exec-all.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -498,13 +499,6 @@ static void riscv_cpu_init(Object *obj) cpu_set_cpustate_pointers(cpu); } -#ifndef CONFIG_USER_ONLY -static const VMStateDescription vmstate_riscv_cpu = { - .name = "cpu", - .unmigratable = 1, -}; -#endif - static Property riscv_cpu_properties[] = { DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true), DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false), diff --git a/target/riscv/machine.c b/target/riscv/machine.c new file mode 100644 index 0000000000..32edbcba7c --- /dev/null +++ b/target/riscv/machine.c @@ -0,0 +1,74 @@ +/* + * RISC-V VMState Description + * + * Copyright (c) 2020 Huawei Technologies Co., Ltd + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "qemu/error-report.h" +#include "sysemu/kvm.h" +#include "migration/cpu.h" + +const VMStateDescription vmstate_riscv_cpu = { + .name = "cpu", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), + VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32), + VMSTATE_UINTTL(env.pc, RISCVCPU), + VMSTATE_UINTTL(env.load_res, RISCVCPU), + VMSTATE_UINTTL(env.load_val, RISCVCPU), + VMSTATE_UINTTL(env.frm, RISCVCPU), + VMSTATE_UINTTL(env.badaddr, RISCVCPU), + VMSTATE_UINTTL(env.guest_phys_fault_addr, RISCVCPU), + VMSTATE_UINTTL(env.priv_ver, RISCVCPU), + VMSTATE_UINTTL(env.vext_ver, RISCVCPU), + VMSTATE_UINTTL(env.misa, RISCVCPU), + VMSTATE_UINTTL(env.misa_mask, RISCVCPU), + VMSTATE_UINT32(env.features, RISCVCPU), + VMSTATE_UINTTL(env.priv, RISCVCPU), + VMSTATE_UINTTL(env.virt, RISCVCPU), + VMSTATE_UINTTL(env.resetvec, RISCVCPU), + VMSTATE_UINTTL(env.mhartid, RISCVCPU), + VMSTATE_UINT64(env.mstatus, RISCVCPU), + VMSTATE_UINTTL(env.mip, RISCVCPU), + VMSTATE_UINT32(env.miclaim, RISCVCPU), + VMSTATE_UINTTL(env.mie, RISCVCPU), + VMSTATE_UINTTL(env.mideleg, RISCVCPU), + VMSTATE_UINTTL(env.sptbr, RISCVCPU), + VMSTATE_UINTTL(env.satp, RISCVCPU), + VMSTATE_UINTTL(env.sbadaddr, RISCVCPU), + VMSTATE_UINTTL(env.mbadaddr, RISCVCPU), + VMSTATE_UINTTL(env.medeleg, RISCVCPU), + VMSTATE_UINTTL(env.stvec, RISCVCPU), + VMSTATE_UINTTL(env.sepc, RISCVCPU), + VMSTATE_UINTTL(env.scause, RISCVCPU), + VMSTATE_UINTTL(env.mtvec, RISCVCPU), + VMSTATE_UINTTL(env.mepc, RISCVCPU), + VMSTATE_UINTTL(env.mcause, RISCVCPU), + VMSTATE_UINTTL(env.mtval, RISCVCPU), + VMSTATE_UINTTL(env.scounteren, RISCVCPU), + VMSTATE_UINTTL(env.mcounteren, RISCVCPU), + VMSTATE_UINTTL(env.sscratch, RISCVCPU), + VMSTATE_UINTTL(env.mscratch, RISCVCPU), + VMSTATE_UINT64(env.mfromhost, RISCVCPU), + VMSTATE_UINT64(env.mtohost, RISCVCPU), + VMSTATE_UINT64(env.timecmp, RISCVCPU), + + VMSTATE_END_OF_LIST() + } +}; diff --git a/target/riscv/meson.build b/target/riscv/meson.build index abd647fea1..14a5c62dac 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -27,7 +27,8 @@ riscv_ss.add(files( riscv_softmmu_ss = ss.source_set() riscv_softmmu_ss.add(files( 'pmp.c', - 'monitor.c' + 'monitor.c', + 'machine.c' )) target_arch += {'riscv': riscv_ss} From patchwork Tue Nov 3 15:21:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85DE692C for ; Tue, 3 Nov 2020 15:56:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 18EDB22280 for ; Tue, 3 Nov 2020 15:56:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="OrpAxVPL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18EDB22280 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyg3-0000gS-5l for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:56:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJR-0001TP-Th for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:33 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJO-0001Fa-VD for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417611; x=1635953611; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WumyfNifo14aIzDni7I+UXZHpnoesgywH8qDEDipM30=; b=OrpAxVPLgcp4wGj2o6SpHlfz3XkHRQ9ruUkGP2dw8v4x8Bfaug593M1G KUUG4yR+Wyl5fjE52VGyPdT9RViAYg4n6DROseoyQCa6EKW2sp1Y8tjGI 2Q0kuVE1AhpeSCF8qH8THkizFxjZC52+QcxIM5haaaUi1iCyZZaA1pjgW staTcvvx2kKjDAcN2HcBWBC6gtIbn3OapHbPQsE+zgs4i2QvUvJxgniHl hMvHpC7ImOkwD8DzbEI0/eqJwTQN/exDkHo6SRRmQ7QZNItQdEZL/n2EB Xy+n1nVczxzRztc/DvYLQhz4wxUPYiKGNb+K6Hjc/hp0Zgb2PGNYGixZF Q==; IronPort-SDR: k+02B0+GCUDyWvUo3QZLOLdxMfJBlzLxaRdXLfDSHwjYhcpR8fSfT58tNlfFqVl01PX7VsoUz0 xgkcfoaxySxUF4hr8clVMsd3zLcXVpbPdIGyGhzQsWSD0ttYocBVQg/tdGvoFjf1sWDHcrCrpQ Onn+eT+9Q7ivZIRUqBfMIW1DgStJjAbuZgkmUYUhn/qyAFGUJJgGuKFjfQeRPrUAIjjMNEO98Z +gnRGlLBF36JpufAJqzXd4ksLa6iPqg1pQ4Vov6GvhR5j3XCEvV/vHPXsl7yytjWT4kcqrKp60 geg= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867458" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:25 +0800 IronPort-SDR: l5Kl9RkBgB7E065gSOsTwTISv9GBQxF+7dFrqXBrf7jFiHIQOy62R6UMSeSdqVFoWsay7aSPj1 Mee8POAfJcSiuJ4ZdRZHcdXUc9KdjWyFoiZMJmk1GSAj+djAPyxKH3+elA8xpMEoR14GBIjfFy PxTvb78/DQVbQv+lmIyFmHnQ7jmtqGTwldJ9UB6dWAeJziSnjLOuhtlpsl+2qhuHOm35jU6ne7 BlSEij5D6FRbPIHdRlw/XRZaXLbDOpy3O+iQTwoQ/yBYbw2++m0qXFgj9pGscifjC3FtSOG3wX ea+bgY7+9eP1KBoUDxPgYbsl Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:33 -0800 IronPort-SDR: FZ03COi3rlLT8tA7qLluEzLUyU35fmvGh/Jynw6gjXDBhE1r0F5833SDdC8wlJHjsYn4D2YIqI EcZNFD8ltr+BzIQwL4n80tQX68kcNfAwL2Nb5tK2by2F/Jx42sBKEeOlRqhwR58H9obi1Ovct9 Ug9jsEy6XIytQVXySMQkXtzkW3ve9aQqwe5fIDzal05s0bI7ykg7BOYwEG+tXgeq2MIAbbUZSy V5f0iD86KFg2cR8NhL3uFuuP8773u7ZdlOcSI94sNy1pIa6rrgHodMswS+SrOkl8kVxnBbHj3I IdA= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:25 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 05/19] target/riscv: Add PMP state description Date: Tue, 3 Nov 2020 07:21:36 -0800 Message-Id: <20201103152150.2677566-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang In the case of supporting PMP feature, add PMP state description to vmstate_riscv_cpu. 'vmstate_pmp_addr' and 'num_rules' could be regenerated by pmp_update_rule(). But there exists the problem of updating num_rules repeatedly in pmp_update_rule(). So here extracts pmp_update_rule_addr() and pmp_update_rule_nums() to update 'vmstate_pmp_addr' and 'num_rules' respectively. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis Message-id: 20201026115530.304-4-jiangyifei@huawei.com Signed-off-by: Alistair Francis --- target/riscv/pmp.h | 2 ++ target/riscv/machine.c | 50 ++++++++++++++++++++++++++++++++++++++++++ target/riscv/pmp.c | 29 ++++++++++++++---------- 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index 6a8f072871..6c6b4c9bef 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -62,5 +62,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, target_ulong size, pmp_priv_t priv, target_ulong mode); bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa, target_ulong *tlb_size); +void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index); +void pmp_update_rule_nums(CPURISCVState *env); #endif diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 32edbcba7c..fc1461d88e 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -22,6 +22,52 @@ #include "sysemu/kvm.h" #include "migration/cpu.h" +static bool pmp_needed(void *opaque) +{ + RISCVCPU *cpu = opaque; + CPURISCVState *env = &cpu->env; + + return riscv_feature(env, RISCV_FEATURE_PMP); +} + +static int pmp_post_load(void *opaque, int version_id) +{ + RISCVCPU *cpu = opaque; + CPURISCVState *env = &cpu->env; + int i; + + for (i = 0; i < MAX_RISCV_PMPS; i++) { + pmp_update_rule_addr(env, i); + } + pmp_update_rule_nums(env); + + return 0; +} + +static const VMStateDescription vmstate_pmp_entry = { + .name = "cpu/pmp/entry", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINTTL(addr_reg, pmp_entry_t), + VMSTATE_UINT8(cfg_reg, pmp_entry_t), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_pmp = { + .name = "cpu/pmp", + .version_id = 1, + .minimum_version_id = 1, + .needed = pmp_needed, + .post_load = pmp_post_load, + .fields = (VMStateField[]) { + VMSTATE_STRUCT_ARRAY(env.pmp_state.pmp, RISCVCPU, MAX_RISCV_PMPS, + 0, vmstate_pmp_entry, pmp_entry_t), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_riscv_cpu = { .name = "cpu", .version_id = 1, @@ -70,5 +116,9 @@ const VMStateDescription vmstate_riscv_cpu = { VMSTATE_UINT64(env.timecmp, RISCVCPU), VMSTATE_END_OF_LIST() + }, + .subsections = (const VMStateDescription * []) { + &vmstate_pmp, + NULL } }; diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index c394e867f8..2eda8e1e2f 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -136,18 +136,8 @@ static void pmp_decode_napot(target_ulong a, target_ulong *sa, target_ulong *ea) } } - -/* Convert cfg/addr reg values here into simple 'sa' --> start address and 'ea' - * end address values. - * This function is called relatively infrequently whereas the check that - * an address is within a pmp rule is called often, so optimise that one - */ -static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index) +void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index) { - int i; - - env->pmp_state.num_rules = 0; - uint8_t this_cfg = env->pmp_state.pmp[pmp_index].cfg_reg; target_ulong this_addr = env->pmp_state.pmp[pmp_index].addr_reg; target_ulong prev_addr = 0u; @@ -186,7 +176,13 @@ static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index) env->pmp_state.addr[pmp_index].sa = sa; env->pmp_state.addr[pmp_index].ea = ea; +} +void pmp_update_rule_nums(CPURISCVState *env) +{ + int i; + + env->pmp_state.num_rules = 0; for (i = 0; i < MAX_RISCV_PMPS; i++) { const uint8_t a_field = pmp_get_a_field(env->pmp_state.pmp[i].cfg_reg); @@ -196,6 +192,17 @@ static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index) } } +/* Convert cfg/addr reg values here into simple 'sa' --> start address and 'ea' + * end address values. + * This function is called relatively infrequently whereas the check that + * an address is within a pmp rule is called often, so optimise that one + */ +static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index) +{ + pmp_update_rule_addr(env, pmp_index); + pmp_update_rule_nums(env); +} + static int pmp_is_in_range(CPURISCVState *env, int pmp_index, target_ulong addr) { int result = 0; From patchwork Tue Nov 3 15:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10E3992C for ; Tue, 3 Nov 2020 15:37:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1A9E20756 for ; Tue, 3 Nov 2020 15:37:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="kRJjP8Lx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1A9E20756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyNZ-0008Iv-MT for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:37:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJS-0001Us-Ia for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:34 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJQ-0001EJ-G9 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417613; x=1635953613; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g+WPltm5YpaGI86/aQt4WJbADi/eUHg46l1ls02OzYI=; b=kRJjP8LxpxLXfVJ5enLpNljfoNCdZp81qbV3vbwLEw/5eqQvonvSjgVb GpXxbcpg3M8JEDTsePxvpnucDQt21aw2NBluXN1KjNdpaygOOzX4CwS6y ZGdzwDL5USIyryr+wLBT2nJTIC0EUm0fy0slcLp3qhYB780i229svevj7 Ge+k5kBohk8G+z6hVuBHsXtvwTl5Y6Bis0Lg67O+ae0H0wF7uLuWfn34L DMvNybZR/4Ui/5qbayTpSg6G9vxl4McHJKWoAdZKyaBEIrQfV1fNLILCp +QkO/2Ih/yuC6azRf7Zb/MsdOtZWNAxogLdcQjClNFAi4tI+6xWSJNyj+ g==; IronPort-SDR: IwQyMRy8dsdxxz01dHNq/cz6+Xr7dl5XHtVk2+X20lwEb7xr/bf7NTxWFQVwh83I2V92sjPFwB Nfd+cMyFEF9KkOyehun2DJ97scy9B/SuGL9HLGR6YZOs3oLUn5jandc4/e4M/1iRaqb8uaTTMK ic6BFX258KB7LsvoiFIQqzw7QOErEAipOL//1jN4OQ50ZS+X06t7zauY/z0DbILP7a3OrzX/Jv HZ/g7ozwt5RvNDLg70VglxFGbLyehmExz7rh+Z4AoT1WRqe2rDuVon4dd54ebHp+Zs5YMzQsGj JIY= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867460" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:25 +0800 IronPort-SDR: knT102/BOyjAbQxhh+d/bP3pSbO++2RAyWQqss5Vnq5oMvNKnCBL9QcH6cBh7sAW7LYFPoZ6VV N2ZgVz1PjJvHaKh1dI8+YpHVXy800+P+SJVF+PBb1fTKasbS5rkJUMk9tVRoG0GYZW3rQbiNY/ 1g+Oe0dVRBwUbFXYjzZQd9LNQlN+JA3qbpdCVvbVTesm4KrD9Z4esgOS5aRYQ49C99FXewGou+ gHSOLWQXHGjyR+Ia3NExXG0y69mKlnfxCd8KTY6yXiRCspngwb5L3wXXXQvSyl1pPGehWHXqlF jnnD1dhSgkAKJ97edBJ1Az8D Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:33 -0800 IronPort-SDR: CrAhbIOju9eqJ8nO5DREby+bryE5SEoFSk9LKGRp+jp7C8gWpEv1hu1dY64rNIu5TqbnvqKk0k ec6Lv927lxFJoRnEw2tAwr5GRvlMJdZbJ+zNu0/H2Y44QgaspD+MCBSPlVuncnsacJ9Wi5PwGL RJWplmisbxq83Z9xd7y83HNOJ6OO/BPZQDyhWju0Ivowpbf7Z7oAmdCcgfQ9xcSmxKuDuqdgC0 Hbtnq2m0X/M52msg3wktH37KFlEqaWmrh+SU1c/8YQxM3TOcfmQC8NabhB/zttNDQIuaKqW1VX OrA= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:25 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 06/19] target/riscv: Add H extension state description Date: Tue, 3 Nov 2020 07:21:37 -0800 Message-Id: <20201103152150.2677566-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang In the case of supporting H extension, add H extension description to vmstate_riscv_cpu. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis Message-id: 20201026115530.304-5-jiangyifei@huawei.com Signed-off-by: Alistair Francis --- target/riscv/machine.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/target/riscv/machine.c b/target/riscv/machine.c index fc1461d88e..ae60050898 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -68,6 +68,52 @@ static const VMStateDescription vmstate_pmp = { } }; +static bool hyper_needed(void *opaque) +{ + RISCVCPU *cpu = opaque; + CPURISCVState *env = &cpu->env; + + return riscv_has_ext(env, RVH); +} + +static const VMStateDescription vmstate_hyper = { + .name = "cpu/hyper", + .version_id = 1, + .minimum_version_id = 1, + .needed = hyper_needed, + .fields = (VMStateField[]) { + VMSTATE_UINTTL(env.hstatus, RISCVCPU), + VMSTATE_UINTTL(env.hedeleg, RISCVCPU), + VMSTATE_UINTTL(env.hideleg, RISCVCPU), + VMSTATE_UINTTL(env.hcounteren, RISCVCPU), + VMSTATE_UINTTL(env.htval, RISCVCPU), + VMSTATE_UINTTL(env.htinst, RISCVCPU), + VMSTATE_UINTTL(env.hgatp, RISCVCPU), + VMSTATE_UINT64(env.htimedelta, RISCVCPU), + + VMSTATE_UINT64(env.vsstatus, RISCVCPU), + VMSTATE_UINTTL(env.vstvec, RISCVCPU), + VMSTATE_UINTTL(env.vsscratch, RISCVCPU), + VMSTATE_UINTTL(env.vsepc, RISCVCPU), + VMSTATE_UINTTL(env.vscause, RISCVCPU), + VMSTATE_UINTTL(env.vstval, RISCVCPU), + VMSTATE_UINTTL(env.vsatp, RISCVCPU), + + VMSTATE_UINTTL(env.mtval2, RISCVCPU), + VMSTATE_UINTTL(env.mtinst, RISCVCPU), + + VMSTATE_UINTTL(env.stvec_hs, RISCVCPU), + VMSTATE_UINTTL(env.sscratch_hs, RISCVCPU), + VMSTATE_UINTTL(env.sepc_hs, RISCVCPU), + VMSTATE_UINTTL(env.scause_hs, RISCVCPU), + VMSTATE_UINTTL(env.stval_hs, RISCVCPU), + VMSTATE_UINTTL(env.satp_hs, RISCVCPU), + VMSTATE_UINT64(env.mstatus_hs, RISCVCPU), + + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_riscv_cpu = { .name = "cpu", .version_id = 1, @@ -119,6 +165,7 @@ const VMStateDescription vmstate_riscv_cpu = { }, .subsections = (const VMStateDescription * []) { &vmstate_pmp, + &vmstate_hyper, NULL } }; From patchwork Tue Nov 3 15:21:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6A6292C for ; Tue, 3 Nov 2020 15:43:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 784E820780 for ; Tue, 3 Nov 2020 15:43:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="fgtl1ViN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 784E820780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZySi-0008Ei-GM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:43:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJU-0001Y6-1w for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:36 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJS-0001Fa-7G for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417614; x=1635953614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jn6EIm9hdrR24DW8Li1I2eFglThg87rXwX+el8u4/zc=; b=fgtl1ViNkjzT8jsEWwJM1eSKGbOVs732DKUiCK2ZtaE7e7LKsVPyCqhi ynVLkWzMJquwhADegQb7L/q4d63+e0fEhYWVljNRZX0O04qnlTckWI+Ft DbeL/Nz67GeKzCdg0KecVuVSbjibQ2emah7G4jH4ASIOD8xkacxAMH+J1 tfydbFqpHtYN1G67Wt4rrvhtipQQpCDe/XtUdC0HfqjEd6J9deHvNqZmh 6MmQneAregiZQsj4qFumjnnpQAcdTj2AMEYJ8Kdqil9n73FX2b5flknwk dklcOyYiyTxXQu21SUx2ngPli7vE5DKvnOmLgYxm5xm0SOPGiHPXKOV/x w==; IronPort-SDR: fotZ8E+Bm2vFOBh0wL1SWluda+y1UkvzH2O6++kCJzE2+kVFSIFUSZlGpdGX7s3R/wOpzEYk/W vvtPG4N1Tpy1cX8Ygas/4DftdUOL/go/a+a1NdKDJurlglLuhrXqDArsRqaLHIZ1fuU+jy+yrq eA7NveVoDKDMD+/oPLI8ttx3GJUYE810yovHB4dTMRsmwyYjFIS6NSfdNqpyIFkY63hKv54ojX 8wuEu/W1OCIith1LxRtYx6eLgyE7qvbW/QargzVAjkO03sf972iSbXPXKCRUeQvIl68UC2rSwt 5LQ= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867462" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:25 +0800 IronPort-SDR: QKBdmz0z6xZQ/vOmvbyehrLFyEiWfhtJoRkZKjX5v+jCyGwlZmVUbM2aZ4yfoPazV0wZu4xiMK ozX3TmR4dMwaPqVdKY8FyBLZ3BBMnLb+KSb2mXs2WpawO5zqjJauuOgyW8nu5rDAd1ik1IZy/j iAEMzzCEU199hvAPkX7UdtazKw2mtztovpPD+6suxmk9NYhqFYxIBOFYHNrwYsxajUShp9IjBG y7VNkIqUXjo+QkZvyGhmgyaW+HnHwdGvGq7k41gDmgYCQMJbJhhqQOnpgHNvF4hZrrx3+U6/DM EXPwiyhu4UlKBNJCg9nbKVXi Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:34 -0800 IronPort-SDR: ZK7gctL0dnWybucKtYOqNrSZ6WiEGpaezGj2sEQOZSrsgfpe3YGQONjHu+rThg8rB1VTf1bwhp eyGZJ9bkEctGRkgv/OavfQbgPp+vcIddv7ns7dP8k4ZweT4z50brZ34On+jLvGh7LM3iJRswLk fbtEEOB8PUjqt1jHJdoxlTaYsbsv2S+FgdIoeTS4iWaPZWx8lwPQ7a5Ihea1plJ19y3nsweHM0 CBOZEjuHbf2DNiQnNWABBgUR0VJP2xkPrKbbbyNkZEUvqd3rOFCQRKJUShka9BNx73ByosRhvO G9I= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:26 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 07/19] target/riscv: Add V extension state description Date: Tue, 3 Nov 2020 07:21:38 -0800 Message-Id: <20201103152150.2677566-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Richard Henderson , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang In the case of supporting V extension, add V extension description to vmstate_riscv_cpu. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-id: 20201026115530.304-6-jiangyifei@huawei.com Signed-off-by: Alistair Francis --- target/riscv/machine.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/riscv/machine.c b/target/riscv/machine.c index ae60050898..44d4015bd6 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -76,6 +76,30 @@ static bool hyper_needed(void *opaque) return riscv_has_ext(env, RVH); } +static bool vector_needed(void *opaque) +{ + RISCVCPU *cpu = opaque; + CPURISCVState *env = &cpu->env; + + return riscv_has_ext(env, RVV); +} + +static const VMStateDescription vmstate_vector = { + .name = "cpu/vector", + .version_id = 1, + .minimum_version_id = 1, + .needed = vector_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT64_ARRAY(env.vreg, RISCVCPU, 32 * RV_VLEN_MAX / 64), + VMSTATE_UINTTL(env.vxrm, RISCVCPU), + VMSTATE_UINTTL(env.vxsat, RISCVCPU), + VMSTATE_UINTTL(env.vl, RISCVCPU), + VMSTATE_UINTTL(env.vstart, RISCVCPU), + VMSTATE_UINTTL(env.vtype, RISCVCPU), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_hyper = { .name = "cpu/hyper", .version_id = 1, @@ -166,6 +190,7 @@ const VMStateDescription vmstate_riscv_cpu = { .subsections = (const VMStateDescription * []) { &vmstate_pmp, &vmstate_hyper, + &vmstate_vector, NULL } }; From patchwork Tue Nov 3 15:21:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A92792C for ; Tue, 3 Nov 2020 15:40:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7A9920756 for ; Tue, 3 Nov 2020 15:40:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="dtOlCLt3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7A9920756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyQJ-0003e0-OQ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:40:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJV-0001bM-Kx for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:37 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJS-0001EJ-RO for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417615; x=1635953615; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g4WdlHNUsSqm5IYl1xQpaPDV/gYQAaTlwhWn8+X0BO0=; b=dtOlCLt3IkE6aVP9LBANvkQbezCH7yaZTpba/j7ngfJMlc+s/tMvwMbu U9GsqgHN/bs/uneiN5J+9jJPTAf5LccM2TVdynXSyzSLAhJ+kZQX6L0PR +77yK1dMJy4ggeiPdeRPvJ8c/WmXsW5VwlALPqZcD3XBQR7kH55PS4fy2 T+mEUYYl/2EGpbWT4lHKBlj96JQ8jDxuGMdJagqYh3bbr+2TINMDWMR/D yeCI8VBAP/Hy+Z+yg76WkhFuK+Nf6KqgkFpREZmkZ1GahwcdB53Rn+sJQ +2XTPZukclV3pCBoCQZ6ded8nVWk6R+pX/vX7Gtuv0vAPlIp3rUQbx9ks Q==; IronPort-SDR: hDo9LPVF1pEKiVED61HUAjvxmdX0QHENUZQGAy/7gtzzMclY+1tcnfyL2Js5NkWDmRG3xd1cNK 8/Uj88YtxjoYTiE4xm8e+cxHBvLdsRNp5clWvKe6syHjd+LhjWydDxvq7dDJQ+vcZAdWOP9eu1 S3Rpw5QR4EJ2IoR2a4yIV/xUfnENKozq6JNnwDH7ex/2esHSRVqeXW5JDq/aIjFp/LWDit0PXJ G17Wo5ghpmgGvKuEWdJfZ6DAyt4h+pYs4/Vfe9B8zFnwGFIlOCsfXk96liXnO6r+PATnJKzwH1 tL0= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867465" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:26 +0800 IronPort-SDR: iC7plak0tBkWUXGG9ie4QnfHTNAr1ZpGlpvacY4XQ9H4mryFjTpXyBOj6XgXm2A4fbjDCwjq+N p4LGZB78QjIypmaUZBl042CfCVYlSLydGg/A5JIrm3G4TckcN9sVGixnC4e1UuIr7oLIyHYglK 0mKgllcLqeiYmvU3S7Ebe0+YPAUhr4USP/Zi6czzX6SUDxq778SV6yPdhIZzbJ99hivbPLTA7I 1KlAQDd9kNfSVJ3HRaPvpFgaeajfOzaezEEs/r7LrrephTws3N0ETD+0pHnBCiukTMHYdtLMhv fSLGWup9/tsoPXcA0FcTDQCu Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:34 -0800 IronPort-SDR: eOqWtonO9HwqCFgkUMpS5s285aYyZzZFl39sZx40qnepr9cdHxm0meCE0ZCP3AAJILYPFhLkC8 2IzCOrdKqvflpmDCAqAWNKhbABAvex6SPQngW//I675ImrfdkkLsRj4XwupAnTYvxTfM5+d4oM bSckxfYrnP1kCbnuCO9FgUhTrNxDDntJpcaUuyXyd7/nOBfFGRu1++v/j7DNz+Tvoq3ksMBGJS 1Vv+EPlWPLP6lZ4sPdzvcfLuYionv/zhpp+AD5lLzYtxnRKHgwIfVnCOs5yD3yUbpXG5v7caPD Sts= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:26 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 08/19] target/riscv: Add sifive_plic vmstate Date: Tue, 3 Nov 2020 07:21:39 -0800 Message-Id: <20201103152150.2677566-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Alistair Francis , Yifei Jiang , Yipeng Yin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yifei Jiang Add sifive_plic vmstate for supporting sifive_plic migration. Current vmstate framework only supports one structure parameter as num field to describe variable length arrays, so introduce num_enables. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis Message-id: 20201026115530.304-7-jiangyifei@huawei.com Signed-off-by: Alistair Francis --- include/hw/intc/sifive_plic.h | 1 + hw/intc/sifive_plic.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/hw/intc/sifive_plic.h b/include/hw/intc/sifive_plic.h index b75b1f145d..1e451a270c 100644 --- a/include/hw/intc/sifive_plic.h +++ b/include/hw/intc/sifive_plic.h @@ -52,6 +52,7 @@ struct SiFivePLICState { uint32_t num_addrs; uint32_t num_harts; uint32_t bitfield_words; + uint32_t num_enables; PLICAddr *addr_config; uint32_t *source_priority; uint32_t *target_priority; diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index f42fd695d8..97a1a27a9a 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -30,6 +30,7 @@ #include "hw/intc/sifive_plic.h" #include "target/riscv/cpu.h" #include "sysemu/sysemu.h" +#include "migration/vmstate.h" #define RISCV_DEBUG_PLIC 0 @@ -448,11 +449,12 @@ static void sifive_plic_realize(DeviceState *dev, Error **errp) TYPE_SIFIVE_PLIC, plic->aperture_size); parse_hart_config(plic); plic->bitfield_words = (plic->num_sources + 31) >> 5; + plic->num_enables = plic->bitfield_words * plic->num_addrs; plic->source_priority = g_new0(uint32_t, plic->num_sources); plic->target_priority = g_new(uint32_t, plic->num_addrs); plic->pending = g_new0(uint32_t, plic->bitfield_words); plic->claimed = g_new0(uint32_t, plic->bitfield_words); - plic->enable = g_new0(uint32_t, plic->bitfield_words * plic->num_addrs); + plic->enable = g_new0(uint32_t, plic->num_enables); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &plic->mmio); qdev_init_gpio_in(dev, sifive_plic_irq_request, plic->num_sources); @@ -472,12 +474,34 @@ static void sifive_plic_realize(DeviceState *dev, Error **errp) msi_nonbroken = true; } +static const VMStateDescription vmstate_sifive_plic = { + .name = "riscv_sifive_plic", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_VARRAY_UINT32(source_priority, SiFivePLICState, + num_sources, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(target_priority, SiFivePLICState, + num_addrs, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(pending, SiFivePLICState, bitfield_words, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(claimed, SiFivePLICState, bitfield_words, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(enable, SiFivePLICState, num_enables, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_END_OF_LIST() + } +}; + static void sifive_plic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); device_class_set_props(dc, sifive_plic_properties); dc->realize = sifive_plic_realize; + dc->vmsd = &vmstate_sifive_plic; } static const TypeInfo sifive_plic_info = { From patchwork Tue Nov 3 15:21:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49B2692C for ; Tue, 3 Nov 2020 15:42:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F33C520780 for ; Tue, 3 Nov 2020 15:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="kVzY1glR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F33C520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:50038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyRz-00076L-Pm for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:42:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJV-0001bk-QM for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:37 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJT-0001FT-9g for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417615; x=1635953615; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P/qi2faPiuz4u3dNR7xsZrZ/3Jx9//l1Rlurl6tn9Fs=; b=kVzY1glR6niliEgvRbYYw4QShcT0fFDczLReBkK+3qspM4MQpMtCDXjO dLZ3PWQFknRhVSgcIO1vxxndP0wI1FSw5h+qz6hkh0ekAqCHuQmA6Q2Fx voy9MRqTLYZr/FXt7FI896VObL9A6a1+h2fxXUz2crZE+ya+RbU48ADpP 5xctLae6d7AAjY/7GnrqtRXbf0Ove/7i4gVH8wj5JH+0c0ofgDOhLXNRH Xe2utxEr+5QvO8T3pQjZZ1R0d9KF7Hhng3+a+moHqFrJw8MgxfKmLfhyL nZvzrpzQlUh1+lhs4KBzLDOrajVvrYhkMCch2Lt4OgUjK4xESq5aec+vy w==; IronPort-SDR: OZw60kG9GYna+v6CHCfKy/GbKnd/H9dTwJ/00fXhdl4OkFHF3KvKRf5+mFaNy28M5fM9y1GmIG FuXFsUvrzkVbmgFWQcIGzWcm0ab9+og7r/1HvtCsb1QwcDVIWXeeD4A5ogYOsR3arvRyZlmT8Z kz8uEhN0Jp0aWYgwkgRe+t4WYDTWAZuOZcRp+S3/UWPAYUuBn2HH8iOUmfbY8eHtlTcL4dG17D KjnJaFfunoCbvgO3XOG1AeAA9ycPD1BYj8pMhauVukEVaiiODETZdwUQRtNbMmecg3jgUCFaU4 xiE= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867467" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:26 +0800 IronPort-SDR: ZXtY/2v6NJZDOxh2ijgPdRyq/v5hl1nETuIT4v/D9w9aGAGI91oJsp3Y5asl6RdMVaGiyXy/9a q4H+XTV1bD8cn7/MGE0tJPOtQ99kUP1b9fot1ERdV7tycNbxZIeI3Cllfbw7U0YCho/NEyRjcD 8Zy1Ci/Y14Wh5su0RXD4qu/6tyDoHk40skRe6YrA9EdfbTe50wrN1nSNodcBKAl455EuLmLIQc DeB/oDInv8OKM/cuk3BpF4tfvrdEsayhtNDCH2MSVGSL3zFiwZSxUaYCXi7yTizdvTu2cWesq7 i1Rrc8yYZvPVTeuN1B1y+IqZ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:34 -0800 IronPort-SDR: PW7nqYWDT0F28ke6svIt4DO2TqMISCY+uaoR8H72EcY6scWscudid+HQl/cZs7JSsS2SAWRV2s vyVmHBW5jr8jV2WPcyfYN4tX9KYFCR9sBE4ZcImMdjM6GDv09W6VHYs5LIbzUCtPkYNscRhANy /wGr65hJcABWP8prOd7TuwQ3yH7sqJoEjBeykGM4Lw0s2mzvrjRzz46IvUoOtCaHvcoBrhaIrq iN1znbBYKd2FToORlovEJanF9NqKZ917/8FTpDpSuJ8dTypOs6OjyGKpv7U7JvgQiWZIV/RbKp eVQ= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:26 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 09/19] hw/riscv: microchip_pfsoc: Document where to look at the SoC memory maps Date: Tue, 3 Nov 2020 07:21:40 -0800 Message-Id: <20201103152150.2677566-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng It is not easy to find out the memory map for a specific component in the PolarFire SoC as the information is scattered in different documents. Add some comments so that people can know where to get such information from the Microchip website. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-2-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 4627179cd3..6aac8497fc 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -66,6 +66,24 @@ /* GEM version */ #define GEM_REVISION 0x0107010c +/* + * The complete description of the whole PolarFire SoC memory map is scattered + * in different documents. There are several places to look at for memory maps: + * + * 1 Chapter 11 "MSS Memory Map", in the doc "UG0880: PolarFire SoC FPGA + * Microprocessor Subsystem (MSS) User Guide", which can be downloaded from + * https://www.microsemi.com/document-portal/doc_download/ + * 1244570-ug0880-polarfire-soc-fpga-microprocessor-subsystem-mss-user-guide, + * describes the whole picture of the PolarFire SoC memory map. + * + * 2 A zip file for PolarFire soC memory map, which can be downloaded from + * https://www.microsemi.com/document-portal/doc_download/ + * 1244581-polarfire-soc-register-map, contains the following 2 major parts: + * - Register Map/PF_SoC_RegMap_V1_1/pfsoc_regmap.htm + * describes the complete integrated peripherals memory map + * - Register Map/PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm + * describes the complete IOSCB modules memory maps + */ static const struct MemmapEntry { hwaddr base; hwaddr size; From patchwork Tue Nov 3 15:21:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFD1C92A for ; Tue, 3 Nov 2020 15:58:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C0FA20870 for ; Tue, 3 Nov 2020 15:58:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="H/uSb1Pq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C0FA20870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyhJ-0001hL-A5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:58:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJj-0001vK-RR for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:53 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJf-0001Fa-Nb for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417628; x=1635953628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v0KEo1sR11JezPsDWguUYfloVCM1WSvPtyX17iu14Os=; b=H/uSb1Pq4NwBZkqFbeaDkCWGjJxIR5St0hlqZfIEoeUBlRweUlZOOsU2 P83eWQZ3HjWfM4NTCwT3bbKRy0IAhshC3NbstTkgJzm6/bWz6LzWwrXMO r5IlXkjLb7t8eUHchPp2MpqCtRxR7N/ePLd5AxvALYSMIfealR/DlCwuU sz23lN4hN9sY6zCV1iL6LZwp+iIkYxIwTNrQLWa9EmSSStzZuFUZmTj9k gqEe8ZAvE6PW5LOssMakRUZP1wdxEevzSjWJylyxdBHWpTd6JtRqPOwEl rQ3iqv4pLctakJZd6hdK+QnU/1KrQaPPhPPfxp+40B07blC4bwmn1qCXA Q==; IronPort-SDR: a0flfrA4nqNDlLVU0BuzCJcp4q3q3W96QAwhoH3OXrQF0ZzGIkJO9qIn6M6Yc6UzZEO8OOz411 7I76gEtToOV8VT+6V2Tb/DAsYd1OPHz2lLDGTUoR7z09r85Zn8657t3IAkae+v9rHpMVsf384j nJvy/Hw5pfG6mVD8q/ptV5KqImdPKPEFFhQ4+Dk5Z7UzAD4E7olQi3g/dE9ivXoE+mHKJf/dFy HoFdR2pe7gRzCX3wup0zBUp+TjcIZC865LY679/I+EfW+sktQRRV9rAT9FxoW33wGAFm3ew5Pe KAI= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867470" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:26 +0800 IronPort-SDR: Rr8PwmHLO4RPmAzJ7y2e+Ov81OOtl+w+UK8L6hOVO4bht4kHVdwM6gh7VecC0UXBhRSW6X+9FL 5nsYuiuMUU1pwV21BstJd02FXSGHA53WoUeUXWdtZiaHDFGCsRaU4TvTnXEt5eqdMZPGaxFMga 7HRCWDd2hy13eA0MP1lu26O/odpJQ2gf15aAU5skTb0KDMvszp6DOt56YJ6WxCtKCn/p761Q19 JuDf20L1dvvpHZtEyXCwA06f76huj8YVlajAQ+j9IIrGVyqk4xmuV8Z1Y4nXEzqDZ/ClOXgu+o b+B/xElQbw+P9bxry58Mj/hk Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:35 -0800 IronPort-SDR: BJBuSpwFhD96yUyWf2eov8XMeyCOtI1DfybajzCYhX8KkGhmgFUNBNe58vMHi+Jqruk9UWya66 uowlSJoLUHp786oZX+rkq1MBgGBPZSRB4n5nNMAldgWmHcb6E14cTvVX/5Sqgji6cqNuFBrjGs 0mQrPZf+J87dl8MCICQUmi6GHrl5kaLauibASPdiJ1r8cV3K+I/cxD5vfQiQGp54Go7qNLRDXG 8sJ5TMVAoOQLDiWnuBPwhjFIhgC10o/rcWn8aS7OSWn49EisFIzgvbjR5cad9lXJuWYsUIB9AX li0= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:26 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 10/19] hw/misc: Add Microchip PolarFire SoC DDR Memory Controller support Date: Tue, 3 Nov 2020 07:21:41 -0800 Message-Id: <20201103152150.2677566-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The PolarFire SoC DDR Memory Controller mainly includes 2 modules, called SGMII PHY module and the CFG module, as documented in the chipset datasheet. This creates a single file that groups these 2 modules, providing the minimum functionalities that make the HSS DDR initialization codes happy. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-3-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/misc/mchp_pfsoc_dmc.h | 56 ++++++++ hw/misc/mchp_pfsoc_dmc.c | 216 +++++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + 5 files changed, 278 insertions(+) create mode 100644 include/hw/misc/mchp_pfsoc_dmc.h create mode 100644 hw/misc/mchp_pfsoc_dmc.c diff --git a/include/hw/misc/mchp_pfsoc_dmc.h b/include/hw/misc/mchp_pfsoc_dmc.h new file mode 100644 index 0000000000..2baa1413b0 --- /dev/null +++ b/include/hw/misc/mchp_pfsoc_dmc.h @@ -0,0 +1,56 @@ +/* + * Microchip PolarFire SoC DDR Memory Controller module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef MCHP_PFSOC_DMC_H +#define MCHP_PFSOC_DMC_H + +/* DDR SGMII PHY module */ + +#define MCHP_PFSOC_DDR_SGMII_PHY_REG_SIZE 0x1000 + +typedef struct MchpPfSoCDdrSgmiiPhyState { + SysBusDevice parent; + MemoryRegion sgmii_phy; +} MchpPfSoCDdrSgmiiPhyState; + +#define TYPE_MCHP_PFSOC_DDR_SGMII_PHY "mchp.pfsoc.ddr_sgmii_phy" + +#define MCHP_PFSOC_DDR_SGMII_PHY(obj) \ + OBJECT_CHECK(MchpPfSoCDdrSgmiiPhyState, (obj), \ + TYPE_MCHP_PFSOC_DDR_SGMII_PHY) + +/* DDR CFG module */ + +#define MCHP_PFSOC_DDR_CFG_REG_SIZE 0x40000 + +typedef struct MchpPfSoCDdrCfgState { + SysBusDevice parent; + MemoryRegion cfg; +} MchpPfSoCDdrCfgState; + +#define TYPE_MCHP_PFSOC_DDR_CFG "mchp.pfsoc.ddr_cfg" + +#define MCHP_PFSOC_DDR_CFG(obj) \ + OBJECT_CHECK(MchpPfSoCDdrCfgState, (obj), \ + TYPE_MCHP_PFSOC_DDR_CFG) + +#endif /* MCHP_PFSOC_DMC_H */ diff --git a/hw/misc/mchp_pfsoc_dmc.c b/hw/misc/mchp_pfsoc_dmc.c new file mode 100644 index 0000000000..15cf3d7725 --- /dev/null +++ b/hw/misc/mchp_pfsoc_dmc.c @@ -0,0 +1,216 @@ +/* + * Microchip PolarFire SoC DDR Memory Controller module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/hw.h" +#include "hw/sysbus.h" +#include "hw/misc/mchp_pfsoc_dmc.h" + +/* DDR SGMII PHY module */ + +#define SGMII_PHY_IOC_REG1 0x208 +#define SGMII_PHY_TRAINING_STATUS 0x814 +#define SGMII_PHY_DQ_DQS_ERR_DONE 0x834 +#define SGMII_PHY_DQDQS_STATUS1 0x84c +#define SGMII_PHY_PVT_STAT 0xc20 + +static uint64_t mchp_pfsoc_ddr_sgmii_phy_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val = 0; + static int training_status_bit; + + switch (offset) { + case SGMII_PHY_IOC_REG1: + /* See ddr_pvt_calibration() in HSS */ + val = BIT(4) | BIT(2); + break; + case SGMII_PHY_TRAINING_STATUS: + /* + * The codes logic emulates the training status change from + * DDR_TRAINING_IP_SM_BCLKSCLK to DDR_TRAINING_IP_SM_DQ_DQS. + * + * See ddr_setup() in mss_ddr.c in the HSS source codes. + */ + val = 1 << training_status_bit; + training_status_bit = (training_status_bit + 1) % 5; + break; + case SGMII_PHY_DQ_DQS_ERR_DONE: + /* + * DDR_TRAINING_IP_SM_VERIFY state in ddr_setup(), + * check that DQ/DQS training passed without error. + */ + val = 8; + break; + case SGMII_PHY_DQDQS_STATUS1: + /* + * DDR_TRAINING_IP_SM_VERIFY state in ddr_setup(), + * check that DQ/DQS calculated window is above 5 taps. + */ + val = 0xff; + break; + case SGMII_PHY_PVT_STAT: + /* See sgmii_channel_setup() in HSS */ + val = BIT(14) | BIT(6); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + break; + } + + return val; +} + +static void mchp_pfsoc_ddr_sgmii_phy_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); +} + +static const MemoryRegionOps mchp_pfsoc_ddr_sgmii_phy_ops = { + .read = mchp_pfsoc_ddr_sgmii_phy_read, + .write = mchp_pfsoc_ddr_sgmii_phy_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +static void mchp_pfsoc_ddr_sgmii_phy_realize(DeviceState *dev, Error **errp) +{ + MchpPfSoCDdrSgmiiPhyState *s = MCHP_PFSOC_DDR_SGMII_PHY(dev); + + memory_region_init_io(&s->sgmii_phy, OBJECT(dev), + &mchp_pfsoc_ddr_sgmii_phy_ops, s, + "mchp.pfsoc.ddr_sgmii_phy", + MCHP_PFSOC_DDR_SGMII_PHY_REG_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->sgmii_phy); +} + +static void mchp_pfsoc_ddr_sgmii_phy_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "Microchip PolarFire SoC DDR SGMII PHY module"; + dc->realize = mchp_pfsoc_ddr_sgmii_phy_realize; +} + +static const TypeInfo mchp_pfsoc_ddr_sgmii_phy_info = { + .name = TYPE_MCHP_PFSOC_DDR_SGMII_PHY, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(MchpPfSoCDdrSgmiiPhyState), + .class_init = mchp_pfsoc_ddr_sgmii_phy_class_init, +}; + +static void mchp_pfsoc_ddr_sgmii_phy_register_types(void) +{ + type_register_static(&mchp_pfsoc_ddr_sgmii_phy_info); +} + +type_init(mchp_pfsoc_ddr_sgmii_phy_register_types) + +/* DDR CFG module */ + +#define CFG_MT_DONE_ACK 0x4428 +#define CFG_STAT_DFI_INIT_COMPLETE 0x10034 +#define CFG_STAT_DFI_TRAINING_COMPLETE 0x10038 + +static uint64_t mchp_pfsoc_ddr_cfg_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val = 0; + + switch (offset) { + case CFG_MT_DONE_ACK: + /* memory test in MTC_test() */ + val = BIT(0); + break; + case CFG_STAT_DFI_INIT_COMPLETE: + /* DDR_TRAINING_IP_SM_START_CHECK state in ddr_setup() */ + val = BIT(0); + break; + case CFG_STAT_DFI_TRAINING_COMPLETE: + /* DDR_TRAINING_IP_SM_VERIFY state in ddr_setup() */ + val = BIT(0); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + break; + } + + return val; +} + +static void mchp_pfsoc_ddr_cfg_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); +} + +static const MemoryRegionOps mchp_pfsoc_ddr_cfg_ops = { + .read = mchp_pfsoc_ddr_cfg_read, + .write = mchp_pfsoc_ddr_cfg_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +static void mchp_pfsoc_ddr_cfg_realize(DeviceState *dev, Error **errp) +{ + MchpPfSoCDdrCfgState *s = MCHP_PFSOC_DDR_CFG(dev); + + memory_region_init_io(&s->cfg, OBJECT(dev), + &mchp_pfsoc_ddr_cfg_ops, s, + "mchp.pfsoc.ddr_cfg", + MCHP_PFSOC_DDR_CFG_REG_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->cfg); +} + +static void mchp_pfsoc_ddr_cfg_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "Microchip PolarFire SoC DDR CFG module"; + dc->realize = mchp_pfsoc_ddr_cfg_realize; +} + +static const TypeInfo mchp_pfsoc_ddr_cfg_info = { + .name = TYPE_MCHP_PFSOC_DDR_CFG, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(MchpPfSoCDdrCfgState), + .class_init = mchp_pfsoc_ddr_cfg_class_init, +}; + +static void mchp_pfsoc_ddr_cfg_register_types(void) +{ + type_register_static(&mchp_pfsoc_ddr_cfg_info); +} + +type_init(mchp_pfsoc_ddr_cfg_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index c1d16026ba..d370158069 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1327,8 +1327,10 @@ L: qemu-riscv@nongnu.org S: Supported F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c +F: hw/misc/mchp_pfsoc_dmc.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h +F: include/hw/misc/mchp_pfsoc_dmc.h RX Machines ----------- diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 877ecff447..32ab718cd3 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -139,6 +139,9 @@ config MAC_VIA config AVR_POWER bool +config MCHP_PFSOC_DMC + bool + config SIFIVE_TEST bool diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 4a06cbabef..2d7a517265 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -23,6 +23,7 @@ softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c')) From patchwork Tue Nov 3 15:21:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 538F392C for ; Tue, 3 Nov 2020 15:44:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A59220780 for ; Tue, 3 Nov 2020 15:44:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="QpH2nAqS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A59220780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyUK-0002AB-3D for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:44:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJo-0001x2-JG for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:57 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJg-0001EJ-0b for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417628; x=1635953628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2GIx+t0Rp+fA0ib/C5fOILwZ9azhuSUJ4wg+kNar0QY=; b=QpH2nAqSylakEXG48ZGT3kC9TvePjI4NXBn1t4KxNr481jgjpyDTmeKo 7fm/fTndVzYeqrTbKStFD5P7smg1sYNJRtHmyysRCHODB0hH8zhVqR189 emga2zvCFNY/zrsv76mEsLeWa6pq+vIku8MZ0rtet6Iq56dcMQXLDUaN6 JTuZBg5zwOfjy0AaPXnITXZTHy9b+ajXXTKv2cB4uV/rnAVf3T5s3GeMb zAkR+f22t4Zoj3M13BPqiOlxDdnMG6kTzN1LY95CYp9Pm4A5FOeqwLhF6 DdRauxxVT+DgeOijPb4OJXDB0GAQCwL4J+4tgZn7R01eafYfDYl6XRaEG w==; IronPort-SDR: rOA0H88uRN1sBHmoiF6tC6kT3A9ANfgyWbQUuvkWpz3zLQTP+GCK6Mahhc0nT2tmnSvrFYVlcE H8AWiz5R2/wbbdRX3e1NNnwAAiGkgGn9Czx5goqnwVPol8tlRZC+luDHIT9uyK0gJzYiRz4LfF NblLQiEeXNSfRFw30hVy+yh1GBkktOQxlqSU+nG5WC+1rFOYz+cvMR8Akk0GMjak3/JWBmnpCL TTVb5JC7aBrAeiN4+tC2wwncgUC4YBDp8zeRDCICdLE6nzYVhHqdXzciwc02Ssb5PMteaOJQ46 zPI= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867472" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:26 +0800 IronPort-SDR: BnrdQUJfUstkeaES/zO3f81NJmeVQCPLwSAYSrioJItbbAyaaXglSwUrRRPWt691HBz4XyS+oU cVGVNmXAIoU8hc9fU5azFu0KQWtfmhH6RAa4Nk0sukPeC1XpyZYiCI3pmzfN5BjzIvW3gg4zNq UPqsWY+KPqx8ui8w0UTFRGkrCxbNuNjsmm2oaHiGZUYVVdjGH4gFHiUtYY+Nk4+HC15CJRpqdk wCEqK5IoDUf8gXKVSrlcdWKID54Hwi2CfTD25IeK7/Zx/divNh1kvNqXbwwgyi0kWZPw0AxDDv nnp3ciC4Mrp7NvzFsYegh/gc Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:35 -0800 IronPort-SDR: VaB6cS9oO56+g0FcdvoubVuhomUSFyVpGdqrU3LN1dbBkuEtvEQxpzjJFvOprOv4a2lHsU3DI5 5PeguqYZ0/rBq378qd2HmDuOSv5I2zQq82v/xYahjmALS6Wa7WHhZ+no8hbdSD+ON6FFTqiyO5 uL5ZA6OfJPjYfvsFiU8CdMhclyXfEZXZHhh/oNuFznGY8sMhxsW0VHxUwvbcz78yZo1JbXFJXE zrUgj59fftynNiFOeLqOXz/e9KF7m35XbB1+GOs4y5vremncTW3uSw0jxsiGlg8dgI/OqD+tTa XKk= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:27 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 11/19] hw/riscv: microchip_pfsoc: Connect DDR memory controller modules Date: Tue, 3 Nov 2020 07:21:42 -0800 Message-Id: <20201103152150.2677566-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Connect DDR SGMII PHY module and CFG module to the PolarFire SoC. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-4-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 5 +++++ hw/riscv/microchip_pfsoc.c | 18 ++++++++++++++++++ hw/riscv/Kconfig | 1 + 3 files changed, 24 insertions(+) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index 8bfc7e1a85..5b81e26241 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -24,6 +24,7 @@ #include "hw/char/mchp_pfsoc_mmuart.h" #include "hw/dma/sifive_pdma.h" +#include "hw/misc/mchp_pfsoc_dmc.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h" @@ -37,6 +38,8 @@ typedef struct MicrochipPFSoCState { RISCVHartArrayState e_cpus; RISCVHartArrayState u_cpus; DeviceState *plic; + MchpPfSoCDdrSgmiiPhyState ddr_sgmii_phy; + MchpPfSoCDdrCfgState ddr_cfg; MchpPfSoCMMUartState *serial0; MchpPfSoCMMUartState *serial1; MchpPfSoCMMUartState *serial2; @@ -82,7 +85,9 @@ enum { MICROCHIP_PFSOC_MMUART0, MICROCHIP_PFSOC_SYSREG, MICROCHIP_PFSOC_MPUCFG, + MICROCHIP_PFSOC_DDR_SGMII_PHY, MICROCHIP_PFSOC_EMMC_SD, + MICROCHIP_PFSOC_DDR_CFG, MICROCHIP_PFSOC_MMUART1, MICROCHIP_PFSOC_MMUART2, MICROCHIP_PFSOC_MMUART3, diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 6aac8497fc..3c504f7c03 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -15,6 +15,7 @@ * 4) Cadence eMMC/SDHC controller and an SD card connected to it * 5) SiFive Platform DMA (Direct Memory Access Controller) * 6) GEM (Gigabit Ethernet MAC Controller) + * 7) DMC (DDR Memory Controller) * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -103,7 +104,9 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 }, [MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 }, [MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_SGMII_PHY] = { 0x20007000, 0x1000 }, [MICROCHIP_PFSOC_EMMC_SD] = { 0x20008000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_CFG] = { 0x20080000, 0x40000 }, [MICROCHIP_PFSOC_MMUART1] = { 0x20100000, 0x1000 }, [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 }, [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 }, @@ -149,6 +152,11 @@ static void microchip_pfsoc_soc_instance_init(Object *obj) object_initialize_child(obj, "dma-controller", &s->dma, TYPE_SIFIVE_PDMA); + object_initialize_child(obj, "ddr-sgmii-phy", &s->ddr_sgmii_phy, + TYPE_MCHP_PFSOC_DDR_SGMII_PHY); + object_initialize_child(obj, "ddr-cfg", &s->ddr_cfg, + TYPE_MCHP_PFSOC_DDR_CFG); + object_initialize_child(obj, "gem0", &s->gem0, TYPE_CADENCE_GEM); object_initialize_child(obj, "gem1", &s->gem1, TYPE_CADENCE_GEM); @@ -278,6 +286,16 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_MPUCFG].base, memmap[MICROCHIP_PFSOC_MPUCFG].size); + /* DDR SGMII PHY */ + sysbus_realize(SYS_BUS_DEVICE(&s->ddr_sgmii_phy), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ddr_sgmii_phy), 0, + memmap[MICROCHIP_PFSOC_DDR_SGMII_PHY].base); + + /* DDR CFG */ + sysbus_realize(SYS_BUS_DEVICE(&s->ddr_cfg), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ddr_cfg), 0, + memmap[MICROCHIP_PFSOC_DDR_CFG].base); + /* SDHCI */ sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 2df978fe8d..c8e50bde99 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -4,6 +4,7 @@ config IBEX config MICROCHIP_PFSOC bool select CADENCE_SDHCI + select MCHP_PFSOC_DMC select MCHP_PFSOC_MMUART select MSI_NONBROKEN select SIFIVE_CLINT From patchwork Tue Nov 3 15:21:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BE3292C for ; Tue, 3 Nov 2020 15:37:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D4AE32080D for ; Tue, 3 Nov 2020 15:37:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="XQUa8WMF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4AE32080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyMu-00075T-MX for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:37:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJp-0001xW-O1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:57 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJg-0001FT-48 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:33:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417628; x=1635953628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUh/JVqOCLT6kfbvDNCum6wBBK4GMTnxNOtvXM/5D88=; b=XQUa8WMFOiW92Crdl4Jumzq7HSe/wgUXG/v/ZVf0iSzats5Wf2qfUKcY 3PnBfGwIh2XJ+SjymYGAvSUkLb41vxvRBt2ffAeHcMLsrUcimuVxetOT2 6GuVJe40lRb6776k8CgMIc4EM/8T8De/pZuQwjBa/GwgukN/iwjxU3m8D T6aS+iqpanwzdV2QgU4HmfvjQ7+FFICBM896SVOfNYMkyTEY1f6unwSb0 LzIPSKu3sDnmNq9eqeYlwErGnuzDnZcvvwmMHmiyKJBCvTGRHHSCZ7KDS 9YSBOm2NpKe8QaLWVoGGSwffm/7CqTbjNw8AvwTwbff+MFcf2vx2xAh0O w==; IronPort-SDR: fuAm6qAf0IXACj4QQyC4uB4MymFNknkmjIpOR6sz0vXdJA1aPiLEi3iEFxywOhxhRwTZFCGfoX qG32un85PyqylwbdsrhaDJbX6AXePJCgZVorSZRp0hDg+pVh5N3kbaC2yajXMO2CKtrsHqVO4j 6g7T9C51yAj1+9iCOJLjX1APQB0K4hy5j4LhCm47Kqxt++4vY73JxCF6mGoVndecV1kPZzV26O rCsLLoNIA2ouXAQZCvzSwbFTQk/IbMSkiMOjzHPL2aqVGpjbfPa8LlbVYjor4rv9pEPtml0g4j 9NE= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867474" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:27 +0800 IronPort-SDR: ujIdcjs/v2l9kzOlG4E2cHlr0c2lL83INaU7viWbaHLyf+xd+qEoKtB06fCKE+v40X/RfGIKoe nO00MqhjBu5LxEiL5yYTw/Oetm3lZYxCyvJI4rjRgE+Vm6J6clrBHziDlRQKvWi3rwtBEJCcSY BGkbtW57U6wKNm7t5DczmYH5GEc7f3m1aX1hU0Z1O1/F9VEmY5yceot10cQ+EEbujZgekgnT56 uNKUpQkmn3fI/EW4TzEfECpjTir/ylnUtbdWZBjub2Aj8/3QHu0YbGmXWpOFFvGCInTPM0PxHm p6l94ysAkU5Xl618fzbhcxk9 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:35 -0800 IronPort-SDR: ogilT1I68x2IjS+MWSgQ2JhiaA+IMi89JGdmwIGWVd9qx6SKukqRTXyHtsOAaJp/SEUGvsappf tf1VJ00DrnMAMdURXv9sLJgXy477jd6+KYUlvAhMiX69D1HwLdeLp/ofpfazi/RberEB/uBbmD h7L26SPjPBEFmcymtdOSRR7PsvFYeZIWiW5UBy2VlaLdx5/G2C7jHQAp38xPNGjHWAIpZkW2fy /nBH57ue6kqZWdx904cZ4oHKAqI667abDo5cHsL3txTWtFxQBPSy/N/kNqEG/6qk8hls8c4wKf Q50= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:27 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 12/19] hw/misc: Add Microchip PolarFire SoC IOSCB module support Date: Tue, 3 Nov 2020 07:21:43 -0800 Message-Id: <20201103152150.2677566-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This creates a model for PolarFire SoC IOSCB [1] module. It actually contains lots of sub-modules like various PLLs to control different peripherals. Only the mininum capabilities are emulated to make the HSS DDR memory initialization codes happy. Lots of sub-modules are created as an unimplemented devices. [1] PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm in https://www.microsemi.com/document-portal/doc_download/1244581-polarfire-soc-register-map Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-5-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/misc/mchp_pfsoc_ioscb.h | 50 ++++++ hw/misc/mchp_pfsoc_ioscb.c | 242 +++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + 5 files changed, 298 insertions(+) create mode 100644 include/hw/misc/mchp_pfsoc_ioscb.h create mode 100644 hw/misc/mchp_pfsoc_ioscb.c diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfsoc_ioscb.h new file mode 100644 index 0000000000..9235523e33 --- /dev/null +++ b/include/hw/misc/mchp_pfsoc_ioscb.h @@ -0,0 +1,50 @@ +/* + * Microchip PolarFire SoC IOSCB module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef MCHP_PFSOC_IOSCB_H +#define MCHP_PFSOC_IOSCB_H + +typedef struct MchpPfSoCIoscbState { + SysBusDevice parent; + MemoryRegion container; + MemoryRegion lane01; + MemoryRegion lane23; + MemoryRegion ctrl; + MemoryRegion cfg; + MemoryRegion pll_mss; + MemoryRegion cfm_mss; + MemoryRegion pll_ddr; + MemoryRegion bc_ddr; + MemoryRegion io_calib_ddr; + MemoryRegion pll_sgmii; + MemoryRegion dll_sgmii; + MemoryRegion cfm_sgmii; + MemoryRegion bc_sgmii; + MemoryRegion io_calib_sgmii; +} MchpPfSoCIoscbState; + +#define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb" + +#define MCHP_PFSOC_IOSCB(obj) \ + OBJECT_CHECK(MchpPfSoCIoscbState, (obj), TYPE_MCHP_PFSOC_IOSCB) + +#endif /* MCHP_PFSOC_IOSCB_H */ diff --git a/hw/misc/mchp_pfsoc_ioscb.c b/hw/misc/mchp_pfsoc_ioscb.c new file mode 100644 index 0000000000..8b0d1cacd7 --- /dev/null +++ b/hw/misc/mchp_pfsoc_ioscb.c @@ -0,0 +1,242 @@ +/* + * Microchip PolarFire SoC IOSCB module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/hw.h" +#include "hw/sysbus.h" +#include "hw/misc/mchp_pfsoc_ioscb.h" + +/* + * The whole IOSCB module registers map into the system address at 0x3000_0000, + * named as "System Port 0 (AXI-D0)". + */ +#define IOSCB_WHOLE_REG_SIZE 0x10000000 +#define IOSCB_SUBMOD_REG_SIZE 0x1000 + +/* + * There are many sub-modules in the IOSCB module. + * See Microchip PolarFire SoC documentation (Register_Map.zip), + * Register Map/PF_SoC_RegMap_V1_1/MPFS250T/mpfs250t_ioscb_memmap_dri.htm + * + * The following are sub-modules offsets that are of concern. + */ +#define IOSCB_LANE01_BASE 0x06500000 +#define IOSCB_LANE23_BASE 0x06510000 +#define IOSCB_CTRL_BASE 0x07020000 +#define IOSCB_CFG_BASE 0x07080000 +#define IOSCB_PLL_MSS_BASE 0x0E001000 +#define IOSCB_CFM_MSS_BASE 0x0E002000 +#define IOSCB_PLL_DDR_BASE 0x0E010000 +#define IOSCB_BC_DDR_BASE 0x0E020000 +#define IOSCB_IO_CALIB_DDR_BASE 0x0E040000 +#define IOSCB_PLL_SGMII_BASE 0x0E080000 +#define IOSCB_DLL_SGMII_BASE 0x0E100000 +#define IOSCB_CFM_SGMII_BASE 0x0E200000 +#define IOSCB_BC_SGMII_BASE 0x0E400000 +#define IOSCB_IO_CALIB_SGMII_BASE 0x0E800000 + +static uint64_t mchp_pfsoc_dummy_read(void *opaque, hwaddr offset, + unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + + return 0; +} + +static void mchp_pfsoc_dummy_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); +} + +static const MemoryRegionOps mchp_pfsoc_dummy_ops = { + .read = mchp_pfsoc_dummy_read, + .write = mchp_pfsoc_dummy_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +/* All PLL modules in IOSCB have the same register layout */ + +#define PLL_CTRL 0x04 + +static uint64_t mchp_pfsoc_pll_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val = 0; + + switch (offset) { + case PLL_CTRL: + /* PLL is locked */ + val = BIT(25); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + break; + } + + return val; +} + +static const MemoryRegionOps mchp_pfsoc_pll_ops = { + .read = mchp_pfsoc_pll_read, + .write = mchp_pfsoc_dummy_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +/* IO_CALIB_DDR submodule */ + +#define IO_CALIB_DDR_IOC_REG1 0x08 + +static uint64_t mchp_pfsoc_io_calib_ddr_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val = 0; + + switch (offset) { + case IO_CALIB_DDR_IOC_REG1: + /* calibration completed */ + val = BIT(2); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + break; + } + + return val; +} + +static const MemoryRegionOps mchp_pfsoc_io_calib_ddr_ops = { + .read = mchp_pfsoc_io_calib_ddr_read, + .write = mchp_pfsoc_dummy_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +static void mchp_pfsoc_ioscb_realize(DeviceState *dev, Error **errp) +{ + MchpPfSoCIoscbState *s = MCHP_PFSOC_IOSCB(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + + memory_region_init(&s->container, OBJECT(s), + "mchp.pfsoc.ioscb", IOSCB_WHOLE_REG_SIZE); + sysbus_init_mmio(sbd, &s->container); + + /* add subregions for all sub-modules in IOSCB */ + + memory_region_init_io(&s->lane01, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.lane01", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_LANE01_BASE, &s->lane01); + + memory_region_init_io(&s->lane23, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.lane23", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_LANE23_BASE, &s->lane23); + + memory_region_init_io(&s->ctrl, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.ctrl", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_CTRL_BASE, &s->ctrl); + + memory_region_init_io(&s->cfg, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.cfg", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_CFG_BASE, &s->cfg); + + memory_region_init_io(&s->pll_mss, OBJECT(s), &mchp_pfsoc_pll_ops, s, + "mchp.pfsoc.ioscb.pll_mss", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_PLL_MSS_BASE, &s->pll_mss); + + memory_region_init_io(&s->cfm_mss, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.cfm_mss", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_CFM_MSS_BASE, &s->cfm_mss); + + memory_region_init_io(&s->pll_ddr, OBJECT(s), &mchp_pfsoc_pll_ops, s, + "mchp.pfsoc.ioscb.pll_ddr", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_PLL_DDR_BASE, &s->pll_ddr); + + memory_region_init_io(&s->bc_ddr, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.bc_ddr", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_BC_DDR_BASE, &s->bc_ddr); + + memory_region_init_io(&s->io_calib_ddr, OBJECT(s), + &mchp_pfsoc_io_calib_ddr_ops, s, + "mchp.pfsoc.ioscb.io_calib_ddr", + IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_IO_CALIB_DDR_BASE, + &s->io_calib_ddr); + + memory_region_init_io(&s->pll_sgmii, OBJECT(s), &mchp_pfsoc_pll_ops, s, + "mchp.pfsoc.ioscb.pll_sgmii", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_PLL_SGMII_BASE, + &s->pll_sgmii); + + memory_region_init_io(&s->dll_sgmii, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.dll_sgmii", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_DLL_SGMII_BASE, + &s->dll_sgmii); + + memory_region_init_io(&s->cfm_sgmii, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.cfm_sgmii", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_CFM_SGMII_BASE, + &s->cfm_sgmii); + + memory_region_init_io(&s->bc_sgmii, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.bc_sgmii", IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_BC_SGMII_BASE, + &s->bc_sgmii); + + memory_region_init_io(&s->io_calib_sgmii, OBJECT(s), &mchp_pfsoc_dummy_ops, + s, "mchp.pfsoc.ioscb.io_calib_sgmii", + IOSCB_SUBMOD_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_IO_CALIB_SGMII_BASE, + &s->io_calib_sgmii); +} + +static void mchp_pfsoc_ioscb_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "Microchip PolarFire SoC IOSCB modules"; + dc->realize = mchp_pfsoc_ioscb_realize; +} + +static const TypeInfo mchp_pfsoc_ioscb_info = { + .name = TYPE_MCHP_PFSOC_IOSCB, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(MchpPfSoCIoscbState), + .class_init = mchp_pfsoc_ioscb_class_init, +}; + +static void mchp_pfsoc_ioscb_register_types(void) +{ + type_register_static(&mchp_pfsoc_ioscb_info); +} + +type_init(mchp_pfsoc_ioscb_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index d370158069..0e597c2989 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1328,9 +1328,11 @@ S: Supported F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c F: hw/misc/mchp_pfsoc_dmc.c +F: hw/misc/mchp_pfsoc_ioscb.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h F: include/hw/misc/mchp_pfsoc_dmc.h +F: include/hw/misc/mchp_pfsoc_ioscb.h RX Machines ----------- diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 32ab718cd3..4ff01ec4be 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -142,6 +142,9 @@ config AVR_POWER config MCHP_PFSOC_DMC bool +config MCHP_PFSOC_IOSCB + bool + config SIFIVE_TEST bool diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 2d7a517265..770149e47a 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -24,6 +24,7 @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c')) From patchwork Tue Nov 3 15:21:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FA6592A for ; Tue, 3 Nov 2020 15:46:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7BC520780 for ; Tue, 3 Nov 2020 15:46:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="OJcIgCSH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7BC520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:60722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyVY-00039u-Rx for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:46:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJx-00029s-57 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:05 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJv-0001Fa-1P for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417643; x=1635953643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o8QV0Me158q9SB0wiG+MH22S5sqXbxbb5FbSRzMEA74=; b=OJcIgCSHhxmouy7R+SEAhviFxByHet/3htk1I0461YqWjCzg4CX9Ap3f H6Mwz+7LtN0SXZmaiYVY99FGE/y2MEviA2OOgxJcBXb9OKza3ZRqbkVoc MM+mSsaBvTYfvGN2FiZ3KlM6r9E4dm2iS5ezouoK36yiyLZ1o+ul7d0C6 48+rtBF09/NlnMikxw3M4bK9RBsxc0Aba9117qAaxpZoLRAsuCNZckOAb LCfneuou/elYiJrQP7IgvD9g0eheS9dqSWAQ2XSMW0gj0QOwPbJ5e8YLa mHFkhJfnFK1O8x3Bg1P92c0kKycusqd2V3KPGUkInB1p4ZI+1MZ6F06vW A==; IronPort-SDR: R0QAT2hE7cnuY23srIFacNo3z28mKebo4umYvnqRPgTn9/Ydo+xpdSJFhULPUpk0KXZULWeitw 2yagp8dKmy4ywLQgTZvlrhXG8P0H/0RtCtNTGJwvAsX8vHTf2ElRp27SyAwXJmsV6jkJXLfAtW D0RJWHazCWvI5ypkENhpo0Ki2y7XVQSPCT+vrBqaG2ehLUaqSC/Uv+1KRuWeBl5fgmQRUHo37O H6clodwyAMyJrQDAGuXAGVCdVzx2XAGVmvdYVChJ+I4N7zjPGdoxJPptmrwtz0p1Lmi5vzvqbh ces= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867477" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:27 +0800 IronPort-SDR: rAIayDd/7eHgy8sNjat7Klt8T0phDXaI4h0jYkGL++oO5LH79DXKl0aT22frz7HDBxKT5iJAmG OSHVvrOKHEruZCI8zYDeXp3WSUo7osX4Hi1zcSf2iaQjPc+JNveOuW430dFlbfknrSMoYCGT5q Ez/oXOoxy2QUkt2tD9GXuM35InIUMruObZ/A5pLBYFLYXu5edGvWdKgcuXREGfHpffDlr47tcE z1ABYMuEwBtLKjHe/axG4z9k9EWFhzHEw81+ChFt1DbB9BZyAF+mKqcpuTnDI3yoEe3Ry2w7He CPDjAt8XkQKlnhrsWwOFFsoF Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:35 -0800 IronPort-SDR: c+YPWVcfGbxr8+UbFLK2oYATqnuf57mP/P5+HLjg/Edc0vkTn86vc4aqUeiIFYtR5+cA7v5pjP HBk8OWHhPXfDuXarmrHTi76Ke2DSFdS/GMLwr5fiu1nv4anihbNQ50HXkFqpSrYuPu5DMs2cOl fL3vw8/LJ+TOQ+iQ+EmiwruXIV2QLiH1QdR7Ig6yINp4K/uZ8oI3t3tqVlvZRCj6nCd4rBm+4Q F+QBPSLfQTtOs4TwjXEm/kGQ4LUlbYWoHuy4C91xrKmnTuKsdppyj0YXDkElkoqdExrTsXIEkH ihg= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:27 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 13/19] hw/riscv: microchip_pfsoc: Connect the IOSCB module Date: Tue, 3 Nov 2020 07:21:44 -0800 Message-Id: <20201103152150.2677566-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Previously IOSCB_CFG was created as an unimplemented device. With the new IOSCB model, its memory range is already covered by the IOSCB hence remove the previous unimplemented device creation in the SoC codes. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-6-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 4 +++- hw/riscv/microchip_pfsoc.c | 13 ++++++++----- hw/riscv/Kconfig | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index 5b81e26241..a244ae6d39 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -25,6 +25,7 @@ #include "hw/char/mchp_pfsoc_mmuart.h" #include "hw/dma/sifive_pdma.h" #include "hw/misc/mchp_pfsoc_dmc.h" +#include "hw/misc/mchp_pfsoc_ioscb.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h" @@ -40,6 +41,7 @@ typedef struct MicrochipPFSoCState { DeviceState *plic; MchpPfSoCDdrSgmiiPhyState ddr_sgmii_phy; MchpPfSoCDdrCfgState ddr_cfg; + MchpPfSoCIoscbState ioscb; MchpPfSoCMMUartState *serial0; MchpPfSoCMMUartState *serial1; MchpPfSoCMMUartState *serial2; @@ -99,7 +101,7 @@ enum { MICROCHIP_PFSOC_GPIO2, MICROCHIP_PFSOC_ENVM_CFG, MICROCHIP_PFSOC_ENVM_DATA, - MICROCHIP_PFSOC_IOSCB_CFG, + MICROCHIP_PFSOC_IOSCB, MICROCHIP_PFSOC_DRAM, }; diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 3c504f7c03..438e0c464d 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -16,6 +16,7 @@ * 5) SiFive Platform DMA (Direct Memory Access Controller) * 6) GEM (Gigabit Ethernet MAC Controller) * 7) DMC (DDR Memory Controller) + * 8) IOSCB modules * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -118,7 +119,7 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_GPIO2] = { 0x20122000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, - [MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 }, + [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 }, }; @@ -162,6 +163,8 @@ static void microchip_pfsoc_soc_instance_init(Object *obj) object_initialize_child(obj, "sd-controller", &s->sdhci, TYPE_CADENCE_SDHCI); + + object_initialize_child(obj, "ioscb", &s->ioscb, TYPE_MCHP_PFSOC_IOSCB); } static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) @@ -373,10 +376,10 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_ENVM_DATA].base, envm_data); - /* IOSCBCFG */ - create_unimplemented_device("microchip.pfsoc.ioscb.cfg", - memmap[MICROCHIP_PFSOC_IOSCB_CFG].base, - memmap[MICROCHIP_PFSOC_IOSCB_CFG].size); + /* IOSCB */ + sysbus_realize(SYS_BUS_DEVICE(&s->ioscb), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ioscb), 0, + memmap[MICROCHIP_PFSOC_IOSCB].base); } static void microchip_pfsoc_soc_class_init(ObjectClass *oc, void *data) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index c8e50bde99..8f043e38e0 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -5,6 +5,7 @@ config MICROCHIP_PFSOC bool select CADENCE_SDHCI select MCHP_PFSOC_DMC + select MCHP_PFSOC_IOSCB select MCHP_PFSOC_MMUART select MSI_NONBROKEN select SIFIVE_CLINT From patchwork Tue Nov 3 15:21:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12C1F697 for ; Tue, 3 Nov 2020 16:01:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8B6F223C7 for ; Tue, 3 Nov 2020 16:01:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="AHdX+xyT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8B6F223C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZykG-0004sf-MF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 11:01:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyK2-0002M1-11 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:10 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyJz-0001EJ-Gi for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417648; x=1635953648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZFmgjHUuJNXRrAu1T34hiTrmmtdxLEyK19w6m80jsqM=; b=AHdX+xyTs7zOyY0WCEgmdGd4swRvnbkmMPywXLunxy7Smkxobt11B8fj /BmjBINGq0L7fOvkWV11335qTVc1ExUgZMNRUFECVXAcaauTdHGJKUSxe R4WPJ4zBU26zE2RnpE1EMSo32LoG3cYBnLeUmjPS5fHzrQAnMDZh4tOXj ygc4LyCnZktN8WKg5uctvhi1DBnqnOfabiKQoal9XyQ5hCZ2RtpNlP689 X0wN+tmKhpnC8GQjJMPY7FkROMqfNlvBe7aVuySSaOBp/zsE+xCpJXJ6W lDWXixab1FXcFyVeLygHsDod2akd3SIdBbb43KRbGUeLyeZmxS7HaRJW1 g==; IronPort-SDR: zQUOQ8EXw2n0jJUQfR4pi38kHX01lk897GdBiyCYR0m69MhccvcrG8fZb4U4ncT9IAbGaJtqQU jEHJPoCccBnDn+9IiOF+elmS0OVBG96h12GAmAOnf+1yZqQ5zwVecKlOegJay9cjN5Oqaewfw2 OaIrlbPsiK/EWxZtbWeUTA/Peu1gL5vYLzI/+qpNqiXV72zXsaEp4xI4r1Afup7uF6CY9g6nu5 6csu66LSFeRMGbkfYXCgmoSZp/sgTbcVXoOUq204GI3pl1ts6hEwNldd61vvRCSJeTjjJPjW0z 3X8= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867479" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:27 +0800 IronPort-SDR: 9O+FYCZGVku1hZdqHyQnX0M1F+g/Rb92C+qnYNFtwa60MuqbGKVsrDpCq3BzY0GHuBd9b5M21t GXRKhNjRrzOTxO1vg+2+sX7+vpT/jN27ZeSNBLyZe30sq0MvtEU/Qzc8EtWbCyYTsiTXUIzmUY HnEym5nb3fVTvFHrJDwZ8N0w45b/KQD3ljK/pItc+FrWRoEJzq44gJdzVCoeqDVXVdbX1EQNlF Q49cYS4TDVhfSrZbiXi3thS56lFGdWrVXicIlXcR/To/X6AuKY5Lulue6APDGmvQz7VsjkkJCl 1kJBN9vtBbqHb/XQwQL3fDLg Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:36 -0800 IronPort-SDR: Za2g24C+nHDgN/tWucdTFaqAw/MBS4fMm5kT8+p0JSvmU5yzuN3XRCu/LAv9Hx/ulriRHrSfnp O5DRRpEjuq0cw/ZPfOoNENmMGrDeWr0E1cmVgDFVEQAxWbIDFacpcb7qcrce/u4W5D/MmpIZfj EkHD6DyMI7WO0P3afP0ni+8V4GrwSyRmUBalmjwZz2G89WgWypzXSK+LjfnkeXWmJgQp8weFOa 2Vyc6k3NlKUlZmAPv5SODNCygfPIuopbx4vGJdbxkb0kYMsOfyWgDkoKya5O8n1ttHSMdFqLVq YkU= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:27 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 14/19] hw/misc: Add Microchip PolarFire SoC SYSREG module support Date: Tue, 3 Nov 2020 07:21:45 -0800 Message-Id: <20201103152150.2677566-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This creates a minimum model for Microchip PolarFire SoC SYSREG module. It only implements the ENVM_CR register to tell guest software that eNVM is running at the configured divider rate. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-7-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/misc/mchp_pfsoc_sysreg.h | 39 ++++++++++++ hw/misc/mchp_pfsoc_sysreg.c | 99 +++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + 5 files changed, 144 insertions(+) create mode 100644 include/hw/misc/mchp_pfsoc_sysreg.h create mode 100644 hw/misc/mchp_pfsoc_sysreg.c diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfsoc_sysreg.h new file mode 100644 index 0000000000..546ba68f6a --- /dev/null +++ b/include/hw/misc/mchp_pfsoc_sysreg.h @@ -0,0 +1,39 @@ +/* + * Microchip PolarFire SoC SYSREG module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef MCHP_PFSOC_SYSREG_H +#define MCHP_PFSOC_SYSREG_H + +#define MCHP_PFSOC_SYSREG_REG_SIZE 0x2000 + +typedef struct MchpPfSoCSysregState { + SysBusDevice parent; + MemoryRegion sysreg; +} MchpPfSoCSysregState; + +#define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg" + +#define MCHP_PFSOC_SYSREG(obj) \ + OBJECT_CHECK(MchpPfSoCSysregState, (obj), \ + TYPE_MCHP_PFSOC_SYSREG) + +#endif /* MCHP_PFSOC_SYSREG_H */ diff --git a/hw/misc/mchp_pfsoc_sysreg.c b/hw/misc/mchp_pfsoc_sysreg.c new file mode 100644 index 0000000000..248a313345 --- /dev/null +++ b/hw/misc/mchp_pfsoc_sysreg.c @@ -0,0 +1,99 @@ +/* + * Microchip PolarFire SoC SYSREG module emulation + * + * Copyright (c) 2020 Wind River Systems, Inc. + * + * Author: + * Bin Meng + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/hw.h" +#include "hw/sysbus.h" +#include "hw/misc/mchp_pfsoc_sysreg.h" + +#define ENVM_CR 0xb8 + +static uint64_t mchp_pfsoc_sysreg_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val = 0; + + switch (offset) { + case ENVM_CR: + /* Indicate the eNVM is running at the configured divider rate */ + val = BIT(6); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + break; + } + + return val; +} + +static void mchp_pfsoc_sysreg_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); +} + +static const MemoryRegionOps mchp_pfsoc_sysreg_ops = { + .read = mchp_pfsoc_sysreg_read, + .write = mchp_pfsoc_sysreg_write, + .endianness = DEVICE_LITTLE_ENDIAN, +}; + +static void mchp_pfsoc_sysreg_realize(DeviceState *dev, Error **errp) +{ + MchpPfSoCSysregState *s = MCHP_PFSOC_SYSREG(dev); + + memory_region_init_io(&s->sysreg, OBJECT(dev), + &mchp_pfsoc_sysreg_ops, s, + "mchp.pfsoc.sysreg", + MCHP_PFSOC_SYSREG_REG_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->sysreg); +} + +static void mchp_pfsoc_sysreg_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "Microchip PolarFire SoC SYSREG module"; + dc->realize = mchp_pfsoc_sysreg_realize; +} + +static const TypeInfo mchp_pfsoc_sysreg_info = { + .name = TYPE_MCHP_PFSOC_SYSREG, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(MchpPfSoCSysregState), + .class_init = mchp_pfsoc_sysreg_class_init, +}; + +static void mchp_pfsoc_sysreg_register_types(void) +{ + type_register_static(&mchp_pfsoc_sysreg_info); +} + +type_init(mchp_pfsoc_sysreg_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 0e597c2989..dd16606bcd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1329,10 +1329,12 @@ F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c F: hw/misc/mchp_pfsoc_dmc.c F: hw/misc/mchp_pfsoc_ioscb.c +F: hw/misc/mchp_pfsoc_sysreg.c F: include/hw/riscv/microchip_pfsoc.h F: include/hw/char/mchp_pfsoc_mmuart.h F: include/hw/misc/mchp_pfsoc_dmc.h F: include/hw/misc/mchp_pfsoc_ioscb.h +F: include/hw/misc/mchp_pfsoc_sysreg.h RX Machines ----------- diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 4ff01ec4be..dc44dc14f6 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -145,6 +145,9 @@ config MCHP_PFSOC_DMC config MCHP_PFSOC_IOSCB bool +config MCHP_PFSOC_SYSREG + bool + config SIFIVE_TEST bool diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 770149e47a..1cd48e8a0f 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -25,6 +25,7 @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) # RISC-V devices softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c')) +softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_SYSREG', if_true: files('mchp_pfsoc_sysreg.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c')) From patchwork Tue Nov 3 15:21:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D208F697 for ; Tue, 3 Nov 2020 16:02:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 179D222264 for ; Tue, 3 Nov 2020 16:02:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="o4UdPBo5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 179D222264 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:52854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZylR-0006TN-Vq for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 11:02:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyK2-0002MR-DT for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:10 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyK0-0001FT-AL for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417648; x=1635953648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2q5eaqHnasSx88RF++/1bEt2K4A/LzHypBeMeKb6C/M=; b=o4UdPBo5W1PlAdkBeu8gTf/SeW8qjVkF9bzpqQHSgPTiIedi64TUyLse 10yLoYk7/BwTy/+lqAxF3iXAULxDwEilCncib/Imo11BbynxlvwkEpk9u t8su9b7nT5hsi/rJtSvmxK/Vv484T9nc1+65TE5226DZWxfEyLO6/wsr2 RC9Ym6lbsvSOKPtX8sQ1DyolvKyL0BN39g/OwYqYjCQCDmsC7ja1nbSaL c16Tz0J+ZS/L9jwEOEENMpKYBV+pxkGtCs7PJoIjz7WdgbWxIiP+RSEXF 1IJStw4YFb37mApN83KkZ4SPgAW//1FuQZmg4wS02ovI9ocIqqB7RNXVH A==; IronPort-SDR: NXB2E02c/8KIAurU4N6QCn7FxVU4ptSUIoImsN79MSnzuz1+gd5z7sFX2OnNV3QaZiXYD4bZ/B P8+vGU2En0j4WFXKBU/PWWrq+AZL8ov5lXIGKh5QW5wp8CF+otTvRJqva/OTbdoYM2AsHkHZyI hPks67Mwbx9JHiyvKdrqczyMvwDMR3CfOWbAxiTMslTT4WhN+IbbylTu2vTo5kEQ6NxLzI8cMv Dbx2CV4TWAiy2vSpFvN3XGEYkkWcLbMl5t0SCkIu+GqbjFR907AGRpTnxqVwWOa+diOdtkykPS Fj4= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867482" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:27 +0800 IronPort-SDR: WCpHK4Cr6jekYe5exuiKuwMIUKXYQhitlN7t6dRplHcDyigubEHHQxFl+WvNrwkUZh2/CUEKXK lyOxo7R0ZfmGzCrnLmTk1AhPekNwYA26Zqv9AdMT0WMinN7iYVamwjCSrdTS3tVjW6YJDWwdCh 2VgjoS0rGLWW9v3ZbmmVM1NGBzfGqp3l/Z9Sqeoxh01LlE+QuEiHgno4R+c87EgHI9SohFtEzh jCTg3dhOfeHhLIhOdHykFJktcWmmLAVTJ6KX8ciPTK2cVksMzwHCudOTwQoBYfbid8ZSffdQO+ LdF3iIle55ZFJVF2TLNTSbQa Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:36 -0800 IronPort-SDR: vkgOX51/ypMSSMceV7JPU8nfABUyjr/u2M7GXOfzPahUihzXV1E+Yyl5e6/hWZd7eKXqH1o1Tj x2l8NHmEKtmE3tis2Ofzpv9T5y3FA8imofWTj9kGWfv78DXsmTovBDZvPF/K0YPvPguGaEI0jt AJYnfw9TqbQW+Vnen4zQvTVr/PgOIC6r+d2oc+yFZfAenxi7Gi5/Y2Rhtz7o5655lGKfdmdf7h jJUSIBfcFrSb1Kd3VR+58TAppZEG+acqRqbsOjdTgCcDUjV7XIjOteeKRtQ5vwod9L0nX1fkOf SEc= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:28 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 15/19] hw/riscv: microchip_pfsoc: Connect the SYSREG module Date: Tue, 3 Nov 2020 07:21:46 -0800 Message-Id: <20201103152150.2677566-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Previously SYSREG was created as an unimplemented device. Now that we have a simple SYSREG module, connect it. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-8-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 2 ++ hw/riscv/microchip_pfsoc.c | 9 ++++++--- hw/riscv/Kconfig | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index a244ae6d39..245c82db61 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -26,6 +26,7 @@ #include "hw/dma/sifive_pdma.h" #include "hw/misc/mchp_pfsoc_dmc.h" #include "hw/misc/mchp_pfsoc_ioscb.h" +#include "hw/misc/mchp_pfsoc_sysreg.h" #include "hw/net/cadence_gem.h" #include "hw/sd/cadence_sdhci.h" @@ -47,6 +48,7 @@ typedef struct MicrochipPFSoCState { MchpPfSoCMMUartState *serial2; MchpPfSoCMMUartState *serial3; MchpPfSoCMMUartState *serial4; + MchpPfSoCSysregState sysreg; SiFivePDMAState dma; CadenceGEMState gem0; CadenceGEMState gem1; diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 438e0c464d..bc908e07d9 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -153,6 +153,9 @@ static void microchip_pfsoc_soc_instance_init(Object *obj) object_initialize_child(obj, "dma-controller", &s->dma, TYPE_SIFIVE_PDMA); + object_initialize_child(obj, "sysreg", &s->sysreg, + TYPE_MCHP_PFSOC_SYSREG); + object_initialize_child(obj, "ddr-sgmii-phy", &s->ddr_sgmii_phy, TYPE_MCHP_PFSOC_DDR_SGMII_PHY); object_initialize_child(obj, "ddr-cfg", &s->ddr_cfg, @@ -280,9 +283,9 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) } /* SYSREG */ - create_unimplemented_device("microchip.pfsoc.sysreg", - memmap[MICROCHIP_PFSOC_SYSREG].base, - memmap[MICROCHIP_PFSOC_SYSREG].size); + sysbus_realize(SYS_BUS_DEVICE(&s->sysreg), errp); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysreg), 0, + memmap[MICROCHIP_PFSOC_SYSREG].base); /* MPUCFG */ create_unimplemented_device("microchip.pfsoc.mpucfg", diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 8f043e38e0..facb0cbacc 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -7,6 +7,7 @@ config MICROCHIP_PFSOC select MCHP_PFSOC_DMC select MCHP_PFSOC_IOSCB select MCHP_PFSOC_MMUART + select MCHP_PFSOC_SYSREG select MSI_NONBROKEN select SIFIVE_CLINT select SIFIVE_PDMA From patchwork Tue Nov 3 15:21:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88D0C92C for ; Tue, 3 Nov 2020 15:47:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29D7022280 for ; Tue, 3 Nov 2020 15:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="K3c8GjPm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29D7022280 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyWy-0004xD-6N for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:47:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKF-0002RX-Cw for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:24 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyK7-0001Fa-Fg for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417656; x=1635953656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=az4hi+7Qmy3zzRkU/t2y0reaYkYBTtPhn+llQuZih24=; b=K3c8GjPm9BGvp1BrI5Vxxyy0ZoQWevYRlUlRA4O1whWJsK8ciEyRaq0/ zDzWFr3QvL323SoTALA2EaAGRAJ8ZEAB8NMwVqebrWSeLYxNErWlY+2qf HRA8WpXPJD2Vds8UcgwyucgKh6RwaXPJkPXIt0Hxb0xTP24EMIDk0E8WR X2xXxg2oxPdfCJLbgtd7Bf4AcWpg6c0dMGMeaKSH5LtPPBp2YSNiBtYOF BkJJwu+dIs+DeTBdUmsT1aM7f548siwJ4hBIZ3CgVy2hYEt3tBiurGlmp qjpfE7GaoVXaZ8pL14ZNBFnYu/iN7pjFpoGdd18ZHoLmGPlQbUGSEC2Hn A==; IronPort-SDR: nT5XZpdCrLdOKN981q414wj2A/C6m8JV4st/vzS5QbCK/jbrCNcx2FwnlpPk8Hbs5bfclUKINf h8sF+NF8a3HLJ0Out06PyCnFbQGtfc8Xi9aO88OZOtAbCxdMPeoXwB1ElgGZcyzQTMHKa/DM59 DOlghwHcI+Vu8RAzchoLMJhM1Lb/dHlQYnRCrx6yh8rHlKCeKxgaVQ1xR9QnZPCgHl2+veQakp 5nhQzSapV95CJqo48x4faB3WfvTcK7KV6w09jpLRKuIs9T/F+Hvkpx3EG67p87c4QJbPgHUdrK DKk= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867483" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:28 +0800 IronPort-SDR: lq9PwhdGEF/XnKJwPFd5tMYBetEqBErZdHQCviF7seZopPiuU9I0QCX5MOtLVZbT30dobsA+sh DkpgOhFcWaXI58csuxJPQAlPUrSu1ingw9WnnYgb7ufqQJiMLXeeKxRKeGQpNal7eB/P2hIHj3 lIm4b75ckI3VHWz8FE2LYMXRB/yNZB+vDahfFO43ETyrWRAHZRFgy1tAbzWp0YezJGN5H4unD7 h7vZsDGD3V0hN0yW9MGqrpimt7i4M+2+FMeLhcsP1yoIQ0ycrIBYrLn7uyH+dC53DTYmRl0+Pw HL6DPgfoNdNXyh9CeqaPrK5+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:36 -0800 IronPort-SDR: BhWFul50anFknOln8z3xVmSXYQfYpheF7gb0VhzdEZtK+WSB22u6ImU3VhUB0mstQ9vs3hrYn3 P9gLLJCetY0FQyp0BBK6o9Qi5i7hM3jgxFIyJkuU92lqqXnWMTJBTVpJBCIsCrgpkOyA99eKt3 v7EczKukGcS7WvAL9zLjPOpsZO45rXV89VmPRFTDdqfu3fiNM1N3C6yXIJ0mELw3yM2dg7b8BL P4TvFlXTs5VIRzvFPqtHMRRFWO0M5lePzW6YuEMfywOriGtW6GfgG3ZhSVf673m5maDSHn0KB2 oAQ= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:28 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 16/19] hw/riscv: microchip_pfsoc: Map the reserved memory at address 0 Date: Tue, 3 Nov 2020 07:21:47 -0800 Message-Id: <20201103152150.2677566-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Somehow HSS needs to access address 0 [1] for the DDR calibration data which is in the chipset's reserved memory. Let's map it. [1] See the config_copy() calls in various places in ddr_setup() in the HSS source codes. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-9-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 1 + hw/riscv/microchip_pfsoc.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index 245c82db61..f34a6b3fd7 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -74,6 +74,7 @@ typedef struct MicrochipIcicleKitState { TYPE_MICROCHIP_ICICLE_KIT_MACHINE) enum { + MICROCHIP_PFSOC_RSVD0, MICROCHIP_PFSOC_DEBUG, MICROCHIP_PFSOC_E51_DTIM, MICROCHIP_PFSOC_BUSERR_UNIT0, diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index bc908e07d9..44a84732ac 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -90,7 +90,8 @@ static const struct MemmapEntry { hwaddr base; hwaddr size; } microchip_pfsoc_memmap[] = { - [MICROCHIP_PFSOC_DEBUG] = { 0x0, 0x1000 }, + [MICROCHIP_PFSOC_RSVD0] = { 0x0, 0x100 }, + [MICROCHIP_PFSOC_DEBUG] = { 0x100, 0xf00 }, [MICROCHIP_PFSOC_E51_DTIM] = { 0x1000000, 0x2000 }, [MICROCHIP_PFSOC_BUSERR_UNIT0] = { 0x1700000, 0x1000 }, [MICROCHIP_PFSOC_BUSERR_UNIT1] = { 0x1701000, 0x1000 }, @@ -176,6 +177,7 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) MicrochipPFSoCState *s = MICROCHIP_PFSOC(dev); const struct MemmapEntry *memmap = microchip_pfsoc_memmap; MemoryRegion *system_memory = get_system_memory(); + MemoryRegion *rsvd0_mem = g_new(MemoryRegion, 1); MemoryRegion *e51_dtim_mem = g_new(MemoryRegion, 1); MemoryRegion *l2lim_mem = g_new(MemoryRegion, 1); MemoryRegion *envm_data = g_new(MemoryRegion, 1); @@ -195,6 +197,13 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) qdev_realize(DEVICE(&s->e_cluster), NULL, &error_abort); qdev_realize(DEVICE(&s->u_cluster), NULL, &error_abort); + /* Reserved Memory at address 0 */ + memory_region_init_ram(rsvd0_mem, NULL, "microchip.pfsoc.rsvd0_mem", + memmap[MICROCHIP_PFSOC_RSVD0].size, &error_fatal); + memory_region_add_subregion(system_memory, + memmap[MICROCHIP_PFSOC_RSVD0].base, + rsvd0_mem); + /* E51 DTIM */ memory_region_init_ram(e51_dtim_mem, NULL, "microchip.pfsoc.e51_dtim_mem", memmap[MICROCHIP_PFSOC_E51_DTIM].size, &error_fatal); From patchwork Tue Nov 3 15:21:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7982D166C for ; Tue, 3 Nov 2020 15:39:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B3D920756 for ; Tue, 3 Nov 2020 15:39:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="f04RQgJ7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B3D920756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyPV-0002JQ-5U for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKN-0002TF-3R for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:31 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKD-0001EJ-Gb for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417662; x=1635953662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GQeiFHPgNUNLdTN/HqvHjPj+kySyVyfKiMFndpNHjIA=; b=f04RQgJ74XBNl6U2iry4QwjYaSxE+hz0o4J2DlbzDA+lRgWj7N9nuabk ucZn62px1kIO47w+6pwjG49Vge/hjcGeG+w+AXTCfB7N185oZvIwJJTXU QPbaUirqNnl1BBm/gHY0ARlMpnIbifZuPHUTnBl9e9SqoyMGkd8RUAxM4 k/rHYsO9s8LReCBLyNNrTdrsJ3zeVQS8c9TvFzpZlHA5MbOgNB6nAS3AP yuofTT/lZaMQBGIQkX0F4AioGOJY5EGPhLvsM3tZqmjFzbBiFlGDiyvcF wvC0bIGbPa2e/N/exANtRiIjcus3D7cmg0/MC4OCsJXVpHKa8RyjxS11v Q==; IronPort-SDR: fGS/xKaVKE5Df6JnlX6WkC/ql4xgocfKt2mT93Y0kx7/5/YB74RYub5+5xvhqdyje1zgFA6lZQ pEUikK8GH5Tv/Vgc/NSTPVI5LBehwEh7DEAOdIy2xwJJN4163+26rpcY5VvZU8aLB3t5n1YQg1 sW9eBLqP90luPKEjRp2jfV6iyMvactGbCdiQ6POPlBWwpL86EMxaYLKHOvLDSevEZf1MTsDsoc b/1L8mG4lgktN4eg5924S7PjQDgqMbyjsSioozZjfN/NeX4XR9+miyUbe/lyvU3uzMSOwYctYD g7c= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867486" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:28 +0800 IronPort-SDR: 1N1gy6M4UNWGHMRGUVt1s3XjPxCJhH9k89eiUZ4mK0IdQLaIdyk0gYqzJYpsWGfFTpJlFGwMML +BK161Vv9HlVRbN58W+gI7NVmVxRaHZn1H480Sf2XEYDwrpzir28/0iFokM/gR0GbydFq3sip0 Sna/CgOBIymR23VVzY9M9rgzhsVjx7HnNG4uIpJQ/5i34siKs3uNEpv+f6ZItG5ay14WLnK3TX nO6/0qiItmAO/3y+jdL/Fxon2MXtnAtRrZhEj31WB6i+VIge63Z5wqZnZOpJ9eHX6jmBZSq3+/ Bdi15QI53u5q2SVBf657uFmV Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:36 -0800 IronPort-SDR: IFjrgivLKDs+cCbvx/BWBuFplMxvaMR5lfXMflFfmyLvMa8El9KWo/fo9iEKMk+txjJrSc6/FP AgmxCi1v+v5qWbnzsvuNvbqj6QTaP8F6ytqAJSxj3BefxX4wqjbGZ9pjOgVgNE3IBUl3zCwaCK gmwYuZmiHbbvTfIAwf9Z6OFN0PgbyQb9PNBVXdJyOF5Vk83TfxrhAe1E1Pv0G8n/6wCji8qtrq n6QvyRzJjMR1tOvb63WCmU2nJsY9O8F2g2Mgvxhj/CAFNzD2Efv34bb89Ez+qVL9be0xk2Qx44 6LU= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:28 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 17/19] hw/riscv: microchip_pfsoc: Correct DDR memory map Date: Tue, 3 Nov 2020 07:21:48 -0800 Message-Id: <20201103152150.2677566-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng When system memory is larger than 1 GiB (high memory), PolarFire SoC maps it at address 0x10_0000_0000. Address 0xC000_0000 and above is aliased to the same 1 GiB low memory with different cache attributes. At present QEMU maps the system memory contiguously from 0x8000_0000. This corrects the wrong QEMU logic. Note address 0x14_0000_0000 is the alias to the high memory, and even physical memory is only 1 GiB, the HSS codes still tries to probe the high memory alias address. It seems there is no issue on the real hardware, so we will have to take that into the consideration in our emulation. Due to this, we we increase the default system memory size to 1537 MiB (the minimum required high memory size by HSS) so that user gets notified an error when less than 1537 MiB is specified. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 20201101170538.3732-1-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 5 ++- hw/riscv/microchip_pfsoc.c | 50 ++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index f34a6b3fd7..db77e9c84a 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -105,7 +105,10 @@ enum { MICROCHIP_PFSOC_ENVM_CFG, MICROCHIP_PFSOC_ENVM_DATA, MICROCHIP_PFSOC_IOSCB, - MICROCHIP_PFSOC_DRAM, + MICROCHIP_PFSOC_DRAM_LO, + MICROCHIP_PFSOC_DRAM_LO_ALIAS, + MICROCHIP_PFSOC_DRAM_HI, + MICROCHIP_PFSOC_DRAM_HI_ALIAS }; enum { diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 44a84732ac..96cb8b983a 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -121,7 +121,10 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 }, [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 }, [MICROCHIP_PFSOC_IOSCB] = { 0x30000000, 0x10000000 }, - [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_LO] = { 0x80000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_LO_ALIAS] = { 0xc0000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_HI] = { 0x1000000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_HI_ALIAS] = { 0x1400000000, 0x0 }, }; static void microchip_pfsoc_soc_instance_init(Object *obj) @@ -424,7 +427,11 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) const struct MemmapEntry *memmap = microchip_pfsoc_memmap; MicrochipIcicleKitState *s = MICROCHIP_ICICLE_KIT_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); + MemoryRegion *mem_low = g_new(MemoryRegion, 1); + MemoryRegion *mem_low_alias = g_new(MemoryRegion, 1); + MemoryRegion *mem_high = g_new(MemoryRegion, 1); + MemoryRegion *mem_high_alias = g_new(MemoryRegion, 1); + uint64_t mem_high_size; DriveInfo *dinfo = drive_get_next(IF_SD); /* Sanity check on RAM size */ @@ -441,10 +448,33 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* Register RAM */ - memory_region_init_ram(main_mem, NULL, "microchip.icicle.kit.ram", - machine->ram_size, &error_fatal); + memory_region_init_ram(mem_low, NULL, "microchip.icicle.kit.ram_low", + memmap[MICROCHIP_PFSOC_DRAM_LO].size, + &error_fatal); + memory_region_init_alias(mem_low_alias, NULL, + "microchip.icicle.kit.ram_low.alias", + mem_low, 0, + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].size); + memory_region_add_subregion(system_memory, + memmap[MICROCHIP_PFSOC_DRAM_LO].base, + mem_low); memory_region_add_subregion(system_memory, - memmap[MICROCHIP_PFSOC_DRAM].base, main_mem); + memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].base, + mem_low_alias); + + mem_high_size = machine->ram_size - 1 * GiB; + + memory_region_init_ram(mem_high, NULL, "microchip.icicle.kit.ram_high", + mem_high_size, &error_fatal); + memory_region_init_alias(mem_high_alias, NULL, + "microchip.icicle.kit.ram_high.alias", + mem_high, 0, mem_high_size); + memory_region_add_subregion(system_memory, + memmap[MICROCHIP_PFSOC_DRAM_HI].base, + mem_high); + memory_region_add_subregion(system_memory, + memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS].base, + mem_high_alias); /* Load the firmware */ riscv_find_and_load_firmware(machine, BIOS_FILENAME, RESET_VECTOR, NULL); @@ -470,7 +500,15 @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data) MICROCHIP_PFSOC_COMPUTE_CPU_COUNT; mc->min_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT + 1; mc->default_cpus = mc->min_cpus; - mc->default_ram_size = 1 * GiB; + + /* + * Map 513 MiB high memory, the mimimum required high memory size, because + * HSS will do memory test against the high memory address range regardless + * of physical memory installed. + * + * See memory_tests() in mss_ddr.c in the HSS source code. + */ + mc->default_ram_size = 1537 * MiB; } static const TypeInfo microchip_icicle_kit_machine_typeinfo = { From patchwork Tue Nov 3 15:21:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2DBF697 for ; Tue, 3 Nov 2020 16:05:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C0392236F for ; Tue, 3 Nov 2020 16:05:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="gdDejzMw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C0392236F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyo5-0000As-AI for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 11:05:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKN-0002UH-SE for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:33 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKD-0001FT-GW for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417662; x=1635953662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gfyFOauU6Gej1Dn0hI4aczlzFeYXPNOkCE53IqC40bY=; b=gdDejzMwv3YPaFgsTgYX1WaCX/J8xoFvgaSIroRCs7qQGXx55GJGJ9SW iKiR4wCiViII5KjWzYuAKcWDOcoo2h+Yhf9aVF9phj20GpgBmb+ERDM8D woDBc3IU661hLYEXG1sOoUxApeAYh0RIcV4xUGLUERqLyxNctxbeq7GGE oCIvL2dxugoogzoC2Y/FmBjluPQS7T7HilKy+yPUl8KKc8wUD14xl1avf u6ItYNU/WF9rGFGvf/7TNieVc57I5Obfi7yjqQ/rcviXiUvZj8FsJitqB D0kpHc1wYI/vKKxGHnwPDdjehfkMgegp0SrkG2mPGfVrln2lXosegbN85 Q==; IronPort-SDR: UXa88enkiHN9SWtIIH8g+bUc7t6Km8EmeA76DFpz0yXFypHrCEo4iknLEwSUPhFWDp9OIXruZW /Bbg/0Jni/7+nTIVbi1bpNpamYSVRtr8LsIPQqBxY9m+JwUpHb83rotK9aee2Yjif/YXwFqXGp XThpx985tSl4GIz4WSFbeBy1gwl5t5QLYHB+alS4cLMJ9jieNH8ViXse+HSId7NhqtForIovTW cqkevWEYThRrK5B0V4w744udIKvHfj/otI8roWvQcEMK6ghzV7vYXKVo1wug7eKlewc0ga/WYE Orw= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867488" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:28 +0800 IronPort-SDR: 75I30xPdcWm6L+50XsVplSRYW86pD+PduwmJ4pbHPCN/FV+/mj0fN7CD8T8uATFRURJjhBWwyO 2X7+iG7rKcqQZFeD+HLGi9soAkPJ9hOhhu7oq3ficq/1+G5kNPzOq3OQhs/JfZGrux5N3ikXr5 Dj8wqCIsmSTS67mXmkrVTiee4zX1oA8EoTufdKQ9+y8Ibf0n3BfLS+ObpVtA8ZYLjS0ATKvidJ G8ap6Ylug84sHCuWfnkW5/Qdpgf2Q3Cu5x/tW6rrAJai9YId8VG6G91UxMQZjbLodeoEkxyIJ2 S26CcqjvVUJfWYBGKtdCxRqI Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:37 -0800 IronPort-SDR: mnZtCmTsqEFzU18mCjIXP9pXVXu33b4ClzdI/2A9WDlD8AqjD+IXsNMm1wptEIKnKJw6hPwAGB C6jl3VkJJXV7+yMoB/tXVN5RMA47YIf3gwAmN9ffvp//QA86kz/u9FJv2RPxdkddjMnXtN2JTr lvizXMaitmanU3aSeKvxWbVmHV0bz9nDNmOqyRuHDPoeExBt5i7YTiIBQKL426fIGiVwhpCkh2 O65Z6E/Zm7VN2Q5c7holByzfrq7zVzy1+e0nWJCWA99zbrvJjklbYJZV8eOT5DIqOgPcYJmaNb oag= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:29 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 18/19] hw/riscv: microchip_pfsoc: Hook the I2C1 controller Date: Tue, 3 Nov 2020 07:21:49 -0800 Message-Id: <20201103152150.2677566-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: alistair23@gmail.com, Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The latest SD card image [1] released by Microchip ships a Linux kernel with built-in PolarFire SoC I2C driver support. The device tree file includes the description for the I2C1 node hence kernel tries to probe the I2C1 device during boot. It is enough to create an unimplemented device for I2C1 to allow the kernel to continue booting to the shell. [1] ftp://ftpsoc.microsemi.com/outgoing/core-image-minimal-dev-icicle-kit-es-sd-20201009141623.rootfs.wic.gz Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1603863010-15807-11-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 1 + hw/riscv/microchip_pfsoc.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index db77e9c84a..51d44637db 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -97,6 +97,7 @@ enum { MICROCHIP_PFSOC_MMUART2, MICROCHIP_PFSOC_MMUART3, MICROCHIP_PFSOC_MMUART4, + MICROCHIP_PFSOC_I2C1, MICROCHIP_PFSOC_GEM0, MICROCHIP_PFSOC_GEM1, MICROCHIP_PFSOC_GPIO0, diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 96cb8b983a..37ac46a1af 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -113,6 +113,7 @@ static const struct MemmapEntry { [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 }, [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 }, [MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 }, + [MICROCHIP_PFSOC_I2C1] = { 0x2010b000, 0x1000 }, [MICROCHIP_PFSOC_GEM0] = { 0x20110000, 0x2000 }, [MICROCHIP_PFSOC_GEM1] = { 0x20112000, 0x2000 }, [MICROCHIP_PFSOC_GPIO0] = { 0x20120000, 0x1000 }, @@ -343,6 +344,11 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART4_IRQ), serial_hd(4)); + /* I2C1 */ + create_unimplemented_device("microchip.pfsoc.i2c1", + memmap[MICROCHIP_PFSOC_I2C1].base, + memmap[MICROCHIP_PFSOC_I2C1].size); + /* GEMs */ nd = &nd_table[0]; From patchwork Tue Nov 3 15:21:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11878211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBF8D92A for ; Tue, 3 Nov 2020 15:48:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51AF32071E for ; Tue, 3 Nov 2020 15:48:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="B/6JgM/z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51AF32071E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyXl-0005mZ-6J for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Nov 2020 10:48:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKT-0002W8-NX for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:39 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:15005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyKR-0001Fa-9a for qemu-devel@nongnu.org; Tue, 03 Nov 2020 10:34:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1604417675; x=1635953675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r57vaix6jaMv33EUrj+BDv2Ap6h5uq3sW8MQsYHDDPE=; b=B/6JgM/zkDiBCPHPmmx4FXs+K5qhEsALIwnAHTa+jzDEy6eU/ZBipX1S tybCkzwHotFkRttEMEOpEaNsRO3GPZ7F84ECvhDh9JaLx3TtB0x5LqPIF PJC7dmeeDOeOW2fO8nQEo+lirCcQATTWFRIZ8kREagblca+xQvmgGcfrR 6Y9Bqq8CBirI6iZTK0ZV0g8QUeCsIMem+ajaoQkXq5UhWTIY22DasUpdR i4FfXGjK5MBfj9Pcykn/lU2w0hzWFxjL6/sgkzCswKFZMyLkJ2RPwLJ9B n167weuPpQ3TBj+33+ijL2nc+Fymh3Om1mTTYjQC9liBGYG+OIDqRkbwx w==; IronPort-SDR: 6ADO8kF3uFxfIHhPd7uj5WWYbeSeVC9ifitvUrbEDZHMEWop3tboJuqd2twm1sIqoHdmoswLsj tlnKyE+eaUVR0SQdVgU/I7FavgnwwqJLn4sgRdGr4GaYB34xH/M3FT6XjSyecKvCoZl79A5M3f yJoV3kpHuAKCVloVfCOFn03duisubDMsgs4OoVQ4LojeHxkXDzPWKY0uRe0JJJyeFvbUH/6YYu pLb787v+7p4r33cbaQvP2D/X0vbIwm+fPqzKoD1XqtZIKE3z0l5sfGokMn45DcI/V4/aeyhsJT F/M= X-IronPort-AV: E=Sophos;i="5.77,448,1596470400"; d="scan'208";a="152867490" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Nov 2020 23:33:29 +0800 IronPort-SDR: fvYEqC0IChBRAmusUOwgdsGZbnT2UbHR4qFC5rpGJQ2sqicmufIcQvgw8VY8QkkuBdD1lxTxo3 7enSktmv3mAU87spuL0GfepWAQD9f27NllY1F1r0H3SKwPYgzMALuD5G8V4lO4BDxIvzFITXy9 HZeI7f/FRN6Whl/Ltv1kiV8gPT4x3iyN1WKI/bO7BO4+i5iu+xRzT7qS1H5bPYoKsN+b1oqVmA e2E6zYEajFobqw2zjO15mYi/e5bFnZIWyDr8TPVxEXa7COgLLwFKEWe/Lg1TEXGkYhjRJYbIYQ goXuwv4RfZxJMPALELWSUSjN Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 07:19:37 -0800 IronPort-SDR: Pjf9/EEDsvH8CX4x0ID5x+NLL8g1ijHk3jQ32f+KAbfll3sJ25muznBSLJ0IFf11dEz2nim02n EVJPMNKPHWrLMHTajg8iUogILVajQiahvLELjrj4QYsApQUnb2u0WGvVgQ9dqTTSCjAosMd0DU 0d1sDqr9z8uSu+jwNfZx30v5ooH9AtMkJW7IjuTMACmgWO/DygTIRnRF6HCyXDXWkxxASSbrEe MCeOuKcQcfy0hj+X7llnqNnl5Dxoxz+xfNM6jiZgrrmlcUNQ0U+zPcrAwAN2LALBwVBEfpq14b knc= WDCIronportException: Internal Received: from usa003000.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.60.113]) by uls-op-cesaip01.wdc.com with ESMTP; 03 Nov 2020 07:33:29 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL v2 19/19] target/riscv/csr.c : add space before the open parenthesis '(' Date: Tue, 3 Nov 2020 07:21:50 -0800 Message-Id: <20201103152150.2677566-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103152150.2677566-1-alistair.francis@wdc.com> References: <20201103152150.2677566-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=569a91e0c=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 10:33:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: Bin Meng , Alistair Francis , Euler Robot , alistair23@gmail.com, Xinhao Zhang , Kai Deng Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xinhao Zhang Fix code style. Space required before the open parenthesis '('. Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Reported-by: Euler Robot Reviewed-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 20201030004815.4172849-1-zhangxinhao1@huawei.com Signed-off-by: Alistair Francis --- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e33f6cdc11..93263f8e06 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -882,7 +882,7 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { return -RISCV_EXCP_ILLEGAL_INST; } else { - if((val ^ env->satp) & SATP_ASID) { + if ((val ^ env->satp) & SATP_ASID) { tlb_flush(env_cpu(env)); } env->satp = val;