From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586604; cv=none; d=zohomail.com; s=zohoarc; b=O086NM51FGEMX4zdf5ZQp7Tulvo9/kqQ04i19ywLiPxNcYqogdry5UbrNSJ+I8P+E2R4aL75MHEB4Ll5T6b7/Ta4/nSIP4L56HchdFGEwDRgv7QbZ8Jw0KE49fmmNhxGgEbdwMJDOva68rkG6aQ2AWQj1impVhQqi6BlsC5rNZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586604; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0q1KFslkW32iZWog5jcD9NEq5N7lNtXEcNwfyJ76JQs=; b=IwPE78++D1h4dstklFF592M5fQMB+TCcL843PwIY1uNhQumD/kqntn+3rEzRrWhM/OEMnOpAZ4ireI2xkqSQwbwFHLOMQLaYxFy2V/7R2iuo7lBQ2RT0LWIM4Z3Zx0XqNgD7+lPWSIkzHal0fxfpy/hncylOEB17VC1bw2/lIL8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586604715999.116921725432; Fri, 19 Jun 2020 10:10:04 -0700 (PDT) Received: from localhost ([::1]:37420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKWh-0005Mi-Ag for importer@patchew.org; Fri, 19 Jun 2020 13:10:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUC-0000dI-2h for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:28 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19131) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKU9-0004PZ-3V for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:27 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:21 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:58 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586445; x=1624122445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRlfmAxnNO+uf1echkK6NudzAPtFUGkmvCQ9SmWv+Zg=; b=Mxw6YUoxCzsUT30KqqdLF8NFP282/TfyNpzmldDIjzc71FbdE/l+AGfu /OGjSzOO99ZX4HOY1jwe7XMSUiGxMki89Psg7uBj4MwtiatCPj9Va5H0Z IqZB8sVPz5KpJkHap0/c+IjVskviBa64GgEFuBfTld8TDLIorpOaCkJsn HknK8kT/NZ8qrzfzOZNbggER41i/RpNCxjfAh0N9rX+2PfyfseCTKtWq+ 47cIrhHr/f6ldmuPwS6A1W8VEZSXGUV4Ky1eFipPDAW6veFU2XDkd17pw FTIqDS45RGInFBKhQ9acmcr1JD+/qR6Iu5LtN7tF/9roIf+R/R+xpdJRm g==; IronPort-SDR: zvPQ5lQqkE9Jp5JINanqI+xo/HUFMIs7K+tY9o3GT72OtI3b191iMRKxYOKJzIBB4uPIEjCLNB J6jNTT2LRTwzx29wCVG6rTtLCgCt0mVtjc3Rm1vwq6a8LaoWKpaJzL1RNQWB08YJhPyGC4JvHT ZHi8nC1APm9q04sT4lfKiEPg08/qL7+djzZI4J3ZGbkHR676BHSeIzWqNPLA0rzHNsybGYLeml LzIx2kZVhkN9tFp1w+3jJ10SDMvVYsNSutuSM7lJIoeWiQ2W14Sgvob8s90YBE/8rk8F6Gf1ZO VQc= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763295" IronPort-SDR: 36Yx6u1MFk392HGrnJdJUt2DMR7n5TejB6KVLeXb8DUjBZxqSLYqtzACjkBFC3wrLJn0IyRVNU 2m+Qo3olGxu68tbDHiNmjRqvGpdtzZzPo= IronPort-SDR: 2KntkliM+aXblpaEUylXwA5cqhqlUeCI/qc8K2/Ppi2FYGxsdHtQqY5ejIcwm/pdeSxseFsUiE RaRzKM37+5AA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 01/32] riscv: Add helper to make NaN-boxing for FP register Date: Fri, 19 Jun 2020 09:57:46 -0700 Message-Id: <20200619165817.4144200-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, Richard Henderson , Alistair Francis , Ian Jiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ian Jiang The function that makes NaN-boxing when a 32-bit value is assigned to a 64-bit FP register is split out to a helper gen_nanbox_fpr(). Then it is applied in translating of the FLW instruction. Signed-off-by: Ian Jiang Message-Id: <20200128003707.17028-1-ianjiang.ict@gmail.com> Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvf.inc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_tr= ans/trans_rvf.inc.c index e23cd639a6..3bfd8881e7 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -23,6 +23,20 @@ return false; \ } while (0) =20 +/* + * RISC-V requires NaN-boxing of narrower width floating + * point values. This applies when a 32-bit value is + * assigned to a 64-bit FP register. Thus this does not + * apply when the RVD extension is not present. + */ +static void gen_nanbox_fpr(DisasContext *ctx, int regno) +{ + if (has_ext(ctx, RVD)) { + tcg_gen_ori_i64(cpu_fpr[regno], cpu_fpr[regno], + MAKE_64BIT_MASK(32, 32)); + } +} + static bool trans_flw(DisasContext *ctx, arg_flw *a) { TCGv t0 =3D tcg_temp_new(); @@ -32,8 +46,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) tcg_gen_addi_tl(t0, t0, a->imm); =20 tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); - /* RISC-V requires NaN-boxing of narrower width floating point values = */ - tcg_gen_ori_i64(cpu_fpr[a->rd], cpu_fpr[a->rd], 0xffffffff00000000ULL); + gen_nanbox_fpr(ctx, a->rd); =20 tcg_temp_free(t0); mark_fs_dirty(ctx); --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586614; cv=none; d=zohomail.com; s=zohoarc; b=hYoP5XHXx37a2x9J/aMEoaQpRQQUNbzQhS7Ft7QbvzxjPpaJkOXeG5optfyKr/QGZuW7AN008iCmSWBdSu/JsRsRYRfmv2T9rZVyx4dsaiItQWQpThcbRVEik4OVQwTpM9SqD68kjkqacudlT5WKCzjwDwDAyI/+9DnJ2qVXjTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586614; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mHaifW2tCOzT7GIgGbafG1CXeLU+mtkfluaKtIpaGf4=; b=LeK3uaLRLybpDjhRChv+QndsP5SVFswm8dP4ukyhwXZvE9ajnMCDQ/D6/lM6VeKSOtsjjIOl7T5A1Apmnjm7WFQRDu1JwjZzKwYuY9I0O+wMF4+SlRCNrkc0XQDlN9d+mzGQOvQV/z2hqNYMUU7p/aZ6/dPw93uZLW8vsiXPrv0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159258661426066.66883642795119; Fri, 19 Jun 2020 10:10:14 -0700 (PDT) Received: from localhost ([::1]:37920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKWp-0005ak-Th for importer@patchew.org; Fri, 19 Jun 2020 13:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUC-0000dg-AB for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:28 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKU9-0004Pg-Er for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:28 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:21 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:58 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586445; x=1624122445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XXem7lAIy5JLne6cVjjQsO7guKTzZZhyfFB1ov8zLOg=; b=fDJBD3Lb1Id4RjgL1jb3NMfvkQQChnqvtRDkIgZ0wYCC1Lprzh+zKudw MKSEQiY+MKGdCdoS1xC3bF6baikh2LUJ15xKJwXq/8G9pctQf7hEOOvXM w/XQHZMSrKbMxM9Xb6JDDSXGgiRERg8+j1M7M0+G/GfT+Zd6a1pbuFBYB rrgl+IAe10GdUA0RYxE81khI6MGyHYpiemNqck8iCzDtmlMjJ30cBZ+yh Lc7JnLG8DiWx6K+CmGiikCjoA4Jn4k0m7GZnYUFoZPc4DQUKPoycCyGqf 8O4nR9VENED1Ylv/NvTJrHx4mOkrmA35mpaLdRXt6TkhB4EnP6xhA/USj Q==; IronPort-SDR: PsBj6//sU9a46ErTf0rrGd6tuHngG6nN938ms+NykNGIlUhgP8bFquJ7r6k3VYZPbDzdDK/wQB YZ2z5ojysGICa+f+bp0EsffI/pVQNn7rxR0YMaQt0wBkElfyk3nFFdrKk6lmwMVjgn8pOvhom5 6HhOODZGoNl9t5FPc5hD+UKxZdSZD+3MgwwpE0H4u6jkfeecUnf93jfav5VUTQ0s3Ij7GPF3Kc s/ExnknwhapLj06ARUszLVbdysOdpqeePK47DMdzLZ0gVwZFrGtHDwFbHr+lmAt73Msp6gckVK VOs= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763300" IronPort-SDR: +ynqII+RQpn9KyggGqUbxBy2CO+IDhNOIynbfEXfRH7/djzP8R8Ri2cKJogDnOrmVpZ3kd86ze k8GmIXtgdqJQAiTI8AsKWncMbz2tmives= IronPort-SDR: T6GGQ2U2sA+ZAKGSh3Dynnzy1N78sGu0jSHtkZWP/EqF5CE5OXgwscwW7AWGy0erN+ieDxZ025 bwvZuZmtCz0Q== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 02/32] sifive_e: Support the revB machine Date: Fri, 19 Jun 2020 09:57:47 -0700 Message-Id: <20200619165817.4144200-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_e.h | 1 + hw/riscv/sifive_e.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h index d386ea9223..637414130b 100644 --- a/include/hw/riscv/sifive_e.h +++ b/include/hw/riscv/sifive_e.h @@ -45,6 +45,7 @@ typedef struct SiFiveEState { =20 /*< public >*/ SiFiveESoCState soc; + bool revb; } SiFiveEState; =20 #define TYPE_RISCV_E_MACHINE MACHINE_TYPE_NAME("sifive_e") diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 1c17d02cf0..36486b72d2 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -95,10 +95,14 @@ static void riscv_sifive_e_init(MachineState *machine) memmap[SIFIVE_E_DTIM].base, main_mem); =20 /* Mask ROM reset vector */ - uint32_t reset_vec[2] =3D { - 0x204002b7, /* 0x1000: lui t0,0x20400 */ - 0x00028067, /* 0x1004: jr t0 */ - }; + uint32_t reset_vec[2]; + + if (s->revb) { + reset_vec[0] =3D 0x200102b7; /* 0x1000: lui t0,0x20010 = */ + } else { + reset_vec[0] =3D 0x204002b7; /* 0x1000: lui t0,0x20400 = */ + } + reset_vec[1] =3D 0x00028067; /* 0x1004: jr t0 */ =20 /* copy in the reset vector in little_endian byte order */ for (i =3D 0; i < sizeof(reset_vec) >> 2; i++) { @@ -112,8 +116,30 @@ static void riscv_sifive_e_init(MachineState *machine) } } =20 +static bool sifive_e_machine_get_revb(Object *obj, Error **errp) +{ + SiFiveEState *s =3D RISCV_E_MACHINE(obj); + + return s->revb; +} + +static void sifive_e_machine_set_revb(Object *obj, bool value, Error **err= p) +{ + SiFiveEState *s =3D RISCV_E_MACHINE(obj); + + s->revb =3D value; +} + static void sifive_e_machine_instance_init(Object *obj) { + SiFiveEState *s =3D RISCV_E_MACHINE(obj); + + s->revb =3D false; + object_property_add_bool(obj, "revb", sifive_e_machine_get_revb, + sifive_e_machine_set_revb); + object_property_set_description(obj, "revb", + "Set on to tell QEMU that it should mo= del " + "the revB HiFive1 board"); } =20 static void sifive_e_machine_class_init(ObjectClass *oc, void *data) --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586608; cv=none; d=zohomail.com; s=zohoarc; b=Umjut5HG4XbzOY6WoOeUAtpEx5nafU4MQoVUKABz0GSlo2VmLg8wK1fIgLaBXCTwMYRoJN/2HLXUUnHmnGL7bFxawwpHR2drEo9Zfhfar5p/wmJphfwfTdhOcav3yw7FdZnNdwHH53lDhHqPsCOWCeke0gY4ZgDyFcSgzuB7y0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586608; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a/lYPit/g39BaAdPfj3JKVgEM7xpI3EeRFuRaLW2rJ0=; b=IHqrdlaVodBvI4niq+GAoSntviFyueviXykKhp8bkSIca8PRz5pHZ0hBAlhap53fHX5F++gl702JEXwInDSCesJD4lCzkwIXhsFHtvLhRBfXQt0gFvJTDK0qWqxCE7KkP+Twgr87UBJyeNTgiZ6ei1mYS6TuCr8lr+sIGKRmbVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586608075932.8294984852271; Fri, 19 Jun 2020 10:10:08 -0700 (PDT) Received: from localhost ([::1]:37722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKWk-0005Vw-P6 for importer@patchew.org; Fri, 19 Jun 2020 13:10:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUD-0000fi-E2 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUB-0004PR-9q for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:21 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:59 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586447; x=1624122447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VU9o6OYV0MkgJqJ+P7yL/zRcCvBETb4yUFY3HT80i6k=; b=EX1S/uCarhHy1ygo45RbSwBiIAAy4qSdQm4kLQ8WjTZtlsfZHHc2gqOp 3EAzZHuDxBALQ6YUU7+8TaiYXRaCmkHvswSM3ix+OTxpP41oGpOaX3DYq S6ZndqO2nS9sVKaEqppxaDOdzo75FXGd4IXEh/i1ZnMmBfD+LN+gl3lvv Eqt6JWzMj4DpbKEQsLC8pm/0vl+m+Fz3TLlqRWI/EoU4y96PbYLUC1FK8 TzJ20nUg8DqPPd74uHs43vdzSFIPxlcGzKz4jTmV4nEUPUqeU2g51+BYZ Zosr6tntqIiRcY5fzCNWLhQCDRfOT6l9ZPAAKJ1hvlOu8JWJ2yXetVUVF Q==; IronPort-SDR: l71BXK/rnGw/I1KLwHcNG78hP3tlUE3Q+mNTFcBbRFNai6aK8LUAnYltQZKOXunD2fMG+YLZwD 5ETIpKqozFYcnlGmuuXTxfFkQX5xpWuw5B0Upi6qfKmjv0p+D40YkBw8W/ffvclZY/bpeYNfGK SUxBoPaUSaSyjNI4XFjUNOLcwfuR6uDWBCBti0yqVhzsJmkEXN+smsXWsjsSswXJSSbipCwep5 A8TzZTWpNuXPL2MMtw1OjlZ2TUE4EoMn9NuRgTFbxrr9CtTO/nXUJN9X5AiIheWL5tMVLOh5l5 eOA= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763304" IronPort-SDR: CamgmRcIaeXfCpsTwDgWSyXeuDoJBVRpUQ99uBm0btUq//37G8cRNxO31ugBeJ0+762U4kYHXL Me7OnNxG12Sh/Jwov3Vg/5/lk4ULgk0ls= IronPort-SDR: NslU3WMGBYWaUDXrA6sWAmVPA8sz07BriKgxT+snsoYTvZrWMupanquYGHt5+Z3+Z5JDa3oXWY pZ6AawrhIA4A== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 03/32] riscv: Generalize CPU init routine for the base CPU Date: Fri, 19 Jun 2020 09:57:48 -0700 Message-Id: <20200619165817.4144200-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng There is no need to have two functions that have exactly the same codes for 32-bit and 64-bit base CPUs. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591837729-27486-1-git-send-email-bmeng.cn@gmail.com Message-Id: <1591837729-27486-1-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3a6d202d03..81cdea8680 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -126,9 +126,7 @@ static void riscv_any_cpu_init(Object *obj) set_resetvec(env, DEFAULT_RSTVEC); } =20 -#if defined(TARGET_RISCV32) - -static void riscv_base32_cpu_init(Object *obj) +static void riscv_base_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; /* We set this in the realise function */ @@ -136,6 +134,8 @@ static void riscv_base32_cpu_init(Object *obj) set_resetvec(env, DEFAULT_RSTVEC); } =20 +#if defined(TARGET_RISCV32) + static void rv32gcsu_priv1_10_0_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -173,14 +173,6 @@ static void rv32imafcu_nommu_cpu_init(Object *obj) =20 #elif defined(TARGET_RISCV64) =20 -static void riscv_base64_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - /* We set this in the realise function */ - set_misa(env, 0); - set_resetvec(env, DEFAULT_RSTVEC); -} - static void rv64gcsu_priv1_10_0_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -603,13 +595,13 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { }, DEFINE_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), #if defined(TARGET_RISCV32) - DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base32_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32imcu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rv32imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32imafcu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rv32gcsu_priv1_10_0_cpu_in= it), #elif defined(TARGET_RISCV64) - DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base64_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rv64gcsu_priv1_10_0_cpu_in= it), #endif --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586517; cv=none; d=zohomail.com; s=zohoarc; b=i5N7EpZ6q2KabhpcoFLSnGBYQRIjWfuVjihipUPFZNrItAVVaOAM//TnHn4JL+3yuEWbgcjP7u0LbYTHmtsU85f0ilxTdgN/7gQOgqwNPEd3oWU5LptVOhB9VZ2dRIZY2d5jT8Ew39SL5bpTx9Erov4YoqUuEIo4ZPeqpZ+AvCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586517; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fAeweTSIqw667tumyzLx20aw43mQKLMVkXel1q8fg+M=; b=d1sWFSBh6ACyQnNyLlFEcei3iVCZWtKeRQ4VgpVPFlnRh8of3E1Sa+6j4nAXhAyVzNZv7SFjsnpiW0/31mqf43LOlpnYJwXkAIq7wxYqkAQL6XWW4B7OGAuU8Tx5TvNFpmtmg+nspw5bHMEExrgy37Mk5T30nAgsQ3JEvlVzYfs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586517522735.1564424557866; Fri, 19 Jun 2020 10:08:37 -0700 (PDT) Received: from localhost ([::1]:58630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKVI-0002Iz-Ak for importer@patchew.org; Fri, 19 Jun 2020 13:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0000hd-Sl for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:30 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19131) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUC-0004PZ-AX for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:30 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:22 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:59 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586448; x=1624122448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZQTwToslAoo6RGSrCI1CsH1WLRCehMn1IkQjkbVRhY=; b=i/Gd9g8c4lahAuWieLBDIWlL03rvKfuFq4t7MjN+MoNsGLGSJqKlaodH S9q+ySQ4s14pRd80llBJ/WLoIws9XukiK9DGN9mSUSJuSL5Yw92i/djVN qfffST47a0Hnuk8QSIqeswl4aS7bO9dVesxcmpz/pqtsydF97qgTQKrx8 0eVHO35ak8bB+Uf04+j5GDpvHIRZYDiYNYlbMyeQ+bVTgIm4HW3IQM1ts yeD/OT/59bdmgqEWpIElELB5CKA3b1lGMsamCM7D2XjVGCJQ8Kwi3DS+R 8EqEsFsFGZDtdf92nkL+z6qyU5h8w5tdCa7bkR54q/y1FH64cShy/33ry A==; IronPort-SDR: aLspBdsesnZc9rLNcYQ7OKvQg+wi9uXd16GtbWC01/iLWReWNwrQuzd9b2H0xsHXlPfOVK1yKJ cuyqAlbJsmcaHGrOYN5SzUrkVUSwyt8S5GXrPB8NLPm0UQCS1G2KnPj7fHQOidtPurUN4BGXrI d+NtkMJdqBuQosp6ne2yppMARKmmIJ030s8GhbbriTLjJHHU80o8Cd5kHeGrBGWbQ+J9SuCFiB 7sHbUm0ocrfakZECWypM7FoxTTRDusmLZag/ex9WWbOnMEPJ1QmKSklfdwAES2UuQQQ2ET3+ly g7Y= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763305" IronPort-SDR: UjaGOvOP5AfCZ52ITyiowKKFFenlY+Jkq+t9GpRpIEORX8VtPYdwjHn/zfsQQOX4D64CLjgi3c xMpKK5fI4Gw4U1/evwdEW5Hv5oYXBF26s= IronPort-SDR: Ng+q+TvM15u7FZa1Q4jh4oUDNuT9rV6JmqcnHVj0assR4UmGvOjkiAz1KeF1VypWFEmUS/3q/7 CCRGvXjwCckA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 04/32] riscv: Generalize CPU init routine for the gcsu CPU Date: Fri, 19 Jun 2020 09:57:49 -0700 Message-Id: <20200619165817.4144200-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng There is no need to have two functions that have almost the same codes for 32-bit and 64-bit gcsu CPUs. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <1591837729-27486-2-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 81cdea8680..437e141ef2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -134,16 +134,16 @@ static void riscv_base_cpu_init(Object *obj) set_resetvec(env, DEFAULT_RSTVEC); } =20 -#if defined(TARGET_RISCV32) - -static void rv32gcsu_priv1_10_0_cpu_init(Object *obj) +static void rvxx_gcsu_priv1_10_0_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); + set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); set_resetvec(env, DEFAULT_RSTVEC); } =20 +#if defined(TARGET_RISCV32) + static void rv32imcu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -173,14 +173,6 @@ static void rv32imafcu_nommu_cpu_init(Object *obj) =20 #elif defined(TARGET_RISCV64) =20 -static void rv64gcsu_priv1_10_0_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); - set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, DEFAULT_RSTVEC); -} - static void rv64imacu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; @@ -599,11 +591,11 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32imcu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rv32imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32imafcu_nommu_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rv32gcsu_priv1_10_0_cpu_in= it), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_gcsu_priv1_10_0_cpu_i= nit), #elif defined(TARGET_RISCV64) DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64imacu_nommu_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rv64gcsu_priv1_10_0_cpu_in= it), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rvxx_gcsu_priv1_10_0_cpu_i= nit), #endif }; =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586998; cv=none; d=zohomail.com; s=zohoarc; b=BVzL0EH0lLOjxQzuWs2JH6lKGGyaqpa11L/dyC03TB8owJ6aGq3KcYqNGtAUiusCH4XaLQtzAXWyilY25PNbYP25rnnDhi06Y3fAQCqdrDWUm2Hg8col2JIvY3eHHdXX0ZSszR3bKUIZxuimXkPdqfEaN9jS001lNC6kYM2tR04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586998; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+2ZjNUBY7cXe112LFV7gUWPg6XUj+mItwpgK14o3p1s=; b=hBpBnsmoAINn0PpyIEuAA/vt/2GIsJvEccQEZvuz8SP2tCODRUyd8XmCFdx7GJv8h3B1mQUL1gIu5pGCMSqEYW/TdS72h/ir1w60oclY5IgspFy9uPnlDVzf3/1TAx4bunfAIb2FnjHSUL6ccS3Pijg+qteyBnlq0F1PMR6Fv6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586998429798.5582981143857; Fri, 19 Jun 2020 10:16:38 -0700 (PDT) Received: from localhost ([::1]:38264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKd3-00053r-1L for importer@patchew.org; Fri, 19 Jun 2020 13:16:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0000hD-Gd for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:30 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUC-0004Pg-LK for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:30 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:22 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:59 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586448; x=1624122448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oVrn5w9HfRb0TvrN5CP3m58pdTdH4CK0+0WfxcCouCQ=; b=feQ0hQs6tQUwvh6IvKh6CC4w4fGhVVQ6u2IaDUv6T0VfDD7rVmO/h10u bPJvKdOboeMbpQ1AQIQc4JIngNz4mtFySupl8J2JSveW3b/jt5gSGzXfC WUjYaRTApwro3qzzKyGQxSwG4A5tcaGJcshkUpbxS7s/IVUK/6BYWlmf0 gfHOmVVb9cMLYHzv4AoCNh8El3KXQ5pumlzDaGhuW6iqtkvElPzkzmYq4 ZmS/XdRBS7jOrl5ihPgSrkNOI8Of9b2atpKYyX4EoenSMYMtOUI/sfoQq E1K3Z6W48xSMGyCwZpugWuJOkwVloPtx4rgzHEWgtrhvQUZPVBKLXLCAV g==; IronPort-SDR: hax4ubTb6bcg8HwMqaP/4iq9pBld8qm9gUaVpbsoR0abkBiJqQ1Kq+flTCf20b4BLwRbRiN1Ef DT7n/KYKMZjUxfnD2+SZ9qhing00oGdBiCMiTr8DkAuxdnoAZNmJuAX0wWL8f7/ClA3uDfPvwI /xlf2Z5+vWWD43XbVfeUZS2+l1TrBrLKawYjUX97X8gPrP32AvVA5LvRV6RA3GAuOZF1/PxSxE 087knH7YyqvDQ9llHFYhw6XJrYhglnKGJUIdHrGSkAjxHFGzwYnKPGCWe4okQKoUzJFC+/GNnf b3Q= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763311" IronPort-SDR: FFVX2v67vxl4NozG2NFAAzWBO48v6mJY1EI9kXqfSI+si5EJ/gnXgAvhII6fEFyOCY80dhwhcw xQZTixLM1ZI02gqRzSTD8zgGm8LqB+byc= IronPort-SDR: vejzWv0e42uTZaiMvqBN8CU5X9FrMFWNU643yjOYl2eQGtmQ8p8L+XeOB8HhrKo6VLlrndw6QA 6I9VBXtVfM6w== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 05/32] riscv: Generalize CPU init routine for the imacu CPU Date: Fri, 19 Jun 2020 09:57:50 -0700 Message-Id: <20200619165817.4144200-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng There is no need to have two functions that have almost the same codes for 32-bit and 64-bit imacu CPUs. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <1591837729-27486-3-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 437e141ef2..35a8c7853b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -142,23 +142,23 @@ static void rvxx_gcsu_priv1_10_0_cpu_init(Object *obj) set_resetvec(env, DEFAULT_RSTVEC); } =20 -#if defined(TARGET_RISCV32) - -static void rv32imcu_nommu_cpu_init(Object *obj) +static void rvxx_imacu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVC | RVU); + set_misa(env, RVXLEN | RVI | RVM | RVA | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, 0x8090); + set_resetvec(env, DEFAULT_RSTVEC); qdev_prop_set_bit(DEVICE(obj), "mmu", false); } =20 -static void rv32imacu_nommu_cpu_init(Object *obj) +#if defined(TARGET_RISCV32) + +static void rv32imcu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVA | RVC | RVU); + set_misa(env, RV32 | RVI | RVM | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, DEFAULT_RSTVEC); + set_resetvec(env, 0x8090); qdev_prop_set_bit(DEVICE(obj), "mmu", false); } =20 @@ -171,17 +171,6 @@ static void rv32imafcu_nommu_cpu_init(Object *obj) qdev_prop_set_bit(DEVICE(obj), "mmu", false); } =20 -#elif defined(TARGET_RISCV64) - -static void rv64imacu_nommu_cpu_init(Object *obj) -{ - CPURISCVState *env =3D &RISCV_CPU(obj)->env; - set_misa(env, RV64 | RVI | RVM | RVA | RVC | RVU); - set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, DEFAULT_RSTVEC); - qdev_prop_set_bit(DEVICE(obj), "mmu", false); -} - #endif =20 static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model) @@ -589,12 +578,12 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #if defined(TARGET_RISCV32) DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32imcu_nommu_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rv32imacu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rvxx_imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32imafcu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_gcsu_priv1_10_0_cpu_i= nit), #elif defined(TARGET_RISCV64) DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64imacu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rvxx_imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rvxx_gcsu_priv1_10_0_cpu_i= nit), #endif }; --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587105; cv=none; d=zohomail.com; s=zohoarc; b=MVnpa4H+AJZ5ZoaGdoBUzbee7OutFbAs6JaAasXQFCRc5Kc93P77sJCydbUsV432GQFptUjx1iupbgJ3CFiEwdYuG6Ljerk0HB6iCVZZHad2/MpBlY8WX5eQTz+u+rGLNbwlyiR+iEbHQkZRhTG0XI/ZivEfCfOp4aZsvYmK7lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587105; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+9x/RNcUh/ycQL1IWr6VpLQdX3dI4VxfR3W0ZgG/B20=; b=bBVqdXcl/3gaaPwkZrcy/3IYeGJJOlITw0q1doqcgaVUT+Kkg8Bajprn4Q9u2wBvZ5vBFRchqkOnYl2lTQXYHNuvLPMxbrtuosJTd5fHXPLbC8Qe7l1+VROVse8favlU8AZN9x80JCBqM98xqSXkZYnat1PbS0uh2ir9gSLsns8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587105026828.727233246055; Fri, 19 Jun 2020 10:18:25 -0700 (PDT) Received: from localhost ([::1]:46806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKel-0000D3-Ia for importer@patchew.org; Fri, 19 Jun 2020 13:18:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUF-0000jB-PC for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:31 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUD-0004PR-NW for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:31 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:22 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:55:59 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586449; x=1624122449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K/19YyQZ1dMfa5QzOEJU2PErNtrrLO7t97Cdg6fUhnU=; b=nObRDFfD+pP7hVdY53JSKcQk/T+YuZjzCNk/KwM853pRP2pm20DsExsr jcdEJdKZlssWLK/b6FwGaFfcN9IZ6kbSdmchA8SZGahiQ5awGHNsnuMyo G0jOttFDj5MPkFGn4lGSwsanXW8isAkh3X7RDjo7/Q6aBsElXvF4TFiXW nhUfNvEVg0IVP5xl8f1JBKpDvGGNSWXdNerP/B+qURWcCN/gOcbChimTG 9cOeEm1P65PF5gxAgA7naPkDSE/x6MJij+dWB3CAQ1EkKUoEsCQEv3PHn TbSxNNNNzQZWn63nPsdXzI91DT6lkYU2V5+ttZ0xQ5ziHj2puGB9+dXup w==; IronPort-SDR: 7fkIcEMZZ6tmGHd9NISf74+2yi5MlzOBkz16gwPBhj3KsXsd7tkc8fRdRzz/Amg8lKmJEhXJjg O7ePHNLmivVTPn5CODOJvySa7cgqpTnDirKXDpD6TQZeIeRsKTd1mi2CZ8tc7Ca7jgMbSwSomd fap92/URmjsLbG/zuewoAIdE9b77GLL82TU5fRs66ES9IWR0mPlWjZ5IqiDTEiGG2RMcY4Y3Jc qVPjAwcU/dP3fiybK7PIpg+hM8ir3tPlYPkp/XCnB5XUfLkRq4KHqNIeju7WrM2/Pi+y8gqXXR U7c= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763314" IronPort-SDR: 6kj3ov8XR0mpmbBX3cl7x6TYiBqHewpFy05dNUtoHLbScE1LcE+wRB0L8k86G/TuV4jsDKfKTJ IbnXwcZkvpvi2q41kzh/zdTF1PhPReNwY= IronPort-SDR: Cdex+AH3dOeWDHm27jfdMxlGyCIYJp5C3m8IPAKJnRh4Kx5Giw76BCs0nTbe2TE3sndJje936O 2sw8McjdPwZQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 06/32] riscv: Keep the CPU init routine names consistent Date: Fri, 19 Jun 2020 09:57:51 -0700 Message-Id: <20200619165817.4144200-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Adding a _ to keep some consistency among the CPU init routines. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <1591837729-27486-4-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 35a8c7853b..e867766cf0 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -153,7 +153,7 @@ static void rvxx_imacu_nommu_cpu_init(Object *obj) =20 #if defined(TARGET_RISCV32) =20 -static void rv32imcu_nommu_cpu_init(Object *obj) +static void rv32_imcu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; set_misa(env, RV32 | RVI | RVM | RVC | RVU); @@ -162,7 +162,7 @@ static void rv32imcu_nommu_cpu_init(Object *obj) qdev_prop_set_bit(DEVICE(obj), "mmu", false); } =20 -static void rv32imafcu_nommu_cpu_init(Object *obj) +static void rv32_imafcu_nommu_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVC | RVU); @@ -577,9 +577,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), #if defined(TARGET_RISCV32) DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32imcu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32_imcu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rvxx_imacu_nommu_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32imafcu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32_imafcu_nommu_cpu_init= ), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_gcsu_priv1_10_0_cpu_i= nit), #elif defined(TARGET_RISCV64) DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base_cpu_init), --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586902; cv=none; d=zohomail.com; s=zohoarc; b=Q3sGLksBJkxldayr4g0lHKdiof6UPmpYOm2iP4HfylqxWaP9LJX60sCyc66ZnRX+I6mMPuBfx5/OOTiRupdlO6lyVFJPBK8vMPx3UH1mg/hkqfuj/8BvyM9n5K5cXPoTQdxCoLcVr1ukYMngcsb7pl1ItYw8zKu2MFaeuazYyLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586902; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2FbR2oMszDkXFD8HmFXuQdZNjw66rBD1JObdxJpXB0Q=; b=GMzrYuJwedJWMS2zYe0JtfPbq17+xx6vH1UCG7YGrqcC0f61hXut9y7dPl+HWmWymksJHC/jpPt1vjXjwHkspGBLQF7oQqsAikEt3ID0mXQw4kRuBp9fyQb2NYUylTTxyaUTOIQpWL7PhX1VFx6vccvR+e0eDp4QNqwLbItmeEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15925869029361003.587950777955; Fri, 19 Jun 2020 10:15:02 -0700 (PDT) Received: from localhost ([::1]:32864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKbV-0002gf-CM for importer@patchew.org; Fri, 19 Jun 2020 13:15:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUH-0000mH-JT for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:34 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0004Pg-Pd for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:33 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:22 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:00 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586450; x=1624122450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pxVyDAhQ8bumskxZPWWUD2L/widqjE3TyqKlh9liO+U=; b=HSZA0iEBpZs640potEO5cWs8TBKs/HOCRWZQP7fBOPMQfxf4LdDiFUng ytBzdCQHI4dEFruQLGhr/ZoCLfsgxT0UTy8UTa1C13P9AHSlD33oFvKLQ f2VzwLTNATi5UX34aNkN0pb2CsEIk8Cf/5lPWzYUy5/UUDzp/UovW171k XM1Ya7XkqXMkkvMWcRIRBxnt81JteI56YOBOLlsONlCJ7pIaOxwfOcpIM DoMsr/jjNslowP8ZgHmZz7zJdHSIN8U7wqeixbgLhWbWTB45/faGBvgf/ EbC+a3zZcNIj16GuO5C5DAO8r69yiSBeJfkyoNFF6l9sWKCv4WgYQ0uB0 g==; IronPort-SDR: HNC/iQWwRGTQPYh11Eyi7g8ral4CD6GAs2nZigswBuFT9VziUNg7zDM9frzdryFVhmsMwAKy1O KYVWRbC21HUCsuUgyn3OAh+RbYc9QbKmdRNVA9wgu5SLQ3xIRp3n22WoV8S/ywX3MynTdJgIN+ JlroG0bVJZoqv0C33sFh4wsvD7zEVZ2eF9IYVhDOyDeO54QAzjl3NJvqrRXIzbzLpN7tVPicK/ 3wowZamv1N+R8zz1HpbnU0A6iGYdFZ+/+g5EhUblRU4/+OENdUcRVDPmLR0934tizBIYdR5HJ/ DNc= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763315" IronPort-SDR: aJth/n0C5p7M16ossfwrWPVI2bokLW97MXr+x41TAGKllcwbMweBOvyFVXRKKCHGHq30wDrzR+ lAdpX8RAf5xCC0X7QaZf0J+r2gmZLUoMc= IronPort-SDR: 4LThq1gMuUwK6x6GWk2VeDZF8defDPcGlKgDwClSY7lxxpFfIWZu89Z/EyXIuYHBG3K5r0E/dH urQG//ltD4kA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 07/32] target/riscv: Set access as data_load when validating stage-2 PTEs Date: Fri, 19 Jun 2020 09:57:52 -0700 Message-Id: <20200619165817.4144200-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, Richard Henderson , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 62fe1ecc8f..eda7057663 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -435,7 +435,7 @@ restart: hwaddr vbase; =20 /* Do the second stage translation on the base PTE address. */ - get_physical_address(env, &vbase, &vbase_prot, base, access_ty= pe, + get_physical_address(env, &vbase, &vbase_prot, base, MMU_DATA_= LOAD, mmu_idx, false, true); =20 pte_addr =3D vbase + idx * ptesize; --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587033; cv=none; d=zohomail.com; s=zohoarc; b=EpRgBGQ5zVec6kZlptoU2tJesQw+QBUvJQW0kAAfBzlndd7qWseJwk1/P4khQ1UGpacuypXVj9P4ME7W7KTSzcKVLvYobSDjsnOHN0sFJ3pDYmUPMCN6wRfm+hGDYXvwc6keRITLC5Bkk9tLJxi8WeyuSdg4qXo8wVzcwCfhuJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587033; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ffHT5j++/UfEcHa29gcZh3asdAiZzj5ZA8c3FDtGn04=; b=NnxhqJRlTYvZ/oCefIRyWC6p5tTsCRU3Wmlm+pEtNKikHpaD5kr1f6VE+CRlf6Zk7FIcGQvAeKZNYTuhkNVzN3vLFMRjJTt/O4ivw6Q4EeXOSFDr4ULgZxylRQHQkTJdOWVZTrHkqpLrNAI32HhdJ+Vg9/yxabDQfxpDNtdYgFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587033419191.79511380055908; Fri, 19 Jun 2020 10:17:13 -0700 (PDT) Received: from localhost ([::1]:41410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKdc-0006LM-2O for importer@patchew.org; Fri, 19 Jun 2020 13:17:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUH-0000lz-Fw for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:34 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19131) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUF-0004PZ-4v for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:33 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:23 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:00 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586451; x=1624122451; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wjfXyN3NWwu3m0SqemYRz9ib0aF+Yfq0vhP7wPn1ngY=; b=gfOQFyPFNEVW4aNTkEvw4IzSys0XSMISnoz4l/NggEnM8uB0qiHd+Hme oiRPdGHlBkHoYQOj/Ub50m2jJwnFfAdE3tCFpiX4uIc43wxpSf83yroz6 uHHM56DIx8MXqCKTmSm762RXp3LbZPr6nA4IAIJ0zaxM6IsHmjnl2fOuU 6a7n5lKz/EtAhslTjtEQPxFrzRF74/paBAy9FhxQaOJXkUy6IEO59Hixd NQDo10Agtpf276vhYxSnIHIoDy6GK6c01HtRnJWOY1bmyzZq98114bl2K 2ObmnMQGcsUWx3Fg6HKKygPguVXTlwbO1o5U4jBPOLnHokytWULMfEklN Q==; IronPort-SDR: e6b6lBzoAGL9cJCUQpjBbTpwXOd5yZarGSMVyrPZO6kM4jtTjGXwgPu/fiqJrnSQfeeXyzxoDe VuiYTE8jsgc4evIcuOHWft6iygfwopQS2fvj17Onsa3p8Peyp5hKhfUKYxlhPCfQRWzEUd1k3Z xFsrOp6Aa8jo9/wEamrOIdcfGicB9F0OKMRhqbhBU5IEp+9tnUVa5yxjVfMuiAA+5HWfQY77oe y535ESfZO2RciwohZJIspgjQSfhxmRf4WKl28BQ13oSYtXhDWJakoXLYnoHvi0kTOn8O2jfe+d CrY= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763319" IronPort-SDR: XGv3vJ+ayckV9rSoEOMzT20sDF9ycmuz/5wu2sVvdUPiU3hETfFLj7hOyL0Jsj6rcSdavEb/dQ DHT7FWRd5hrGxAPrwkzH/NoMAMauxWHYM= IronPort-SDR: whcHO7l//rMB7SOXYwPqHww4eOE4VW91W6ARn71S6Xyz2rplSVBeqHAGxl56KYH+uYfbS8bvU6 6pLfTtIGWc9w== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 08/32] target/riscv: Report errors validating 2nd-stage PTEs Date: Fri, 19 Jun 2020 09:57:53 -0700 Message-Id: <20200619165817.4144200-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, Richard Henderson , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/cpu_helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index eda7057663..75d2ae3434 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -435,8 +435,13 @@ restart: hwaddr vbase; =20 /* Do the second stage translation on the base PTE address. */ - get_physical_address(env, &vbase, &vbase_prot, base, MMU_DATA_= LOAD, - mmu_idx, false, true); + int vbase_ret =3D get_physical_address(env, &vbase, &vbase_pro= t, + base, MMU_DATA_LOAD, + mmu_idx, false, true); + + if (vbase_ret !=3D TRANSLATE_SUCCESS) { + return vbase_ret; + } =20 pte_addr =3D vbase + idx * ptesize; } else { --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586948; cv=none; d=zohomail.com; s=zohoarc; b=B3N5gijXB8eDduT6T74ruksSnQBUZJiqqPgv3I7PodvWfNTtktkJSaCVac0N/WEjjm6vnS0HFW4qmBCmT0uWIwne58zIKCpuksJ3g8H73dZ12LJd64Hgg6S+kVXD9yt4lcDUNcZ3rA0NX1kQDwpBVriMYMmissSCGTQL8vZ+n0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586948; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/kRmYC+Uzd6x+x9NCDuisjp5oco9SmfpsEyU7iK9r74=; b=jiP2rGtSA2LK5Nn1CNZJ1omnfrdK6BLtA2t07p50yKIkRMT/Is9vgF+Jo4wcbkIomulKfJN0Rk7YTClC/iUFAgTQ2WRys66LToqSaYs3sgdu7uknEeG+QKk/voRkphwbIRA8XHcXbG4Bq7tc4REuV4KosR1hTCLaDpRMIp+MVQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586948225958.5142805417375; Fri, 19 Jun 2020 10:15:48 -0700 (PDT) Received: from localhost ([::1]:35710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKcE-0003wC-RA for importer@patchew.org; Fri, 19 Jun 2020 13:15:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUU-00014n-U2 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:46 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUS-0004Pg-GX for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:46 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:23 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:00 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586464; x=1624122464; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iMetX1AG2MztuekpTz0Vq0px5OhOLtHAmGALKic8XNY=; b=IZ/SvfJozdZxfvFZkBqgCnWsM5rMHHUWUIyB38/0MwXpIaPqUr85hsFc 8PaDzXjcD+2gw5Q5Ygc4ptZJxYstBSDBNNJTxA6qtumLfvVryqcc4LGKa Qs97cS4kfVl5Ak87gMEQz8/SK7YEbRJUJStbb2TxF8WEODj1uTfzrgKYe PXIplDkV9r10eFzsGcSxq1bVW6C6xis1MtBHWa5p11bt/Nx8PKBeM0bps WNe6aiunp/6tp3vcDr5yLyvPclQDd0unSPiDIJKgJNEDzPyyzIBzxfwtH C485AFnWm7m7MwF9VEPuRSW/2NtQc9VD8Boh897HdsotIlkxyWoKxBZLQ w==; IronPort-SDR: vjL4C5KfdG0f5x5pS78Yedp62UPCQ1k5B9f6JHEJdbPSC+SM762C73W4Jeb43ksouHcqNy15dA OzWsg1J0OKo6/j6e2L/ek+TSR/0AoaN8tcWHqe61CUSO7nLX7EEADAQ17RnkUVt1wEj5NZX5bC 0gz2c1+aj7XnyGp4Hl4gWjUuK6LrO0/aGhYVGbUv3e+dYfz5bhoEtJCGL2aL5fZ91GWFvwlf8S cMKcZ3EFIMrZwR+rxWDVH/rVv4RF57q6z2nu3qBgZxTpEehOVhuhsphioGTNLjrZS8UbYBsL2v mvs= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763324" IronPort-SDR: k/e2Fo1zYhOfmYYXZ/u6nPpTsflTbQKoKNAKgLdw1YtNy3+oCanjotWjM5ubiuNYRFzhqgACNn O0oUg6nHi5guVCh5WlO0GDxb1Tjv280sw= IronPort-SDR: Ix1sDtiV53FPXYJwDGIvUmb/V9i0v67T11Ew2TmBf5iqKoHHrJvjxwtMTutiGdZtddXzGAfKDd E02lbLEhVN0A== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 09/32] target/riscv: Move the hfence instructions to the rvh decode Date: Fri, 19 Jun 2020 09:57:54 -0700 Message-Id: <20200619165817.4144200-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, Richard Henderson , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Also correct the name of the VVMA instruction. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/insn32.decode | 8 ++- .../riscv/insn_trans/trans_privileged.inc.c | 38 ------------- target/riscv/insn_trans/trans_rvh.inc.c | 57 +++++++++++++++++++ target/riscv/translate.c | 1 + 4 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 target/riscv/insn_trans/trans_rvh.inc.c diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index b883672e63..4c8d1215ce 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -64,7 +64,7 @@ @r2 ....... ..... ..... ... ..... ....... %rs1 %rd =20 @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 -@hfence_bvma ....... ..... ..... ... ..... ....... %rs2 %rs1 +@hfence_vvma ....... ..... ..... ... ..... ....... %rs2 %rs1 =20 @sfence_vma ....... ..... ..... ... ..... ....... %rs2 %rs1 @sfence_vm ....... ..... ..... ... ..... ....... %rs1 @@ -77,8 +77,6 @@ uret 0000000 00010 00000 000 00000 1110011 sret 0001000 00010 00000 000 00000 1110011 mret 0011000 00010 00000 000 00000 1110011 wfi 0001000 00101 00000 000 00000 1110011 -hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma -hfence_bvma 0010001 ..... ..... 000 00000 1110011 @hfence_bvma sfence_vma 0001001 ..... ..... 000 00000 1110011 @sfence_vma sfence_vm 0001000 00100 ..... 000 00000 1110011 @sfence_vm =20 @@ -207,3 +205,7 @@ fcvt_w_d 1100001 00000 ..... ... ..... 1010011 @r2_rm fcvt_wu_d 1100001 00001 ..... ... ..... 1010011 @r2_rm fcvt_d_w 1101001 00000 ..... ... ..... 1010011 @r2_rm fcvt_d_wu 1101001 00001 ..... ... ..... 1010011 @r2_rm + +# *** RV32H Base Instruction Set *** +hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma +hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma diff --git a/target/riscv/insn_trans/trans_privileged.inc.c b/target/riscv/= insn_trans/trans_privileged.inc.c index 5f26e0f5ea..2a61a853bf 100644 --- a/target/riscv/insn_trans/trans_privileged.inc.c +++ b/target/riscv/insn_trans/trans_privileged.inc.c @@ -95,41 +95,3 @@ static bool trans_sfence_vm(DisasContext *ctx, arg_sfenc= e_vm *a) { return false; } - -static bool trans_hfence_gvma(DisasContext *ctx, arg_sfence_vma *a) -{ -#ifndef CONFIG_USER_ONLY - if (has_ext(ctx, RVH)) { - /* Hpervisor extensions exist */ - /* - * if (env->priv =3D=3D PRV_M || - * (env->priv =3D=3D PRV_S && - * !riscv_cpu_virt_enabled(env) && - * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { - */ - gen_helper_tlb_flush(cpu_env); - return true; - /* } */ - } -#endif - return false; -} - -static bool trans_hfence_bvma(DisasContext *ctx, arg_sfence_vma *a) -{ -#ifndef CONFIG_USER_ONLY - if (has_ext(ctx, RVH)) { - /* Hpervisor extensions exist */ - /* - * if (env->priv =3D=3D PRV_M || - * (env->priv =3D=3D PRV_S && - * !riscv_cpu_virt_enabled(env) && - * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { - */ - gen_helper_tlb_flush(cpu_env); - return true; - /* } */ - } -#endif - return false; -} diff --git a/target/riscv/insn_trans/trans_rvh.inc.c b/target/riscv/insn_tr= ans/trans_rvh.inc.c new file mode 100644 index 0000000000..2c0359819d --- /dev/null +++ b/target/riscv/insn_trans/trans_rvh.inc.c @@ -0,0 +1,57 @@ +/* + * RISC-V translation routines for the RVXI Base Integer Instruction Set. + * + * Copyright (c) 2020 Western Digital + * + * 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +static bool trans_hfence_gvma(DisasContext *ctx, arg_sfence_vma *a) +{ +#ifndef CONFIG_USER_ONLY + if (ctx->priv_ver >=3D PRIV_VERSION_1_10_0 && + has_ext(ctx, RVH)) { + /* Hpervisor extensions exist */ + /* + * if (env->priv =3D=3D PRV_M || + * (env->priv =3D=3D PRV_S && + * !riscv_cpu_virt_enabled(env) && + * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { + */ + gen_helper_tlb_flush(cpu_env); + return true; + /* } */ + } +#endif + return false; +} + +static bool trans_hfence_vvma(DisasContext *ctx, arg_sfence_vma *a) +{ +#ifndef CONFIG_USER_ONLY + if (ctx->priv_ver >=3D PRIV_VERSION_1_10_0 && + has_ext(ctx, RVH)) { + /* Hpervisor extensions exist */ + /* + * if (env->priv =3D=3D PRV_M || + * (env->priv =3D=3D PRV_S && + * !riscv_cpu_virt_enabled(env) && + * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { + */ + gen_helper_tlb_flush(cpu_env); + return true; + /* } */ + } +#endif + return false; +} diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 43bf7e39a6..ce71ca7a92 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -711,6 +711,7 @@ static bool gen_shift(DisasContext *ctx, arg_r *a, #include "insn_trans/trans_rva.inc.c" #include "insn_trans/trans_rvf.inc.c" #include "insn_trans/trans_rvd.inc.c" +#include "insn_trans/trans_rvh.inc.c" #include "insn_trans/trans_privileged.inc.c" =20 /* Include the auto-generated decoder for 16 bit insn */ --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587149; cv=none; d=zohomail.com; s=zohoarc; b=Fh6XnanDhgLQPO2GNutzLZUPUndjssq2bWkMSp25GcQJO3Pxup2HTp+yQKH/HfS1JA2YGVqPdbkx+5Ol8/y3ZSkxoUUMcgNTJFG6u90X3Iqrmks6Hpca6BLbWQqD62gkrQkpbDe3nnFyQ112DGOVvPTLIxZKCdzjLTPLuHQ04XI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587149; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=svr+SKYAM1aMwQSwQAB3OTFRRph4M9LjHDkAJDCQkbY=; b=KELta+6js2lU/vjA5ib2ziEdGXN8qES+eq/6XmBnhn1rIyJR4/0QUfQgIuJICG+imqEgoZZp/NuEEhaIzxSvFdmYL38qnD+zbQl3ciHkDiFfgJV6dLfUY5JuIWyPtfDuO/UikDKpwka46XMEqJ1ZOeGzgJAtfphQ+yxs5/MKb5I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159258714908596.2564143051419; Fri, 19 Jun 2020 10:19:09 -0700 (PDT) Received: from localhost ([::1]:49950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKfT-0001pa-Fk for importer@patchew.org; Fri, 19 Jun 2020 13:19:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUL-0000pi-Mp for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:38 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUG-0004PR-3M for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:37 -0400 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:23 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:33 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586452; x=1624122452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=melHyBNyq+GBsmbi68L0crjn+k4ZDNG0okkKwoQJd1E=; b=WDJrDptaXabXE60fGKqvHWkSaLIZVwVAF09vb/6YHOf4Vox6xnMsdqh+ 06deDkso/fcM53Y+W3JKiuY0FfRoHTuAhh2sHFyjfn0fW42wgGnOpOTnf aIYeGF+0U3JD03ShxNbbcxRXvOzeCFrXi0GZfr4zXwprVriic7elo4NoN mZPTgwJ+LnU6CCdDvzVJXfxZCZ8rztXD0Ve6saYTNI9DYfJAOg6QeTa1K C4H/Ci1B+PUYUMsJS+n29S3Y05dIA7Mey9+trQVWJH0xk2oPz8tac3BFx uxWQqw4Kg3mfIhHlpNwR8QrEdFyFL4oTk5TbpVAzn5znAkNgzagYPIkOO w==; IronPort-SDR: 2f2e9DrkxKt0TvInIYK+8XLU55FlPFCIZOc6LBxBCnQJ4b7JGuHa7eLBEZjdJsGBZmRnABU/lx pt30hgmTL37pX6q7s+T/8sg3RB1669HaeYmSxyPiX0SzneDKz3C9ICSlYFJsvVl6WZnQ9d60xV 9jFLSuTSjlp0uTdiDVLp43nTcPQiN9puWaHIQHyCJ9++g85tRbUDuEgF3NJ/zAqUEz7r2ZCTeH laSpWvOv8iXCj4+8hXCAcMt7loAZg2O1vvVNQbdqSDGl6OMjsE+QqtwoDTp5scpzHzx1stRxzm as0= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763327" IronPort-SDR: 6xwowBLhNMZu9tJKEt1fWW8OFsgB067nmoS/k2xZG4Aw5tg0Ywwag3KORIpLbnyot5hUwf8qaK +HpGonOZzaiDx5ze78x+nEE9K8MhaYuAk= IronPort-SDR: tX4WVnppWyeEaM/LdRYn1c9CUUefhDT+KGF6VXtu4JxYNd/6Fe68k+lerR/HdZmM1XNMQ1441N Kgjpd5r4rLPw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 10/32] target/riscv: Implement checks for hfence Date: Fri, 19 Jun 2020 09:57:55 -0700 Message-Id: <20200619165817.4144200-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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, Richard Henderson , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Call the helper_hyp_tlb_flush() function on hfence instructions which will generate an illegal insruction execption if we don't have permission to flush the Hypervisor level TLBs. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/helper.h | 5 ++++ target/riscv/insn_trans/trans_rvh.inc.c | 32 +++++-------------------- target/riscv/op_helper.c | 13 ++++++++++ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/target/riscv/helper.h b/target/riscv/helper.h index debb22a480..b36be978d5 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -76,3 +76,8 @@ DEF_HELPER_2(mret, tl, env, tl) DEF_HELPER_1(wfi, void, env) DEF_HELPER_1(tlb_flush, void, env) #endif + +/* Hypervisor functions */ +#ifndef CONFIG_USER_ONLY +DEF_HELPER_1(hyp_tlb_flush, void, env) +#endif diff --git a/target/riscv/insn_trans/trans_rvh.inc.c b/target/riscv/insn_tr= ans/trans_rvh.inc.c index 2c0359819d..263b652d90 100644 --- a/target/riscv/insn_trans/trans_rvh.inc.c +++ b/target/riscv/insn_trans/trans_rvh.inc.c @@ -18,40 +18,20 @@ =20 static bool trans_hfence_gvma(DisasContext *ctx, arg_sfence_vma *a) { + REQUIRE_EXT(ctx, RVH); #ifndef CONFIG_USER_ONLY - if (ctx->priv_ver >=3D PRIV_VERSION_1_10_0 && - has_ext(ctx, RVH)) { - /* Hpervisor extensions exist */ - /* - * if (env->priv =3D=3D PRV_M || - * (env->priv =3D=3D PRV_S && - * !riscv_cpu_virt_enabled(env) && - * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { - */ - gen_helper_tlb_flush(cpu_env); - return true; - /* } */ - } + gen_helper_hyp_tlb_flush(cpu_env); + return true; #endif return false; } =20 static bool trans_hfence_vvma(DisasContext *ctx, arg_sfence_vma *a) { + REQUIRE_EXT(ctx, RVH); #ifndef CONFIG_USER_ONLY - if (ctx->priv_ver >=3D PRIV_VERSION_1_10_0 && - has_ext(ctx, RVH)) { - /* Hpervisor extensions exist */ - /* - * if (env->priv =3D=3D PRV_M || - * (env->priv =3D=3D PRV_S && - * !riscv_cpu_virt_enabled(env) && - * get_field(ctx->mstatus_fs, MSTATUS_TVM))) { - */ - gen_helper_tlb_flush(cpu_env); - return true; - /* } */ - } + gen_helper_hyp_tlb_flush(cpu_env); + return true; #endif return false; } diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index b0c49efc4a..7cccd42a1e 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -194,4 +194,17 @@ void helper_tlb_flush(CPURISCVState *env) } } =20 +void helper_hyp_tlb_flush(CPURISCVState *env) +{ + CPUState *cs =3D env_cpu(env); + + if (env->priv =3D=3D PRV_M || + (env->priv =3D=3D PRV_S && !riscv_cpu_virt_enabled(env))) { + tlb_flush(cs); + return; + } + + riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); +} + #endif /* !CONFIG_USER_ONLY */ --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587540; cv=none; d=zohomail.com; s=zohoarc; b=RnxrBjny1dk7bxd1Fhd5UILO23B1mGlMJvyVneTJOsuG7H+8Dh/zr58bw2i3jkSV6wirbY/IM7fwd/K3bNdyYQZhs1PF6wJOczvGPTZu7MH0XB7g9d9+fpAttg4qxXVVyjM0EoxsV1D79/5Q3OnfxzVIcxaQr0ms2JFAwEQT+h4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587540; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6dYjK+Ali2hnqi2kTaX5zw7hxhDj49J6jcg8Qi0Q6Ug=; b=g1gJls9JJX0HV2BXLfh9c9vJrhHEjb1XsMB4jc6HSjwesl7urJJrb+zQbWatxjtCvg269t4iy5lyu57rO9nWHWPCiS97UntYhHLjlqSm/QSMsFsk6h7zu3mxYty4xt+oeYDXUtP3uhFlqdpeQmr8bCy7525tMH2aE1mlT5uyiZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587540713647.7506839562128; Fri, 19 Jun 2020 10:25:40 -0700 (PDT) Received: from localhost ([::1]:49374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKln-0007F6-FT for importer@patchew.org; Fri, 19 Jun 2020 13:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUT-00010s-Ib for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:45 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19131) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUR-0004PZ-Q1 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:45 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:23 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:01 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586463; x=1624122463; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LYV/HV2oePnGMNLANWSHYTsEansGO/O7noO72QkqJrU=; b=MTUYepk/0VECDFE2+UpnPNiG07MsMyACpl9sgJPbomJ3vVa4BIGXVu/t mEqssXB6m/l0Yhu774WESOxVMTKZf641cgQDjIwvCX/Sjhb9479qL6CwG tDLnoFPVbFCEA3ZpNq8p/x/P5L4ZJLwFiL3IReUKgrPQaVql4yZNT9sJ2 beZtkXONvyjf20YXBdl6ZECjkYxr9JKZx3hwoA2+BofQ3u1hZ4uFMZJti Equwxc9ia2NTlZEYsxCrhEBg5smnlLzGha0xoX4CRpOh7fdhv+FGBgdnM /o8d2K5HgspIRNhbS3wJ71Klo2PXnrkN4pMJZZq/AIHiAWjoqtDuDkam8 Q==; IronPort-SDR: lw4KtMantPBd+u1Dl7MkQJJH+S3DwcPDBObDqqg0XpjOSJRBDaoGzeAitufFC3i63Z8wx6959e /ajTt1xvRBzna9RAMoL7uHkAoX3OSsjhICGIlzUz7rIkr+TnD8U9ddV+TS1tY161tgs8+LKQL4 /eojnexo+9iy0ABpKgMBGySc1G33kX/jixFkL+OeSpExY+j7+BUSSaYRDqmc+azDYubtkO6yaX enYrWMY34pBLjxReRHmZdtAJHiAeF4zMSqOO2jxo4aHVEoI0gj1H+OqmbosKuHkSOCCQNcFTgx Noo= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763328" IronPort-SDR: xDMss9n4YtkJA8QGE0ntQS9l5dbZcZV0Drx8eppqFoL8cyNQVx7oi5U54GIBVktv2XLZTNG5PB VIDSXtoPpBYZmqCnw8WohGA45/4wGMe7s= IronPort-SDR: /I5VQBK97zQ7pOb2dRLGRR7MSpg5z0wjEHAkzpEbNCBV6HprzV3iQQzVdfy9vfZbnyDyR7hxWI OUjU3mLjBEZw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 11/32] riscv/opentitan: Fix the ROM size Date: Fri, 19 Jun 2020 09:57:56 -0700 Message-Id: <20200619165817.4144200-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: Damien Hedde , alistair23@gmail.com, Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis Reported-by: Damien Hedde --- hw/riscv/opentitan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index f6776da8e9..011e4f7ee2 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -25,12 +25,13 @@ #include "hw/misc/unimp.h" #include "hw/riscv/boot.h" #include "exec/address-spaces.h" +#include "qemu/units.h" =20 static const struct MemmapEntry { hwaddr base; hwaddr size; } ibex_memmap[] =3D { - [IBEX_ROM] =3D { 0x00008000, 0xc000 }, + [IBEX_ROM] =3D { 0x00008000, 16 * KiB }, [IBEX_RAM] =3D { 0x10000000, 0x10000 }, [IBEX_FLASH] =3D { 0x20000000, 0x80000 }, [IBEX_UART] =3D { 0x40000000, 0x10000 }, --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587487; cv=none; d=zohomail.com; s=zohoarc; b=GeelyVkPi3VQ0bQgSAFgSKjBkubL4isTA3hcpmyCviTVrulJzEiTco07nKA1S/G+rInXo+dYGdidBBFobf1lGRh7gl6qzw1AVFv4VMbJtlFeH67jfS8UFROX62hW7/M7epco/kXUgS2gLuliIYQeYAR4uM7DpV5fsrwL7UobZn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587487; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TnfV3aIPvImFJMsmjJbVRsTwTEVI2G4+pOe7kHBGOsE=; b=MSe0R1Y2vnwS7n+y2Sbk+M5a4lt21MqnqoBdZ/VU5oYXA6E4F7qYP1OcMayOSi+1mxEf2xvccdPgklBaN33Yiom8uUAt2bYiLrMmyEbn9J8i13iZqCD6CXFasf09T0trinKiXcMGUTnzDu4UERkLc/jNJwS9MfUE8KrQVsC2lYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587487790913.7780363324646; Fri, 19 Jun 2020 10:24:47 -0700 (PDT) Received: from localhost ([::1]:45662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKkw-0005c0-D6 for importer@patchew.org; Fri, 19 Jun 2020 13:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUZ-0001Et-AZ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:51 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUW-0004PR-6j for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:51 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:24 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:01 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586468; x=1624122468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CHr5IFEEHjwwhDrA+gfB1EUHeRDcWu0fMlPUFNj3b2M=; b=SHxMaXOF0v74yLrPqFPnWWGe4qL2P3VNJ0fmt0AGtWB/EipcZIG2HbeM uO0v9ND2LNkAOI9vcMKElStAV5Uj9JC78EduKE7ILKMXCcC4d4AFPwjKu jX7NsYVsRRQB9lpyUxrPwpu/OvIn1Jhygr9LNB/keNWmyP/iH9I38rDPk dLHgR19hbeusXD6P1GlBMjHry+YiNw3p76MGxzOggwH0ryIPnJmivlFJy ztw+fLTdkHZZdELayMzsOLiV7CNpaSDrVuHk1m3k4K6nbdnp14DzlEwAJ Vi3AUi9Kuk8Hf+LJpWXR2P42KNIM/8GTEITpcSYUt0R0f1+fiy08U/qoK g==; IronPort-SDR: UOsLGFM4pBUhU7YUu3lsAqhS7U90OTKAos4zO9BQitGTaLKon2GafzN/egcupv2UufSIJ3upAh 7jXjP1MH9UyD8F7bUGZJ4u0POkXMwfO1OEz6YltMMP663YSAQ8hHKY1pqyf0oYLg/Obr7ZqCWA UWW0Gb6AQ+x3gODNmU3G4ua7odAfyDbZZiio0rBvb7TmGRIRF11afCtk2NqWZYloTs6atWGOG4 OTiAka/II0muFsLiMUZMXOoSFpz7xIw9S8c4f9al3kQ92BE5flQEDbqFsGC8A1gtgUx9A+BZie n9Y= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763331" IronPort-SDR: t80b/o2N5zTCSfs7QXNAhaoiH0ND3kkW83RLXikupFPG0DSrFJSDtjEzn1DjZ/JhCbH8aWbc/o 598q+8cIQ/wkJvxYclaAp9FMwZQElwBxs= IronPort-SDR: 7IHQaFJWgNSXamCCdXXnNwgaS/LNy2LtzBSWV5l6PLse3tvnURPNbixjywWf3WefjYazF6UBLZ IHnSp+Umev0Q== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 12/32] hw/char: Initial commit of Ibex UART Date: Fri, 19 Jun 2020 09:57:57 -0700 Message-Id: <20200619165817.4144200-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 , LIU Zhiwei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is the initial commit of the Ibex UART device. Serial TX is working, while RX has been implemeneted but untested. This is based on the documentation from: https://docs.opentitan.org/hw/ip/uart/doc/ Signed-off-by: Alistair Francis Reviewed-by: LIU Zhiwei --- include/hw/char/ibex_uart.h | 110 ++++++++ hw/char/ibex_uart.c | 492 ++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/char/Makefile.objs | 1 + hw/riscv/Kconfig | 4 + 5 files changed, 609 insertions(+) create mode 100644 include/hw/char/ibex_uart.h create mode 100644 hw/char/ibex_uart.c diff --git a/include/hw/char/ibex_uart.h b/include/hw/char/ibex_uart.h new file mode 100644 index 0000000000..2bec772615 --- /dev/null +++ b/include/hw/char/ibex_uart.h @@ -0,0 +1,110 @@ +/* + * QEMU lowRISC Ibex UART device + * + * Copyright (c) 2020 Western Digital + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef HW_IBEX_UART_H +#define HW_IBEX_UART_H + +#include "hw/sysbus.h" +#include "chardev/char-fe.h" +#include "qemu/timer.h" + +#define IBEX_UART_INTR_STATE 0x00 + #define INTR_STATE_TX_WATERMARK (1 << 0) + #define INTR_STATE_RX_WATERMARK (1 << 1) + #define INTR_STATE_TX_EMPTY (1 << 2) + #define INTR_STATE_RX_OVERFLOW (1 << 3) +#define IBEX_UART_INTR_ENABLE 0x04 +#define IBEX_UART_INTR_TEST 0x08 + +#define IBEX_UART_CTRL 0x0c + #define UART_CTRL_TX_ENABLE (1 << 0) + #define UART_CTRL_RX_ENABLE (1 << 1) + #define UART_CTRL_NF (1 << 2) + #define UART_CTRL_SLPBK (1 << 4) + #define UART_CTRL_LLPBK (1 << 5) + #define UART_CTRL_PARITY_EN (1 << 6) + #define UART_CTRL_PARITY_ODD (1 << 7) + #define UART_CTRL_RXBLVL (3 << 8) + #define UART_CTRL_NCO (0xFFFF << 16) + +#define IBEX_UART_STATUS 0x10 + #define UART_STATUS_TXFULL (1 << 0) + #define UART_STATUS_RXFULL (1 << 1) + #define UART_STATUS_TXEMPTY (1 << 2) + #define UART_STATUS_RXIDLE (1 << 4) + #define UART_STATUS_RXEMPTY (1 << 5) + +#define IBEX_UART_RDATA 0x14 +#define IBEX_UART_WDATA 0x18 + +#define IBEX_UART_FIFO_CTRL 0x1c + #define FIFO_CTRL_RXRST (1 << 0) + #define FIFO_CTRL_TXRST (1 << 1) + #define FIFO_CTRL_RXILVL (7 << 2) + #define FIFO_CTRL_RXILVL_SHIFT (2) + #define FIFO_CTRL_TXILVL (3 << 5) + #define FIFO_CTRL_TXILVL_SHIFT (5) + +#define IBEX_UART_FIFO_STATUS 0x20 +#define IBEX_UART_OVRD 0x24 +#define IBEX_UART_VAL 0x28 +#define IBEX_UART_TIMEOUT_CTRL 0x2c + +#define IBEX_UART_TX_FIFO_SIZE 16 + +#define TYPE_IBEX_UART "ibex-uart" +#define IBEX_UART(obj) \ + OBJECT_CHECK(IbexUartState, (obj), TYPE_IBEX_UART) + +typedef struct { + /* */ + SysBusDevice parent_obj; + + /* */ + MemoryRegion mmio; + + uint8_t tx_fifo[IBEX_UART_TX_FIFO_SIZE]; + uint32_t tx_level; + + QEMUTimer *fifo_trigger_handle; + uint64_t char_tx_time; + + uint32_t uart_intr_state; + uint32_t uart_intr_enable; + uint32_t uart_ctrl; + uint32_t uart_status; + uint32_t uart_rdata; + uint32_t uart_fifo_ctrl; + uint32_t uart_fifo_status; + uint32_t uart_ovrd; + uint32_t uart_val; + uint32_t uart_timeout_ctrl; + + CharBackend chr; + qemu_irq tx_watermark; + qemu_irq rx_watermark; + qemu_irq tx_empty; + qemu_irq rx_overflow; +} IbexUartState; +#endif /* HW_IBEX_UART_H */ diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c new file mode 100644 index 0000000000..3e0dd9968e --- /dev/null +++ b/hw/char/ibex_uart.c @@ -0,0 +1,492 @@ +/* + * QEMU lowRISC Ibex UART device + * + * Copyright (c) 2020 Western Digital + * + * For details check the documentation here: + * https://docs.opentitan.org/hw/ip/uart/doc/ + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "hw/char/ibex_uart.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" + +static void ibex_uart_update_irqs(IbexUartState *s) +{ + if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_TX_WATERMARK= ) { + qemu_set_irq(s->tx_watermark, 1); + } else { + qemu_set_irq(s->tx_watermark, 0); + } + + if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_RX_WATERMARK= ) { + qemu_set_irq(s->rx_watermark, 1); + } else { + qemu_set_irq(s->rx_watermark, 0); + } + + if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_TX_EMPTY) { + qemu_set_irq(s->tx_empty, 1); + } else { + qemu_set_irq(s->tx_empty, 0); + } + + if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_RX_OVERFLOW)= { + qemu_set_irq(s->rx_overflow, 1); + } else { + qemu_set_irq(s->rx_overflow, 0); + } +} + +static int ibex_uart_can_receive(void *opaque) +{ + IbexUartState *s =3D opaque; + + if (s->uart_ctrl & UART_CTRL_RX_ENABLE) { + return 1; + } + + return 0; +} + +static void ibex_uart_receive(void *opaque, const uint8_t *buf, int size) +{ + IbexUartState *s =3D opaque; + uint8_t rx_fifo_level =3D (s->uart_fifo_ctrl & FIFO_CTRL_RXILVL) + >> FIFO_CTRL_RXILVL_SHIFT; + + s->uart_rdata =3D *buf; + + s->uart_status &=3D ~UART_STATUS_RXIDLE; + s->uart_status &=3D ~UART_STATUS_RXEMPTY; + + if (size > rx_fifo_level) { + s->uart_intr_state |=3D INTR_STATE_RX_WATERMARK; + } + + ibex_uart_update_irqs(s); +} + +static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond, + void *opaque) +{ + IbexUartState *s =3D opaque; + uint8_t tx_fifo_level =3D (s->uart_fifo_ctrl & FIFO_CTRL_TXILVL) + >> FIFO_CTRL_TXILVL_SHIFT; + int ret; + + /* instant drain the fifo when there's no back-end */ + if (!qemu_chr_fe_backend_connected(&s->chr)) { + s->tx_level =3D 0; + return FALSE; + } + + if (!s->tx_level) { + s->uart_status &=3D ~UART_STATUS_TXFULL; + s->uart_status |=3D UART_STATUS_TXEMPTY; + s->uart_intr_state |=3D INTR_STATE_TX_EMPTY; + s->uart_intr_state &=3D ~INTR_STATE_TX_WATERMARK; + ibex_uart_update_irqs(s); + return FALSE; + } + + ret =3D qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level); + + if (ret >=3D 0) { + s->tx_level -=3D ret; + memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_level); + } + + if (s->tx_level) { + guint r =3D qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, + ibex_uart_xmit, s); + if (!r) { + s->tx_level =3D 0; + return FALSE; + } + } + + /* Clear the TX Full bit */ + if (s->tx_level !=3D IBEX_UART_TX_FIFO_SIZE) { + s->uart_status &=3D ~UART_STATUS_TXFULL; + } + + /* Disable the TX_WATERMARK IRQ */ + if (s->tx_level < tx_fifo_level) { + s->uart_intr_state &=3D ~INTR_STATE_TX_WATERMARK; + } + + /* Set TX empty */ + if (s->tx_level =3D=3D 0) { + s->uart_status |=3D UART_STATUS_TXEMPTY; + s->uart_intr_state |=3D INTR_STATE_TX_EMPTY; + } + + ibex_uart_update_irqs(s); + return FALSE; +} + +static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf, + int size) +{ + uint64_t current_time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + uint8_t tx_fifo_level =3D (s->uart_fifo_ctrl & FIFO_CTRL_TXILVL) + >> FIFO_CTRL_TXILVL_SHIFT; + + if (size > IBEX_UART_TX_FIFO_SIZE - s->tx_level) { + size =3D IBEX_UART_TX_FIFO_SIZE - s->tx_level; + qemu_log_mask(LOG_GUEST_ERROR, "ibex_uart: TX FIFO overflow"); + } + + memcpy(s->tx_fifo + s->tx_level, buf, size); + s->tx_level +=3D size; + + if (s->tx_level > 0) { + s->uart_status &=3D ~UART_STATUS_TXEMPTY; + } + + if (s->tx_level >=3D tx_fifo_level) { + s->uart_intr_state |=3D INTR_STATE_TX_WATERMARK; + ibex_uart_update_irqs(s); + } + + if (s->tx_level =3D=3D IBEX_UART_TX_FIFO_SIZE) { + s->uart_status |=3D UART_STATUS_TXFULL; + } + + timer_mod(s->fifo_trigger_handle, current_time + + (s->char_tx_time * 4)); +} + +static void ibex_uart_reset(DeviceState *dev) +{ + IbexUartState *s =3D IBEX_UART(dev); + + s->uart_intr_state =3D 0x00000000; + s->uart_intr_state =3D 0x00000000; + s->uart_intr_enable =3D 0x00000000; + s->uart_ctrl =3D 0x00000000; + s->uart_status =3D 0x0000003c; + s->uart_rdata =3D 0x00000000; + s->uart_fifo_ctrl =3D 0x00000000; + s->uart_fifo_status =3D 0x00000000; + s->uart_ovrd =3D 0x00000000; + s->uart_val =3D 0x00000000; + s->uart_timeout_ctrl =3D 0x00000000; + + s->tx_level =3D 0; + + s->char_tx_time =3D (NANOSECONDS_PER_SECOND / 230400) * 10; + + ibex_uart_update_irqs(s); +} + +static uint64_t ibex_uart_read(void *opaque, hwaddr addr, + unsigned int size) +{ + IbexUartState *s =3D opaque; + uint64_t retvalue =3D 0; + + switch (addr) { + case IBEX_UART_INTR_STATE: + retvalue =3D s->uart_intr_state; + break; + case IBEX_UART_INTR_ENABLE: + retvalue =3D s->uart_intr_enable; + break; + case IBEX_UART_INTR_TEST: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: wdata is write only\n", __func__); + break; + + case IBEX_UART_CTRL: + retvalue =3D s->uart_ctrl; + break; + case IBEX_UART_STATUS: + retvalue =3D s->uart_status; + break; + + case IBEX_UART_RDATA: + retvalue =3D s->uart_rdata; + if (s->uart_ctrl & UART_CTRL_RX_ENABLE) { + qemu_chr_fe_accept_input(&s->chr); + + s->uart_status |=3D UART_STATUS_RXIDLE; + s->uart_status |=3D UART_STATUS_RXEMPTY; + } + break; + case IBEX_UART_WDATA: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: wdata is write only\n", __func__); + break; + + case IBEX_UART_FIFO_CTRL: + retvalue =3D s->uart_fifo_ctrl; + break; + case IBEX_UART_FIFO_STATUS: + retvalue =3D s->uart_fifo_status; + + retvalue |=3D s->tx_level & 0x1F; + + qemu_log_mask(LOG_UNIMP, + "%s: RX fifos are not supported\n", __func__); + break; + + case IBEX_UART_OVRD: + retvalue =3D s->uart_ovrd; + qemu_log_mask(LOG_UNIMP, + "%s: ovrd is not supported\n", __func__); + break; + case IBEX_UART_VAL: + retvalue =3D s->uart_val; + qemu_log_mask(LOG_UNIMP, + "%s: val is not supported\n", __func__); + break; + case IBEX_UART_TIMEOUT_CTRL: + retvalue =3D s->uart_timeout_ctrl; + qemu_log_mask(LOG_UNIMP, + "%s: timeout_ctrl is not supported\n", __func__); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + return 0; + } + + return retvalue; +} + +static void ibex_uart_write(void *opaque, hwaddr addr, + uint64_t val64, unsigned int size) +{ + IbexUartState *s =3D opaque; + uint32_t value =3D val64; + + switch (addr) { + case IBEX_UART_INTR_STATE: + /* Write 1 clear */ + s->uart_intr_state &=3D ~value; + ibex_uart_update_irqs(s); + break; + case IBEX_UART_INTR_ENABLE: + s->uart_intr_enable =3D value; + ibex_uart_update_irqs(s); + break; + case IBEX_UART_INTR_TEST: + s->uart_intr_state |=3D value; + ibex_uart_update_irqs(s); + break; + + case IBEX_UART_CTRL: + s->uart_ctrl =3D value; + + if (value & UART_CTRL_NF) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_NF is not supported\n", __func__); + } + if (value & UART_CTRL_SLPBK) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_SLPBK is not supported\n", __func= __); + } + if (value & UART_CTRL_LLPBK) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_LLPBK is not supported\n", __func= __); + } + if (value & UART_CTRL_PARITY_EN) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_PARITY_EN is not supported\n", + __func__); + } + if (value & UART_CTRL_PARITY_ODD) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_PARITY_ODD is not supported\n", + __func__); + } + if (value & UART_CTRL_RXBLVL) { + qemu_log_mask(LOG_UNIMP, + "%s: UART_CTRL_RXBLVL is not supported\n", __fun= c__); + } + if (value & UART_CTRL_NCO) { + uint64_t baud =3D ((value & UART_CTRL_NCO) >> 16); + baud *=3D 1000; + baud /=3D 2 ^ 20; + + s->char_tx_time =3D (NANOSECONDS_PER_SECOND / baud) * 10; + } + break; + case IBEX_UART_STATUS: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: status is read only\n", __func__); + break; + + case IBEX_UART_RDATA: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: rdata is read only\n", __func__); + break; + case IBEX_UART_WDATA: + uart_write_tx_fifo(s, (uint8_t *) &value, 1); + break; + + case IBEX_UART_FIFO_CTRL: + s->uart_fifo_ctrl =3D value; + + if (value & FIFO_CTRL_RXRST) { + qemu_log_mask(LOG_UNIMP, + "%s: RX fifos are not supported\n", __func__); + } + if (value & FIFO_CTRL_TXRST) { + s->tx_level =3D 0; + } + break; + case IBEX_UART_FIFO_STATUS: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: fifo_status is read only\n", __func__); + break; + + case IBEX_UART_OVRD: + s->uart_ovrd =3D value; + qemu_log_mask(LOG_UNIMP, + "%s: ovrd is not supported\n", __func__); + break; + case IBEX_UART_VAL: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: val is read only\n", __func__); + break; + case IBEX_UART_TIMEOUT_CTRL: + s->uart_timeout_ctrl =3D value; + qemu_log_mask(LOG_UNIMP, + "%s: timeout_ctrl is not supported\n", __func__); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + } +} + +static void fifo_trigger_update(void *opaque) +{ + IbexUartState *s =3D opaque; + + if (s->uart_ctrl & UART_CTRL_TX_ENABLE) { + ibex_uart_xmit(NULL, G_IO_OUT, s); + } +} + +static const MemoryRegionOps ibex_uart_ops =3D { + .read =3D ibex_uart_read, + .write =3D ibex_uart_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl.min_access_size =3D 4, + .impl.max_access_size =3D 4, +}; + +static int ibex_uart_post_load(void *opaque, int version_id) +{ + IbexUartState *s =3D opaque; + + ibex_uart_update_irqs(s); + return 0; +} + +static const VMStateDescription vmstate_ibex_uart =3D { + .name =3D TYPE_IBEX_UART, + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D ibex_uart_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY(tx_fifo, IbexUartState, + IBEX_UART_TX_FIFO_SIZE), + VMSTATE_UINT32(tx_level, IbexUartState), + VMSTATE_UINT64(char_tx_time, IbexUartState), + VMSTATE_TIMER_PTR(fifo_trigger_handle, IbexUartState), + VMSTATE_UINT32(uart_intr_state, IbexUartState), + VMSTATE_UINT32(uart_intr_enable, IbexUartState), + VMSTATE_UINT32(uart_ctrl, IbexUartState), + VMSTATE_UINT32(uart_status, IbexUartState), + VMSTATE_UINT32(uart_rdata, IbexUartState), + VMSTATE_UINT32(uart_fifo_ctrl, IbexUartState), + VMSTATE_UINT32(uart_fifo_status, IbexUartState), + VMSTATE_UINT32(uart_ovrd, IbexUartState), + VMSTATE_UINT32(uart_val, IbexUartState), + VMSTATE_UINT32(uart_timeout_ctrl, IbexUartState), + VMSTATE_END_OF_LIST() + } +}; + +static Property ibex_uart_properties[] =3D { + DEFINE_PROP_CHR("chardev", IbexUartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ibex_uart_init(Object *obj) +{ + IbexUartState *s =3D IBEX_UART(obj); + + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->tx_watermark); + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->rx_watermark); + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->tx_empty); + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->rx_overflow); + + memory_region_init_io(&s->mmio, obj, &ibex_uart_ops, s, + TYPE_IBEX_UART, 0x400); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); +} + +static void ibex_uart_realize(DeviceState *dev, Error **errp) +{ + IbexUartState *s =3D IBEX_UART(dev); + + s->fifo_trigger_handle =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, + fifo_trigger_update, s); + + qemu_chr_fe_set_handlers(&s->chr, ibex_uart_can_receive, + ibex_uart_receive, NULL, NULL, + s, NULL, true); +} + +static void ibex_uart_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->reset =3D ibex_uart_reset; + dc->realize =3D ibex_uart_realize; + dc->vmsd =3D &vmstate_ibex_uart; + device_class_set_props(dc, ibex_uart_properties); +} + +static const TypeInfo ibex_uart_info =3D { + .name =3D TYPE_IBEX_UART, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(IbexUartState), + .instance_init =3D ibex_uart_init, + .class_init =3D ibex_uart_class_init, +}; + +static void ibex_uart_register_types(void) +{ + type_register_static(&ibex_uart_info); +} + +type_init(ibex_uart_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 955cc8dd5c..4010ea5606 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1250,7 +1250,9 @@ M: Alistair Francis L: qemu-riscv@nongnu.org S: Supported F: hw/riscv/opentitan.c +F: hw/char/ibex_uart.c F: include/hw/riscv/opentitan.h +F: include/hw/char/ibex_uart.h =20 SH4 Machines ------------ diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs index 9e9a6c1aff..633996be5b 100644 --- a/hw/char/Makefile.objs +++ b/hw/char/Makefile.objs @@ -12,6 +12,7 @@ common-obj-$(CONFIG_VIRTIO_SERIAL) +=3D virtio-console.o common-obj-$(CONFIG_XILINX) +=3D xilinx_uartlite.o common-obj-$(CONFIG_XEN) +=3D xen_console.o common-obj-$(CONFIG_CADENCE) +=3D cadence_uart.o +common-obj-$(CONFIG_IBEX) +=3D ibex_uart.o =20 common-obj-$(CONFIG_EXYNOS4) +=3D exynos4210_uart.o common-obj-$(CONFIG_COLDFIRE) +=3D mcf_uart.o diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 94d19571f7..28947ef3e0 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -4,6 +4,9 @@ config HTIF config HART bool =20 +config IBEX + bool + config SIFIVE bool select MSI_NONBROKEN @@ -29,6 +32,7 @@ config SPIKE =20 config OPENTITAN bool + select IBEX select HART select UNIMP =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587648; cv=none; d=zohomail.com; s=zohoarc; b=OVvOR9kspU3FgIavCubmjq7AqZVhpoLnJcz2iGvhQEN5Rf++ReyEK9MDxh3MvS58f7LFf4AkjpaCmCSUw7wI19c0JdmhDh3pmpKa1D4kePvpFSTzSHsRZdJRV1TmeZGO+5vZqP93xlLaDwVtojwEXXVvFYnsj5hrYDrmCdACGNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587648; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BI+wCdoyZ308J5Gm7C8Kpfav19JFLmXmrNTR6Mm1Vmg=; b=c7XFOrgGY57e+DM/WbBN7jabL810XsOtXN07PnzJKI+BBwtSIetrGdRXxlmyVYbztQrGY5DxOWVHxG9mcKxMPlS9AfA4UgWCWMG53kxpfDrf9oui5RaYBrb8pxg/rEwx1l2iv3bcgExJTGFJhP6hmDzTatk/3OxECeZTMvjlsDI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587648613854.9987049018218; Fri, 19 Jun 2020 10:27:28 -0700 (PDT) Received: from localhost ([::1]:55158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKnW-0001IB-AG for importer@patchew.org; Fri, 19 Jun 2020 13:27:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUg-0001Va-LB for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:58 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19131) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUd-0004PZ-SY for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:58 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:24 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:01 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586476; x=1624122476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q84SoZ/VTr/fgQthZQkif3oxb/7JuSt4f4aIvRC20gI=; b=GHMuKMQcdqZGW8BqRCmYSSRrwX+AqcxDcOozTqc+RkXN5qj8wESmJ+j6 6XDEN5fF79Rm1XkR2OOljFXmKKg7Fq0oe4VUjaFLWIBgZbGoK4n+aXDrK EM91bADdQkoWqwYYYTutbLP86sa3KLLaalDP6I9VFiNEmlBr3CjOAt/Gb /ZHt+QHGKfML+KHaM6fmwt6qMP5I2OGwIGuj/YRmJ/rl2gG1+ZJYUoTaE /ptg3VoixhuHGAhz+9PCS3TvY57INDRAmOZKh99u9qgL9Z+A4c6hKiTos KtqDtAohBEBFU6osF3o8pSQmz7hbko8+DBB8aMqL8lu9ccCOzzcvcmP2A g==; IronPort-SDR: OJ57tY6Wx/hrUKMUZdgIYehVgBEZzUKwWu6lfaJ2Ec6mYJvCG0NJhyPXJhH5dZDRqv0V1bXr3y 05Ncz7OOxqSELQEC1O0W7IFdCHFttUDu4wN6a6QaL47cJowdZ4BGn3XSc9EI7zIaZi71i7tvoX 0ffPOKlU8F30IFrP3dokk6lrF15vlS34LGLxwCXPHZn8cDx6yhUOljUuslk2O9N8Bl3T0OCHAZ lYwkxMRVQtdTb/ECnJWT6/L9qKsJKgpynXFZx6k7eX0tl/XVI2b09GKtZED2pq+Rco9tUcay+u 4NY= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="144763333" IronPort-SDR: fIbQDvmaPyfoPJGrrIRg6GXNRfM9OgWYdYq2Gc7j58UE3jm8X7b6g2D5MAfnGJL6R9nOu9wZ3R bh/YFPvCAemxWd6evcnMuGppHMThsNafs= IronPort-SDR: B8vONw+B7142yzO/R4/K7zmGOUAr4qQWSv62xn3mdSm8J6QvuCZSiyE9F8z2AcXK6mh+Aa+t/c fZf2tVuKRuew== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 13/32] hw/intc: Initial commit of lowRISC Ibex PLIC Date: Fri, 19 Jun 2020 09:57:58 -0700 Message-Id: <20200619165817.4144200-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:21 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The Ibex core contains a PLIC that although similar to the RISC-V spec is not RISC-V spec compliant. This patch implements a Ibex PLIC in a somewhat generic way. As the current RISC-V PLIC needs tidying up, my hope is that as the Ibex PLIC move towards spec compliance this PLIC implementation can be updated until it can replace the current PLIC. Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/intc/ibex_plic.h | 63 +++++++++ hw/intc/ibex_plic.c | 261 ++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/intc/Makefile.objs | 1 + 4 files changed, 327 insertions(+) create mode 100644 include/hw/intc/ibex_plic.h create mode 100644 hw/intc/ibex_plic.c diff --git a/include/hw/intc/ibex_plic.h b/include/hw/intc/ibex_plic.h new file mode 100644 index 0000000000..ddc7909903 --- /dev/null +++ b/include/hw/intc/ibex_plic.h @@ -0,0 +1,63 @@ +/* + * QEMU RISC-V lowRISC Ibex PLIC + * + * Copyright (c) 2020 Western Digital + * + * 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#ifndef HW_IBEX_PLIC_H +#define HW_IBEX_PLIC_H + +#include "hw/sysbus.h" + +#define TYPE_IBEX_PLIC "ibex-plic" +#define IBEX_PLIC(obj) \ + OBJECT_CHECK(IbexPlicState, (obj), TYPE_IBEX_PLIC) + +typedef struct IbexPlicState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion mmio; + + uint32_t *pending; + uint32_t *source; + uint32_t *priority; + uint32_t *enable; + uint32_t threshold; + uint32_t claim; + + /* config */ + uint32_t num_cpus; + uint32_t num_sources; + + uint32_t pending_base; + uint32_t pending_num; + + uint32_t source_base; + uint32_t source_num; + + uint32_t priority_base; + uint32_t priority_num; + + uint32_t enable_base; + uint32_t enable_num; + + uint32_t threshold_base; + + uint32_t claim_base; +} IbexPlicState; + +#endif /* HW_IBEX_PLIC_H */ diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c new file mode 100644 index 0000000000..41079518c6 --- /dev/null +++ b/hw/intc/ibex_plic.c @@ -0,0 +1,261 @@ +/* + * QEMU RISC-V lowRISC Ibex PLIC + * + * Copyright (c) 2020 Western Digital + * + * Documentation avaliable: https://docs.opentitan.org/hw/ip/rv_plic/doc/ + * + * 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 f= or + * 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/log.h" +#include "hw/qdev-properties.h" +#include "hw/core/cpu.h" +#include "hw/boards.h" +#include "hw/pci/msi.h" +#include "target/riscv/cpu_bits.h" +#include "target/riscv/cpu.h" +#include "hw/intc/ibex_plic.h" + +static bool addr_between(uint32_t addr, uint32_t base, uint32_t num) +{ + uint32_t end =3D base + (num * 0x04); + + if (addr >=3D base && addr < end) { + return true; + } + + return false; +} + +static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool lev= el) +{ + int pending_num =3D irq / 32; + + s->pending[pending_num] |=3D level << (irq % 32); +} + +static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context) +{ + int i; + + for (i =3D 0; i < s->pending_num; i++) { + uint32_t irq_num =3D ctz64(s->pending[i]) + (i * 32); + + if (!(s->pending[i] & s->enable[i])) { + /* No pending and enabled IRQ */ + continue; + } + + if (s->priority[irq_num] > s->threshold) { + if (!s->claim) { + s->claim =3D irq_num; + } + return true; + } + } + + return false; +} + +static void ibex_plic_update(IbexPlicState *s) +{ + CPUState *cpu; + int level, i; + + for (i =3D 0; i < s->num_cpus; i++) { + cpu =3D qemu_get_cpu(i); + + if (!cpu) { + continue; + } + + level =3D ibex_plic_irqs_pending(s, 0); + + riscv_cpu_update_mip(RISCV_CPU(cpu), MIP_MEIP, BOOL_TO_MASK(level)= ); + } +} + +static void ibex_plic_reset(DeviceState *dev) +{ + IbexPlicState *s =3D IBEX_PLIC(dev); + + s->threshold =3D 0x00000000; + s->claim =3D 0x00000000; +} + +static uint64_t ibex_plic_read(void *opaque, hwaddr addr, + unsigned int size) +{ + IbexPlicState *s =3D opaque; + int offset; + uint32_t ret =3D 0; + + if (addr_between(addr, s->pending_base, s->pending_num)) { + offset =3D (addr - s->pending_base) / 4; + ret =3D s->pending[offset]; + } else if (addr_between(addr, s->source_base, s->source_num)) { + qemu_log_mask(LOG_UNIMP, + "%s: Interrupt source mode not supported\n", __func_= _); + } else if (addr_between(addr, s->priority_base, s->priority_num)) { + offset =3D (addr - s->priority_base) / 4; + ret =3D s->priority[offset]; + } else if (addr_between(addr, s->enable_base, s->enable_num)) { + offset =3D (addr - s->enable_base) / 4; + ret =3D s->enable[offset]; + } else if (addr_between(addr, s->threshold_base, 1)) { + ret =3D s->threshold; + } else if (addr_between(addr, s->claim_base, 1)) { + int pending_num =3D s->claim / 32; + s->pending[pending_num] &=3D ~(1 << (s->claim % 32)); + + ret =3D s->claim; + } + + return ret; +} + +static void ibex_plic_write(void *opaque, hwaddr addr, + uint64_t value, unsigned int size) +{ + IbexPlicState *s =3D opaque; + + if (addr_between(addr, s->pending_base, s->pending_num)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Pending registers are read only\n", __func__); + } else if (addr_between(addr, s->source_base, s->source_num)) { + qemu_log_mask(LOG_UNIMP, + "%s: Interrupt source mode not supported\n", __func_= _); + } else if (addr_between(addr, s->priority_base, s->priority_num)) { + uint32_t irq =3D ((addr - s->priority_base) >> 2) + 1; + s->priority[irq] =3D value & 7; + } else if (addr_between(addr, s->enable_base, s->enable_num)) { + uint32_t enable_reg =3D (addr - s->enable_base) / 4; + + s->enable[enable_reg] =3D value; + } else if (addr_between(addr, s->threshold_base, 1)) { + s->threshold =3D value & 3; + } else if (addr_between(addr, s->claim_base, 1)) { + if (s->claim =3D=3D value) { + /* Interrupt was completed */ + s->claim =3D 0; + } + } + + ibex_plic_update(s); +} + +static const MemoryRegionOps ibex_plic_ops =3D { + .read =3D ibex_plic_read, + .write =3D ibex_plic_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4 + } +}; + +static void ibex_plic_irq_request(void *opaque, int irq, int level) +{ + IbexPlicState *s =3D opaque; + + ibex_plic_irqs_set_pending(s, irq, level > 0); + ibex_plic_update(s); +} + +static Property ibex_plic_properties[] =3D { + DEFINE_PROP_UINT32("num-cpus", IbexPlicState, num_cpus, 1), + DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 80), + + DEFINE_PROP_UINT32("pending-base", IbexPlicState, pending_base, 0), + DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 3), + + DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x0c), + DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 3), + + DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x18= ), + DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 80), + + DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x200), + DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 3), + + DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x= 20c), + + DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x210), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ibex_plic_init(Object *obj) +{ + IbexPlicState *s =3D IBEX_PLIC(obj); + + memory_region_init_io(&s->mmio, obj, &ibex_plic_ops, s, + TYPE_IBEX_PLIC, 0x400); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); +} + +static void ibex_plic_realize(DeviceState *dev, Error **errp) +{ + IbexPlicState *s =3D IBEX_PLIC(dev); + int i; + + s->pending =3D g_new0(uint32_t, s->pending_num); + s->source =3D g_new0(uint32_t, s->source_num); + s->priority =3D g_new0(uint32_t, s->priority_num); + s->enable =3D g_new0(uint32_t, s->enable_num); + + qdev_init_gpio_in(dev, ibex_plic_irq_request, s->num_sources); + + /* + * We can't allow the supervisor to control SEIP as this would allow t= he + * supervisor to clear a pending external interrupt which will result = in + * a lost interrupt in the case a PLIC is attached. The SEIP bit must = be + * hardware controlled when a PLIC is attached. + */ + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; + for (i =3D 0; i < smp_cpus; i++) { + RISCVCPU *cpu =3D RISCV_CPU(qemu_get_cpu(i)); + if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) { + error_report("SEIP already claimed"); + exit(1); + } + } + + msi_nonbroken =3D true; +} + +static void ibex_plic_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->reset =3D ibex_plic_reset; + device_class_set_props(dc, ibex_plic_properties); + dc->realize =3D ibex_plic_realize; +} + +static const TypeInfo ibex_plic_info =3D { + .name =3D TYPE_IBEX_PLIC, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(IbexPlicState), + .instance_init =3D ibex_plic_init, + .class_init =3D ibex_plic_class_init, +}; + +static void ibex_plic_register_types(void) +{ + type_register_static(&ibex_plic_info); +} + +type_init(ibex_plic_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 4010ea5606..63b3bb3266 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1251,8 +1251,10 @@ L: qemu-riscv@nongnu.org S: Supported F: hw/riscv/opentitan.c F: hw/char/ibex_uart.c +F: hw/intc/ibex_plic.c F: include/hw/riscv/opentitan.h F: include/hw/char/ibex_uart.h +F: include/hw/intc/ibex_plic.h =20 SH4 Machines ------------ diff --git a/hw/intc/Makefile.objs b/hw/intc/Makefile.objs index f726d87532..a61e6728fe 100644 --- a/hw/intc/Makefile.objs +++ b/hw/intc/Makefile.objs @@ -49,3 +49,4 @@ obj-$(CONFIG_ARM_GIC) +=3D arm_gicv3_cpuif.o obj-$(CONFIG_MIPS_CPS) +=3D mips_gic.o obj-$(CONFIG_NIOS2) +=3D nios2_iic.o obj-$(CONFIG_OMPIC) +=3D ompic.o +obj-$(CONFIG_IBEX) +=3D ibex_plic.o --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586516; cv=none; d=zohomail.com; s=zohoarc; b=ebDS7DAhKtByRIFmHAB2BwCmiUNU33paO9jDQ6sItmnG7eiAXarqF4lIZDH2AKijscQ+HJspBL/1pDReiWTO/tNn6TdqH/1N6oYhSsMvoZPkrYIw4/prMj3y19IBD9XCTHDXG32QrRK9uwbcMMVPm3em+LUU0RADcF6g7lskDcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cdUGT5JMyDVa6g7z01DneBRm4l+XnDY6B42to7+1IQ0=; b=CGM/607AGIeuR1tCJ9Us4FleiEMleuK9Xdmo5NDRKZOveSfeL5jxoY0tmmoTtyWTd3v8kjZWH7J9yayk7DUME0r5wF39cl3ImRJDl8UmtS/ChDKkv0/4GfK4ZoFUrqxl044wvHIvwpqV7H7VHPvlVvGMl+FtvdjGBPsjb+XziFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586516130377.955850799263; Fri, 19 Jun 2020 10:08:36 -0700 (PDT) Received: from localhost ([::1]:58464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKVG-0002ES-Sc for importer@patchew.org; Fri, 19 Jun 2020 13:08:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUD-0000f9-5d for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUA-0004Pk-By for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:28 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:01 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586448; x=1624122448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZyHGfLXMoD/vQlrAS/c+SUX96vz+cOHa3/TUMLtyVWc=; b=kGhRpwjNSGbfcwmNKyPGUiiRrEImMVnm5KB83w8kmXC0eh8Czpb9V1Y4 eap9+r5wlmfT3L97L3UeygkJR/QrVOprISWGaK9fCbg6fmtIJxMiokqNf 9CkVsQTQhR3QhhKnna2w8dHQFK+l1+YD/A+QvnSIrBw/WEp05yVrQgEoW zIyAIAuwhHozEOfKn3A06krjwZjHEC/LaRPJEDsW8gsjDDes35LreSdSJ xKo+sF94sJnZ5CDHVQmRrWRbX/w4WLw1M0cdqH0mMs/FvrKkQyDXbbhhZ g0m7TXxOCRitx1aTtEatAJTQzFcwm0jVfXpgs/YrSFIXuNO6auJUZIVDG Q==; IronPort-SDR: Po9P9PvycdX9ExbhWAg3UAezC8IcKs416WAMKO1cLR57KWqnlRhP7rqpF3+AWJEUGaVfHQZ77N SyBQbZfCU0L24kE+6x7w/b3C7NwLXWDBpFK4HwuUsbED10MR1E68Y0jqwZxw97pDJPCsy7TBY2 KA8YTOCashF/5xjlalCLspSfnzWs2DY/Ts4aqh4EVpIxXuyzPvaZs07ihUFW9SkvjjagcsAA2E bh4mMYUZfNJ00i1SbrYTH1NXbG6g87Wzc3bHjxb29tBSifsO0E61Zx/Rf8JKI2u8VI1MaSO3Js i54= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243416990" IronPort-SDR: 5S/qM5xJwe+WMPJG2iq33egEkJLmmWKLdoDtGOsYszd3xm2AnsGol6Y5xhml3mf8ZlI+YUts4w 3A1mh44f2wI+JnB8/7yotN86HjG89Q/CI= IronPort-SDR: pX4EIbFiMrPRRMf3mBSgcwb3UHD9NFFIm8ADkfnOn1H7hNqc35sxmQltERG/5aT0DiFBMEOoDH pJNQ+Q9qr/OQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 14/32] riscv/opentitan: Connect the PLIC device Date: Fri, 19 Jun 2020 09:57:59 -0700 Message-Id: <20200619165817.4144200-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/riscv/opentitan.h | 3 +++ hw/riscv/opentitan.c | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index a4b6499444..76f72905a8 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -20,6 +20,7 @@ #define HW_OPENTITAN_H =20 #include "hw/riscv/riscv_hart.h" +#include "hw/intc/ibex_plic.h" =20 #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" #define RISCV_IBEX_SOC(obj) \ @@ -31,6 +32,8 @@ typedef struct LowRISCIbexSoCState { =20 /*< public >*/ RISCVHartArrayState cpus; + IbexPlicState plic; + MemoryRegion flash_mem; MemoryRegion rom; } LowRISCIbexSoCState; diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 011e4f7ee2..835b2c503f 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -26,6 +26,7 @@ #include "hw/riscv/boot.h" #include "exec/address-spaces.h" #include "qemu/units.h" +#include "sysemu/sysemu.h" =20 static const struct MemmapEntry { hwaddr base; @@ -94,6 +95,8 @@ static void riscv_lowrisc_ibex_soc_init(Object *obj) LowRISCIbexSoCState *s =3D RISCV_IBEX_SOC(obj); =20 object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY); + + object_initialize_child(obj, "plic", &s->plic, TYPE_IBEX_PLIC); } =20 static void riscv_lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **e= rrp) @@ -102,6 +105,7 @@ static void riscv_lowrisc_ibex_soc_realize(DeviceState = *dev_soc, Error **errp) MachineState *ms =3D MACHINE(qdev_get_machine()); LowRISCIbexSoCState *s =3D RISCV_IBEX_SOC(dev_soc); MemoryRegion *sys_mem =3D get_system_memory(); + Error *err =3D NULL; =20 object_property_set_str(OBJECT(&s->cpus), ms->cpu_type, "cpu-type", &error_abort); @@ -121,6 +125,14 @@ static void riscv_lowrisc_ibex_soc_realize(DeviceState= *dev_soc, Error **errp) memory_region_add_subregion(sys_mem, memmap[IBEX_FLASH].base, &s->flash_mem); =20 + /* PLIC */ + sysbus_realize(SYS_BUS_DEVICE(&s->plic), &err); + if (err !=3D NULL) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->plic), 0, memmap[IBEX_PLIC].base); + create_unimplemented_device("riscv.lowrisc.ibex.uart", memmap[IBEX_UART].base, memmap[IBEX_UART].size); create_unimplemented_device("riscv.lowrisc.ibex.gpio", @@ -141,8 +153,6 @@ static void riscv_lowrisc_ibex_soc_realize(DeviceState = *dev_soc, Error **errp) memmap[IBEX_AES].base, memmap[IBEX_AES].size); create_unimplemented_device("riscv.lowrisc.ibex.hmac", memmap[IBEX_HMAC].base, memmap[IBEX_HMAC].size); - create_unimplemented_device("riscv.lowrisc.ibex.plic", - memmap[IBEX_PLIC].base, memmap[IBEX_PLIC].size); create_unimplemented_device("riscv.lowrisc.ibex.pinmux", memmap[IBEX_PINMUX].base, memmap[IBEX_PINMUX].size); create_unimplemented_device("riscv.lowrisc.ibex.alert_handler", --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586720; cv=none; d=zohomail.com; s=zohoarc; b=WCVewIIwb6cywz4n5H8hNdZDgGIs6GkHgFvhjVMt6X47XHOsIZwgWoylDnobjIUpkwfyn1lDzIULIzZ3vG1xhDZxckesJEbMQCzIsXv/7D0Is0S4S4vQksmE4a3hTdFrQC4OE+Oune/x1au+lT/Uwjt0PZ40ypDnwOlZZPhPzWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586720; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w/F27CxK0gfgy8Fz/GO9+NOgLT7rdTZTGR4ul163RGs=; b=Y7eBV0uL/b2Oz8PbvNHEwUiS8TVv5r4pfCj7833Uek7VTrqnrDR/b7/Ed2D64ClwUUjGZF5Jm6cXDAtPZCtx/OK0JSP1vGe46KsHJ1E9+Wr+D0R6dkmGGZipeYas3crNqAVgG02DUDp7imafid1O9IOOwMMOOjj96ix+bfwx6J4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586720427609.6047596702683; Fri, 19 Jun 2020 10:12:00 -0700 (PDT) Received: from localhost ([::1]:45034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKYY-0002PQ-VO for importer@patchew.org; Fri, 19 Jun 2020 13:11:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0000gy-8E for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:30 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUB-0004Ps-0k for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:02 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586449; x=1624122449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wj2tmgrLszFAAngO5h43Czzs+HrNQaJZBg5sgRJ6o9o=; b=IaqGSdk2NdnW/StJ2/FD2G2RhVN73n1ne3WHqT/IZ9ziwRRlHixEArpp +GuHyvg1XyJAoCW38yxdkiioX+euzlDXKGxzvSnFFCQypWR8G/gufSq2s eOf7aMfzyArWnWpkr3/Xlxh0EguI1MAV5Q3tEPPpxUVxpGnN2Z8pNRyza oWKs0S9hb2Z5TjYW+QNF6I7GS6zZh2cnIxf+fPmuVzydwFYDe791Ac70Y yLhORaalJqNpv6JQm6rSZ5sPbL1Oc9xCZ+FP7RhtwrOZJvAPKrTzm0xPF qmZMduG+DB3qKnaNhMqgC3ltN9hqHbuhMp/oGHCU78zdIjfV+f9PT1guV Q==; IronPort-SDR: cr8kMIEtWb2yqf3otnzW2HepBQjou9uTykuX5Z8R4v6DDIw8PXKdb64I15rEr9x4B7psRotFB1 Wqhb6U3IP3UBOR67BWUVleguSiSYOnIRpLxZbJ7qn1SJLorsGUlAS1ZXaUV+KeM/AdYUOaVF65 vJeplLo+ZNtiXPg9zfAxrismTjdPtNoPMcSuFt6l+MJ9xphGxPS8uRO/NmR7a+8Z3BTv2RX3K0 KwCWCzu5pY/Rnxh72NuV8AjiAk45tdVabhXDyhuNtT3YT4XnypAQ/0/V/+skGUMuuQ6pSLDXe5 QbI= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243416993" IronPort-SDR: ArbQH3j0SZfzmqNg2u4v3D6wpZ5rKWrsD8MX9TaG/KgvOgwOC+ON8mXKtrWiRWR5++ggdzZacE Ea8+a/ceKdeqdfu00XRgcitxisEb9H7aI= IronPort-SDR: XUe9wYsvwIE4ZqLZs3Y6cDpuM0p2CCF40mZjYwh5pt87v6WW3YdfcMW5+n1dMdf8hGrT1V8seI kAoEeo6pUcfA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 15/32] riscv/opentitan: Connect the UART device Date: Fri, 19 Jun 2020 09:58:00 -0700 Message-Id: <20200619165817.4144200-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/riscv/opentitan.h | 13 +++++++++++++ hw/riscv/opentitan.c | 25 +++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index 76f72905a8..8f29b9cbbf 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -21,6 +21,7 @@ =20 #include "hw/riscv/riscv_hart.h" #include "hw/intc/ibex_plic.h" +#include "hw/char/ibex_uart.h" =20 #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" #define RISCV_IBEX_SOC(obj) \ @@ -33,6 +34,7 @@ typedef struct LowRISCIbexSoCState { /*< public >*/ RISCVHartArrayState cpus; IbexPlicState plic; + IbexUartState uart; =20 MemoryRegion flash_mem; MemoryRegion rom; @@ -68,4 +70,15 @@ enum { IBEX_PADCTRL, }; =20 +enum { + IBEX_UART_RX_PARITY_ERR_IRQ =3D 0x28, + IBEX_UART_RX_TIMEOUT_IRQ =3D 0x27, + IBEX_UART_RX_BREAK_ERR_IRQ =3D 0x26, + IBEX_UART_RX_FRAME_ERR_IRQ =3D 0x25, + IBEX_UART_RX_OVERFLOW_IRQ =3D 0x24, + IBEX_UART_TX_EMPTY_IRQ =3D 0x23, + IBEX_UART_RX_WATERMARK_IRQ =3D 0x22, + IBEX_UART_TX_WATERMARK_IRQ =3D 0x21, +}; + #endif diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 835b2c503f..675ce900bd 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -97,6 +97,8 @@ static void riscv_lowrisc_ibex_soc_init(Object *obj) object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY); =20 object_initialize_child(obj, "plic", &s->plic, TYPE_IBEX_PLIC); + + object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART); } =20 static void riscv_lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **e= rrp) @@ -133,8 +135,27 @@ static void riscv_lowrisc_ibex_soc_realize(DeviceState= *dev_soc, Error **errp) } sysbus_mmio_map(SYS_BUS_DEVICE(&s->plic), 0, memmap[IBEX_PLIC].base); =20 - create_unimplemented_device("riscv.lowrisc.ibex.uart", - memmap[IBEX_UART].base, memmap[IBEX_UART].size); + /* UART */ + qdev_prop_set_chr(DEVICE(&(s->uart)), "chardev", serial_hd(0)); + sysbus_realize(SYS_BUS_DEVICE(&s->uart), &err); + if (err !=3D NULL) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart), 0, memmap[IBEX_UART].base); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), + 0, qdev_get_gpio_in(DEVICE(&s->plic), + IBEX_UART_TX_WATERMARK_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), + 1, qdev_get_gpio_in(DEVICE(&s->plic), + IBEX_UART_RX_WATERMARK_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), + 2, qdev_get_gpio_in(DEVICE(&s->plic), + IBEX_UART_TX_EMPTY_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), + 3, qdev_get_gpio_in(DEVICE(&s->plic), + IBEX_UART_RX_OVERFLOW_IRQ)); + create_unimplemented_device("riscv.lowrisc.ibex.gpio", memmap[IBEX_GPIO].base, memmap[IBEX_GPIO].size); create_unimplemented_device("riscv.lowrisc.ibex.spi", --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586871; cv=none; d=zohomail.com; s=zohoarc; b=JfXnM9p1wXZmPv0u+NcYEzJkiOraSI5KZKY2RQpOSLj73Hid8jRZM2g5BJ18rI+9/Ih52iDMlyq3gEySim5iZC8oz2Bc/oCmLujiKBwSCxca3mCOUhZEPfZjPLGvAplsZZMn0eU+8YEG92LdlRN9IbyFF3wirxl81JaBqX5IDBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586871; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UrMbW0Wsr+uGtTRjpv1sT1DKcKiVwKW289h+OJlov98=; b=lblDXxKrDrOg6DAKAd3jYAXnOR0QUUaH2S+D+aIUaipNkL4jzBI7034LLUPuIaWW0FWfAa4pZJ3VpqNjT5TKaAd5N/a7RmcZPPChTRaEbr9PiLBB+VW2gw4Mj+mFXS4ikuMc8F9piRZzpKWxQCslagL/ai9xszcFBPPE7JUWCbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586871987761.376757229489; Fri, 19 Jun 2020 10:14:31 -0700 (PDT) Received: from localhost ([::1]:58002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKb0-0001A8-Id for importer@patchew.org; Fri, 19 Jun 2020 13:14:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUD-0000g4-MA for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUC-0004Q3-0k for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:29 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:26 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:02 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586450; x=1624122450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=81HMh1gHLXQkIcSglIbxP90s73UN4Lp7ZsuwWeLGYlk=; b=dGxSDty1cWip2XsHIOLvERz/K0SzG6yeArbvur7gh0qHkYLxrTzHnSfw qBCX3qhyKZZtytzueh0Q23icS6VdA1TBuZa1Lex80kvhrwWhAozkA6C0d SC7HDDiTUIpRTg2meZ91trJRXctEJgE0Ui4XukkWGXr1jWIaAUAJXj9rP GA/e4BwlslAsqwc7n6VH+S41tVMIE/8I8InXdm3Fdmp461zWKapdwhRNc AbfTEE+lS6zz3/WF74G+i3x4THTaygWzFLupH9gE3WSJQ0rS86ow/dVHD vJlUaU40MmdpZwstPw8nlBpDwVhD5flw26EBTLAvTH4TodYemUNFhe35j w==; IronPort-SDR: WU8S5MvgT+xIXU0JjsnyhyJHRmgdKspnkYfBb2n/E5qeRqUdiZXOTCui7z2JCEbpNef2N84CYb 1dBoi3ei+A3kjrvWQURamtbPZ/B9gmvjSbvbsCRrqfMdtcZ66tbVUicjQ+upFAfhJZuBXYgZ7K fq6/nsqzJnvciT75xD3Co7LPxVLCmAXBJbpnPQiq7Zf7Oc4iVSzGBT/sNv1WnVlwBJmodVkWUs LlQ2BN/p0+f/1kN4i8rj0mmKeeFyFt/cpLEhpzTLKLNEiD5DRHyART1OfcdEu2Z72DKOQeFKkO d6k= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243416995" IronPort-SDR: r6eGJskz6iMRkve7RjR6KA56/QSe789VlGmmfjSmhnZ0KKUV++EfRlyFstzzoMC/9FY0/DqFWc SArityFtDh00uQLUN/jFP8oypnag/MQZA= IronPort-SDR: kP8VdEr8/OSTHb8AWKYhVJYtLsb0y0ihSBhb3HE2gUDINx4RB+MDjge6evsI5i6v3OdHv0uTau /e3KJycCuIGg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 16/32] target/riscv: Use a smaller guess size for no-MMU PMP Date: Fri, 19 Jun 2020 09:58:01 -0700 Message-Id: <20200619165817.4144200-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/pmp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 0e6b640fbd..9418660f1b 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -233,12 +233,16 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ul= ong addr, return true; } =20 - /* - * if size is unknown (0), assume that all bytes - * from addr to the end of the page will be accessed. - */ if (size =3D=3D 0) { - pmp_size =3D -(addr | TARGET_PAGE_MASK); + if (riscv_feature(env, RISCV_FEATURE_MMU)) { + /* + * If size is unknown (0), assume that all bytes + * from addr to the end of the page will be accessed. + */ + pmp_size =3D -(addr | TARGET_PAGE_MASK); + } else { + pmp_size =3D sizeof(target_ulong); + } } else { pmp_size =3D size; } --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586724; cv=none; d=zohomail.com; s=zohoarc; b=kPv1O07ZopKfldns0tHIfAKxko0mEGTIkob/SpZfmDspPjp5ccW9Mu+onrYslJjIdLguZ6D8zZ1MSNSqrxz7SDSwEzww+pCuoYD2bM6YtubDx7uoYWOJpHTmTFIDKMlE4AcLgt2HW1f+dsoCEiSsL76/8QwTj4+qlCEiuD8hZWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586724; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3OPiM+jEQc0Wv/Olo86dXIsTWi4QmMuLg3l8coL+9aE=; b=CtuDMiFrgjNnuDpizTw/yc0mdOkeVoBwq1yqpIluU1OJ00z9R4NeGtZCXyLcCbEZc6fgQ/d3L/+tygZFW9RvTzRmS7FKuvu1wtMIAI3H4VrK9XqjdES/SlygLjXOhaONfqHnpFjwWGVaaFCiyR1q6WdS2oDVN1+AszsTakylIeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586724830592.3599887408047; Fri, 19 Jun 2020 10:12:04 -0700 (PDT) Received: from localhost ([::1]:45346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKYd-0002bR-HF for importer@patchew.org; Fri, 19 Jun 2020 13:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUF-0000iV-DB for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:31 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUD-0004Pk-EV for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:31 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:26 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:02 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586453; x=1624122453; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MwmhX+QruCR5bliKSXbiubjgtbRSUKmWFEdzq1sWRbI=; b=gowrHUmrmPT4DdocCxvxzeIAztUl61pPRekJpOXy94tqT7FGyUeUvumW icKcvcEY/FeQAVq41If0klcZzvRH9HE/X0QgiTtAh72VC0uiuyy3ZsrMa b+s6HQkRWUs40K3HVCFE3uHDb554YHUaJB4Ha5ug+X+JbUWfzH/3t3Kc9 aQf8Jwh+ELgm/SYXyCDvK2GHOp+ZQsdUzIxocqSsqfyYylTgtdepCcm9f KxWN8w3LyzevOufUzpd0XD4Z6RXknlJMD3a55v7F3G4f9iimDi/spjmlU dVhdxX0tL6jOhhISbrd8wJrDyCqkoIt5NzLet89D6xgTU6gCrOa6bhUan g==; IronPort-SDR: dnBY5G2Zz8vf7uc2lapTXqwYL0ZIuY58pOJYkfzXVHFosrFVH7GIw4trbUzM142z6EXz6cvi8E QPZ+ucfWU7h2tvpUReTSzeD4JDUm402HL3+tsI0VlrwMJtHVnR8x8pkg1GM2XvFAn71plNZXA4 Gcu1M2gMbdBJX/Zr2NoYSlaiVdTXiHBRiI8xyzeLi7wyYquAfhWC/hpO+7tHb4G/0bJtykuQbJ joFfJaGXoMALUPoMj2G1kEklgu+4/mKFyKpQt0zeX2Ep8PGCY8ci00otEj5uiTy9kFKWnTlwlk 48o= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243416997" IronPort-SDR: RXXytb5BPqj34mYwVLTMoQmKpEpf1tgFHfxT57nJ9qgvJ21ZP1l1lW77wwqasuf1lEd64SQAVG MD7Y0qT03lnimfxW/OI9KpGpdNH8akPb0= IronPort-SDR: Al99hpR9yDSAOBFdqEN5ZPZjJHrMI3XsefXbAspR7Zt+3GvlErbMia4l5lxoCs5w6Bap/pcide jqUt7HTgGmtA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 17/32] hw/riscv: sifive_e: Remove the riscv_ prefix of the machine* and soc* functions Date: Fri, 19 Jun 2020 09:58:02 -0700 Message-Id: <20200619165817.4144200-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng This was done in the virt & sifive_u codes, but sifive_e codes were missed. Remove the riscv_ prefix of the machine* and soc* functions. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-2-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-2-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_e.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 36486b72d2..01626820bb 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -75,7 +75,7 @@ static const struct MemmapEntry { [SIFIVE_E_DTIM] =3D { 0x80000000, 0x4000 } }; =20 -static void riscv_sifive_e_init(MachineState *machine) +static void sifive_e_machine_init(MachineState *machine) { const struct MemmapEntry *memmap =3D sifive_e_memmap; =20 @@ -147,7 +147,7 @@ static void sifive_e_machine_class_init(ObjectClass *oc= , void *data) MachineClass *mc =3D MACHINE_CLASS(oc); =20 mc->desc =3D "RISC-V Board compatible with SiFive E SDK"; - mc->init =3D riscv_sifive_e_init; + mc->init =3D sifive_e_machine_init; mc->max_cpus =3D 1; mc->default_cpu_type =3D SIFIVE_E_CPU; } @@ -167,7 +167,7 @@ static void sifive_e_machine_init_register_types(void) =20 type_init(sifive_e_machine_init_register_types) =20 -static void riscv_sifive_e_soc_init(Object *obj) +static void sifive_e_soc_init(Object *obj) { MachineState *ms =3D MACHINE(qdev_get_machine()); SiFiveESoCState *s =3D RISCV_E_SOC(obj); @@ -179,7 +179,7 @@ static void riscv_sifive_e_soc_init(Object *obj) TYPE_SIFIVE_GPIO); } =20 -static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) +static void sifive_e_soc_realize(DeviceState *dev, Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); const struct MemmapEntry *memmap =3D sifive_e_memmap; @@ -262,26 +262,26 @@ static void riscv_sifive_e_soc_realize(DeviceState *d= ev, Error **errp) &s->xip_mem); } =20 -static void riscv_sifive_e_soc_class_init(ObjectClass *oc, void *data) +static void sifive_e_soc_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - dc->realize =3D riscv_sifive_e_soc_realize; + dc->realize =3D sifive_e_soc_realize; /* Reason: Uses serial_hds in realize function, thus can't be used twi= ce */ dc->user_creatable =3D false; } =20 -static const TypeInfo riscv_sifive_e_soc_type_info =3D { +static const TypeInfo sifive_e_soc_type_info =3D { .name =3D TYPE_RISCV_E_SOC, .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(SiFiveESoCState), - .instance_init =3D riscv_sifive_e_soc_init, - .class_init =3D riscv_sifive_e_soc_class_init, + .instance_init =3D sifive_e_soc_init, + .class_init =3D sifive_e_soc_class_init, }; =20 -static void riscv_sifive_e_soc_register_types(void) +static void sifive_e_soc_register_types(void) { - type_register_static(&riscv_sifive_e_soc_type_info); + type_register_static(&sifive_e_soc_type_info); } =20 -type_init(riscv_sifive_e_soc_register_types) +type_init(sifive_e_soc_register_types) --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587240; cv=none; d=zohomail.com; s=zohoarc; b=LB2dc8/KKsJbDeK8WVCBWhmKQO7jsyJRV0ydu0kuTpJ8kbhyGN68LF+9M/h3s5cHwbe0LNYbEqF9k/wPT+MVfW31wlLCBCOEnf8djsjT9Bz4sQDGy2iTvjxSbs/cTr35NSE7W9wVNoBRU013NG2dWRXpYgZ9jBErGBiXuaR+vZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587240; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vEHs/ORKutP5QXIC0H5tejkjUfFJg56cSBF9YuTOMe4=; b=Jwrnf5QQPbMxQOG6S5qdcSfk6DDEvKKWGIQ2w/vxjcrpBClUg9x6cg5JRs0wHxTJ4KUbLHxUuEy6v7d0N7CBZ9xDFr4iurLR3ZMEiO+B6AVLJqPHyFTCL1kc08xcDNx0e2dMQoFdw7bYwSPkDdJ1yI5BIWEyvsR6GtY/RZbMFkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159258724097627.822524407005744; Fri, 19 Jun 2020 10:20:40 -0700 (PDT) Received: from localhost ([::1]:55414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKgx-0004R7-Fs for importer@patchew.org; Fri, 19 Jun 2020 13:20:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUG-0000kQ-D9 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:32 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0004Q3-03 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:32 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:27 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:02 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586453; x=1624122453; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRyEFMliFOazvxi0uiuNB7H49JK+CbFims83EBUndek=; b=HOOuMai8MlpHgr399522zV16bytVIpISJYwhr/J+3WiZVWOad/m/jU/W McNdAP3DIBIrUqQ95fUjvmpVxffwz8Lbb+G50FPtg49fXhaGjyAzDJQ4W R7in5a+S/pp6fOZpOkbk8iuRZYXf3ahMt0tz6GKjwqfFsvAW2H2YTITjs CH9iscnJXT/C96FTNDxVn7/pb9vejkRhxvlUceOLD/bHNuSGMV2XoTud9 X9dv7origunhn8jJl0b1mm1Frb0yo+JJBp67kkA+IO1r028D3zeQSLnA1 wOJrFm4/Y4WwUJcofLAq0xkRaKUrAoQ8qu6EB/lur/I4qPKFaTkzMzyiC w==; IronPort-SDR: Y9ipvCupa62SzXDYAKh1+h5J/AQac/uoTr5kHFc2D7i4rI4DV9OHXGVU+FgfVu3+XwHQ9sQ2LE BtrCSLHxTo2C2MimB0iLBNxdN2TyDzfFQoTkVZeXVXVnHyy3nCyQK+AJP7VgQM2anjF2GCUDxm 0X2tNzM83ERwZ7KCNAu+y3tC3TgJhnOfo40KSZuPr6AZt7o1sJBk2kcoDpr2S2cCcZqlZe76xJ FdbhCYPPHOSfIF8zT0nCXqlhP26APXO0mrpfbmfPRCJ4sLN4JBH32NcuGUC0X0ddeFgV35Kai5 rww= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243416999" IronPort-SDR: NTWeMTPfmNu68y5kAJbn6gpHHJIxfeMgrnWabYYb4r8awmlI3RpnphjUJvUGAtlbwko0qt1FEB iTLNpZ2t6wgkorWi8FywAEGvnDilnfwbw= IronPort-SDR: dYAT47Ubq5wt971yWEOlY6zbwIrEoTNsN/HOziCICJkaScm3EjrrJW5s1MD01ldjxbQ2MajoUL pfBzUcKuaUSw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 18/32] hw/riscv: opentitan: Remove the riscv_ prefix of the machine* and soc* functions Date: Fri, 19 Jun 2020 09:58:03 -0700 Message-Id: <20200619165817.4144200-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng This was done in the virt & sifive_u codes, but opentitan codes were missed. Remove the riscv_ prefix of the machine* and soc* functions. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-3-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-3-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/opentitan.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 675ce900bd..19223e4c29 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -53,7 +53,7 @@ static const struct MemmapEntry { [IBEX_PADCTRL] =3D { 0x40160000, 0x10000 } }; =20 -static void riscv_opentitan_init(MachineState *machine) +static void opentitan_board_init(MachineState *machine) { const struct MemmapEntry *memmap =3D ibex_memmap; OpenTitanState *s =3D g_new0(OpenTitanState, 1); @@ -70,7 +70,6 @@ static void riscv_opentitan_init(MachineState *machine) memory_region_add_subregion(sys_mem, memmap[IBEX_RAM].base, main_mem); =20 - if (machine->firmware) { riscv_load_firmware(machine->firmware, memmap[IBEX_RAM].base, NULL= ); } @@ -80,17 +79,17 @@ static void riscv_opentitan_init(MachineState *machine) } } =20 -static void riscv_opentitan_machine_init(MachineClass *mc) +static void opentitan_machine_init(MachineClass *mc) { mc->desc =3D "RISC-V Board compatible with OpenTitan"; - mc->init =3D riscv_opentitan_init; + mc->init =3D opentitan_board_init; mc->max_cpus =3D 1; mc->default_cpu_type =3D TYPE_RISCV_CPU_IBEX; } =20 -DEFINE_MACHINE("opentitan", riscv_opentitan_machine_init) +DEFINE_MACHINE("opentitan", opentitan_machine_init) =20 -static void riscv_lowrisc_ibex_soc_init(Object *obj) +static void lowrisc_ibex_soc_init(Object *obj) { LowRISCIbexSoCState *s =3D RISCV_IBEX_SOC(obj); =20 @@ -101,7 +100,7 @@ static void riscv_lowrisc_ibex_soc_init(Object *obj) object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART); } =20 -static void riscv_lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **e= rrp) +static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) { const struct MemmapEntry *memmap =3D ibex_memmap; MachineState *ms =3D MACHINE(qdev_get_machine()); @@ -186,26 +185,26 @@ static void riscv_lowrisc_ibex_soc_realize(DeviceStat= e *dev_soc, Error **errp) memmap[IBEX_PADCTRL].base, memmap[IBEX_PADCTRL].size); } =20 -static void riscv_lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) +static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); =20 - dc->realize =3D riscv_lowrisc_ibex_soc_realize; + dc->realize =3D lowrisc_ibex_soc_realize; /* Reason: Uses serial_hds in realize function, thus can't be used twi= ce */ dc->user_creatable =3D false; } =20 -static const TypeInfo riscv_lowrisc_ibex_soc_type_info =3D { +static const TypeInfo lowrisc_ibex_soc_type_info =3D { .name =3D TYPE_RISCV_IBEX_SOC, .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(LowRISCIbexSoCState), - .instance_init =3D riscv_lowrisc_ibex_soc_init, - .class_init =3D riscv_lowrisc_ibex_soc_class_init, + .instance_init =3D lowrisc_ibex_soc_init, + .class_init =3D lowrisc_ibex_soc_class_init, }; =20 -static void riscv_lowrisc_ibex_soc_register_types(void) +static void lowrisc_ibex_soc_register_types(void) { - type_register_static(&riscv_lowrisc_ibex_soc_type_info); + type_register_static(&lowrisc_ibex_soc_type_info); } =20 -type_init(riscv_lowrisc_ibex_soc_register_types) +type_init(lowrisc_ibex_soc_register_types) --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586818; cv=none; d=zohomail.com; s=zohoarc; b=AhBvSFwbwMC4gyGp9wLKG9Uf2hg/zeV4l3irJ4jSuBo68e2DAnzy3VMNhsfICShezpPVW0PKpMUQN1EthTGpyCiGEJF9QcZXioHR/Rk3ifsET5/bqHfsmBc7CtfM/7wdi9RJ89hDvtMcBS9Bv1pytLuk3o0F5XKcplDBKGuzSUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586818; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rv3/BvR5DYXaMaDDEbbjvPpjB9Sgg/v5DCoaHh7ELo4=; b=QUkFVWz8kq/L7WK1vhBHyq6uRMtg+Fd7gA441RK0ZZXPE2w3kCYebZ7m/yq3SIxQKmeJUORA0NhMFqZjfdotiQqPqnO/itxkeZoWRMoWfa82kEXAHY9ab2Stb72Yyu/fCykumyWFnu4L5WX3peGq7dhKpGqzpTST6/fuxRgj5iA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15925868186091006.9486323373496; Fri, 19 Jun 2020 10:13:38 -0700 (PDT) Received: from localhost ([::1]:52718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKa8-0006jG-Gm for importer@patchew.org; Fri, 19 Jun 2020 13:13:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUG-0000l9-Pe for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:33 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUE-0004Ps-IB for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:32 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:27 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:03 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586454; x=1624122454; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HF1JxGXWDSpTRfYKaMM0wJ4es08kDgUw2iC6UdUH7F8=; b=rhia0lgRqwz9Y15Pkh/mIBBCM6eWPdhJtR3YFBcy9qcR+n3r0+ZR8lWt /xTz3zGs4dQZe0HY5AYOX+umW66UWYxE5iXLIirniCSAQqJNLKJuP6KYn V4nwA12udohhrFa6vLkkfdUSCc5sjuvyz7Vx7CUIgOHXzNbGtY8UXHe83 xjjsJlHzJokGaTI0l/cc+sIDmCl4uYr3j27GYwzF2ODqu3m/WkaNcFGTT GBtWm3fdu7v/BejP043vDeLI8mqWUrKSykWQh+tt4BnOCplyV9BRfNSfp h1Iy9JZo6kE2YP11Jzc3w0fKhJImpibMk+H482M4u57MgZobrUq44lGRL g==; IronPort-SDR: KGyOF9kxo90jyrWzV5VQhrsR3CMISo6Iu8qvITnNg3u1Bek60i9Lu+6xRWYTHt7Xn92XSJZd73 SSipozQwrxgxWpbXVeTitFmGP0Mnr9/kTUeP481Nb/T1uiKDAs1kx21DPwY33tY53OovUvVX4/ AZpXxr/kc6PG5oRVIUH1rdLVAzH2+uZauAlUZoIXi2mV7sNULq1u7GYqrAYsixo1Ap3vq3S2bu s+526480XpL9VVLI8xasBI6L+wDOfYcH54K9rQHsxZz7+lzGYmTvfZr8FgkWozrAGRpeb/I0vh zgE= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417001" IronPort-SDR: ypZJUS+aOzYXvOoVLwatp1wO2qpZpRRZ8uAZcJ053SOiu1Ojqvw86EZDU/I3P78tl5nG+2Lgqe UjoMTWm0mII+DWBVtcfRV+h3TNbYjfWZs= IronPort-SDR: bPOAPRcStAC7V+pKVMbBXqHoM8SZyXdp96ZFcMD+NlGaoDbZS8r4LVplLnmggT869DYzPARqRM aA8A4qhON3sQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 19/32] hw/riscv: sifive_u: Simplify the GEM IRQ connect code a little bit Date: Fri, 19 Jun 2020 09:58:04 -0700 Message-Id: <20200619165817.4144200-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng There is no need to retrieve all PLIC IRQ information in order to just connect the GEM IRQ. Use qdev_get_gpio_in() directly like what is done for other peripherals. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-4-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-4-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index ea197ab64f..20b0276ea3 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -514,7 +514,6 @@ static void sifive_u_soc_realize(DeviceState *dev, Erro= r **errp) MemoryRegion *system_memory =3D get_system_memory(); MemoryRegion *mask_rom =3D g_new(MemoryRegion, 1); MemoryRegion *l2lim_mem =3D g_new(MemoryRegion, 1); - qemu_irq plic_gpios[SIFIVE_U_PLIC_NUM_SOURCES]; char *plic_hart_config; size_t plic_hart_config_len; int i; @@ -594,10 +593,6 @@ static void sifive_u_soc_realize(DeviceState *dev, Err= or **errp) sysbus_realize(SYS_BUS_DEVICE(&s->otp), &err); sysbus_mmio_map(SYS_BUS_DEVICE(&s->otp), 0, memmap[SIFIVE_U_OTP].base); =20 - for (i =3D 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) { - plic_gpios[i] =3D qdev_get_gpio_in(DEVICE(s->plic), i); - } - if (nd->used) { qemu_check_nic_model(nd, TYPE_CADENCE_GEM); qdev_set_nic_properties(DEVICE(&s->gem), nd); @@ -611,7 +606,7 @@ static void sifive_u_soc_realize(DeviceState *dev, Erro= r **errp) } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem), 0, memmap[SIFIVE_U_GEM].base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem), 0, - plic_gpios[SIFIVE_U_GEM_IRQ]); + qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_U_GEM_IRQ)= ); =20 create_unimplemented_device("riscv.sifive.u.gem-mgmt", memmap[SIFIVE_U_GEM_MGMT].base, memmap[SIFIVE_U_GEM_MGMT].size); --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586735; cv=none; d=zohomail.com; s=zohoarc; b=WdklBBcfkKWumsnsqgsdyf40q1ItKk82Sm4iYyFBvfTVWCNAJv5Dgv/eBGsd9FnFAeOSP2Amfu01qnXsk9iRpT46uEmThyzH9hWyEWnR4CYWmh7sN2KqLsey8kdrtocoEO+81hI9ODQORU68yNr1uS+e6x3wfxNRyQpneVZnMzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586735; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9gfSA/0vp9w3uTLoC+f0ScVZTNz4GYiv7PQ2C7Hz8yg=; b=Ar+9BEwuFV8Bv1BLerUJj2/slGATVu9fy9PyynfvaEC/aBdpOWGiJ+dyjh+iRTAonKCVa8SS8GSOMfF2HlJjl7w78uDcXkIz7RbUv3Yj+YCjQ1XcKszIDWdyGRIWjgq48SDmV+wHXgTu8zFdlj/u8sSiO8VMhvCTvoGF6y+pFAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586735067468.84359075230896; Fri, 19 Jun 2020 10:12:15 -0700 (PDT) Received: from localhost ([::1]:45614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKYn-0002nJ-Ra for importer@patchew.org; Fri, 19 Jun 2020 13:12:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUM-0000qN-DY for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:39 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUF-0004Pk-Ld for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:38 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:27 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:03 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586456; x=1624122456; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dMdIIDoCv7W8aOLzjHKqNqNnPV7covUPMRH4EMqR6ec=; b=VO/FtQjWbqVoqNBHl3ljvpysi/gR2EKDJOzZqjnecx5D7QygQf06beuo jVzoCC9zF/USv38lAwERzjxAmeKILUzEArlatNBZyttC1gKBgKAPiB9V3 DmS+3TEriISspEKYCp9txdrJ9Ur//bH3+itb9vmbtbP2+Lx1kId8qwjhA 1Hqn8ZatarsBKuIV+FLqifc3o5jppI8aBG/tF3DfGRX2I8nEMYSRN78c/ xpt1N71Xku3tNwARhEKDwhiogCY+cwOkkCC12og8tF7HkpIAbsxOAqXO/ AkXwikGDiF6cw9fEwKruDH9qE2DcI43h+G6sMRAmzUz04AJ1fbBud6iq0 Q==; IronPort-SDR: mRrwEKAmWDORzXLQG6jL9uYe5e9c06SWN8vJIgQ/r+SjiC2o5Sq9kTg+A3N75qK/+CE+9lhG1m NChX9if8k7njuRD56hQIlGuTIQExs3GLIjIBEYmf22h5U+lExyA6bGfz4Ume1na4+3Z44Jnca8 X6xQpw8dlpLkiLeve2MPKOlz/I0X61H4uXTDxW9zMUz3C1eb7EUsQA5DQabl2KIZopAId8C79i m+G2Fy8q1iiJxxxc9Vtal2+TDyeVRXZNE1ywgIbyJuLiR6nEnULxN4E8v2kij4LI2Lb5flyeod pMw= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417003" IronPort-SDR: Avgnrck5NOHTymscd4ti83DHdpP6mYa8CMBWFqAegM+tAMDrl2kCeuN1/cbswKQCQihkzFmCuX DrHZklQVHb4mVIxb8KTqaIhZyS3hc+rxc= IronPort-SDR: FSR5p7C+wVa6RzhHe+IX2VX+pOzUeISzcc0dL+h00/YAaxlAulpVWr+w0ebOFbY01AfJ51wCJu 9hk6KPJax+Vg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 20/32] hw/riscv: sifive_u: Generate device tree node for OTP Date: Fri, 19 Jun 2020 09:58:05 -0700 Message-Id: <20200619165817.4144200-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Upstream U-Boot v2020.07 codes switch to access SiFive FU540 OTP based on device tree information. Let's generate the device tree node for OTP. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-5-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-5-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 20b0276ea3..a6dfce4273 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -207,6 +207,17 @@ static void create_fdt(SiFiveUState *s, const struct M= emmapEntry *memmap, g_free(cells); g_free(nodename); =20 + nodename =3D g_strdup_printf("/soc/otp@%lx", + (long)memmap[SIFIVE_U_OTP].base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "fuse-count", SIFIVE_U_OTP_REG_SI= ZE); + qemu_fdt_setprop_cells(fdt, nodename, "reg", + 0x0, memmap[SIFIVE_U_OTP].base, + 0x0, memmap[SIFIVE_U_OTP].size); + qemu_fdt_setprop_string(fdt, nodename, "compatible", + "sifive,fu540-c000-otp"); + g_free(nodename); + prci_phandle =3D phandle++; nodename =3D g_strdup_printf("/soc/clock-controller@%lx", (long)memmap[SIFIVE_U_PRCI].base); --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587280; cv=none; d=zohomail.com; s=zohoarc; b=bsgx8+uIuQCes9teUidsASQzPic6XAJT8pv9xpiHDNhXLDqeSjnnvxJwMIJOP2uuJWqBdn/rjvBTANxQUSgHv05iD4Da9PGapo9dihiRxN4WXs5hBo8fqFeYBRQevrMsP0x9zYv52Gm8AKVhVPbhRYETYCuHf72zXDJVtnm734o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587280; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c1CZTaF6JHcZKsdtyUdmB1bOhLoZwEjYE0yVCM/Yk78=; b=BvAnvGIo5irG5tU40HCuCJWM+W8rt6UHpo/KhcFsnqiHVf4pnjexX2mKbuNB8ZHGdDUS/9q0uILs5CUpd2c8RGNDQQl0IGyZ7WH3ttfcYKSxH/JOY/jYLjDd0+cnar3iCJwB+i3lyMpSsyhIQFZflcOubZki1qreTQ2grrgGmeo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587280212979.7143226298407; Fri, 19 Jun 2020 10:21:20 -0700 (PDT) Received: from localhost ([::1]:58660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKha-00060f-NM for importer@patchew.org; Fri, 19 Jun 2020 13:21:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUO-0000rg-4E for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:41 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUG-0004Q3-LY for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:39 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:28 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:03 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586457; x=1624122457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4Ag3dG3gO5iJShtsvDkPTUJzzzPAJlVfRVRDsoWCqx0=; b=o2Iur9HPwTx3NLtSqBxYLv36RtWuF03Zdow6BwiBQvIRBXaO6OsXMFPd Us9S2rZ8D5XptPK7FzNk2p44ApWQl5DOicJBeD2a6gXClI1zpdItMWWte KcWTm2aVX18ukhfkrULgQtsdg2PwToWDP5nuIiJA8IH3LNBcxXUMGrFAD muaVIAHkVCyO7X0cyrpZJBRY8CP0NdrUtZ3h98RRzystYxbi8aktFTUUk 6H4EgvEcGPRN2405VBBOsah6dHCz3r9BoGitMF1KqdNYxdLZO+WJPEywr eAvP9tAvMI0tw1INU7S1CaaaIKb92t6appwcbM6MhNJLMgzN55ht21m3J Q==; IronPort-SDR: 2wbGMnErFY+zQZSHyMbkR+Z1PxetB0QEK00+3NcSWqzwCrbismtUcniUn4k4qK9uUngG9r1h5O AV63LpgSxjXrO5eL4mcuLZxDbyFClyFF70X6NyP+e2lL+3r1AA8wTGtZDgaQVcfO+YSvyIwlTy 6JVRxgcUyzZZr61mlgMTQrWVKqoX+we+f8B6EEHPFJvyseywPlmAUs8A/1ivnkJOEpinU8s41Z jOW19rvsCthxYmY2FfijUKJ8yJXfY9LYrinBBVvLIhHTyJMFTi7ZAbVldYHR/FzB9RDHED/vvO 6ZY= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417005" IronPort-SDR: qDC0zaLiwgNKKviT3xufOVTbF+WPMvVIfPMJ1uyNIbNhvKW0LZjpqgoEKbFo8D/6vRXVIE4OF7 Ml+kSQv1+ciN6z5vu+GmlPnfDhGTYh6/w= IronPort-SDR: hQnxKYaYSn3YmJsSWkuJgVikTNj0fyt72a8/9DSKuONaPINRdMsMSGRr2lwdi0DAV3yxb32ViS AjWaeLYvpwkw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 21/32] hw/riscv: sifive_gpio: Clean up the codes Date: Fri, 19 Jun 2020 09:58:06 -0700 Message-Id: <20200619165817.4144200-22-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Do various minor clean-ups to the exisiting codes for: - coding convention conformance - remove unnecessary blank lines - spell SiFive correctly Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-6-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-6-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_gpio.h | 7 ++++--- hw/riscv/sifive_gpio.c | 13 +++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/hw/riscv/sifive_gpio.h b/include/hw/riscv/sifive_gpio.h index fce03d6c41..ad915b26d6 100644 --- a/include/hw/riscv/sifive_gpio.h +++ b/include/hw/riscv/sifive_gpio.h @@ -1,5 +1,5 @@ /* - * sifive System-on-Chip general purpose input/output register definition + * SiFive System-on-Chip general purpose input/output register definition * * Copyright 2019 AdaCore * @@ -10,10 +10,12 @@ * This code is licensed under the GPL version 2 or later. See * the COPYING file in the top-level directory. */ + #ifndef SIFIVE_GPIO_H #define SIFIVE_GPIO_H =20 #include "hw/sysbus.h" + #define TYPE_SIFIVE_GPIO "sifive_soc.gpio" #define SIFIVE_GPIO(obj) OBJECT_CHECK(SIFIVEGPIOState, (obj), TYPE_SIFIVE_= GPIO) =20 @@ -66,7 +68,6 @@ typedef struct SIFIVEGPIOState { uint32_t out_xor; uint32_t in; uint32_t in_mask; - } SIFIVEGPIOState; =20 -#endif +#endif /* SIFIVE_GPIO_H */ diff --git a/hw/riscv/sifive_gpio.c b/hw/riscv/sifive_gpio.c index 5c7c596e6b..c9cffa2eba 100644 --- a/hw/riscv/sifive_gpio.c +++ b/hw/riscv/sifive_gpio.c @@ -1,5 +1,5 @@ /* - * sifive System-on-Chip general purpose input/output register definition + * SiFive System-on-Chip general purpose input/output register definition * * Copyright 2019 AdaCore * @@ -20,7 +20,6 @@ =20 static void update_output_irq(SIFIVEGPIOState *s) { - uint32_t pending; uint32_t pin; =20 @@ -186,7 +185,7 @@ static uint64_t sifive_gpio_read(void *opaque, hwaddr o= ffset, unsigned int size) } =20 static void sifive_gpio_write(void *opaque, hwaddr offset, - uint64_t value, unsigned int size) + uint64_t value, unsigned int size) { SIFIVEGPIOState *s =3D SIFIVE_GPIO(opaque); =20 @@ -318,7 +317,6 @@ static void sifive_gpio_reset(DeviceState *dev) s->out_xor =3D 0; s->in =3D 0; s->in_mask =3D 0; - } =20 static const VMStateDescription vmstate_sifive_gpio =3D { @@ -342,8 +340,8 @@ static const VMStateDescription vmstate_sifive_gpio =3D= { VMSTATE_UINT32(iof_en, SIFIVEGPIOState), VMSTATE_UINT32(iof_sel, SIFIVEGPIOState), VMSTATE_UINT32(out_xor, SIFIVEGPIOState), - VMSTATE_UINT32(in, SIFIVEGPIOState), - VMSTATE_UINT32(in_mask, SIFIVEGPIOState), + VMSTATE_UINT32(in, SIFIVEGPIOState), + VMSTATE_UINT32(in_mask, SIFIVEGPIOState), VMSTATE_END_OF_LIST() } }; @@ -356,7 +354,6 @@ static void sifive_gpio_init(Object *obj) TYPE_SIFIVE_GPIO, SIFIVE_GPIO_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); =20 - for (int i =3D 0; i < SIFIVE_GPIO_PINS; i++) { sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq[i]); } @@ -371,7 +368,7 @@ static void sifive_gpio_class_init(ObjectClass *klass, = void *data) =20 dc->vmsd =3D &vmstate_sifive_gpio; dc->reset =3D sifive_gpio_reset; - dc->desc =3D "sifive GPIO"; + dc->desc =3D "SiFive GPIO"; } =20 static const TypeInfo sifive_gpio_info =3D { --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586845; cv=none; d=zohomail.com; s=zohoarc; b=bZF3zYZENyO8wgFbSWT7s/4eYX+rZFbOxCL68JQxqWO/i+dj+rQf6wNTbGHWMOGVuaxYqBlhS68RVs8bHRPH1vQYs8p6igIHmlEISYiwHV2X+AhHKHiO0FSSwXUtsHx88/7MTE1tVngFQJ8zp6+CzvP/ixaLUHyX7eSncg2qurs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586845; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FT36KvY/1yycKLn9dxQvuVKd8qHg6lJ6sjZhD/Hmf5M=; b=WPn7FeFeCplcGKsQ869aS9xAkUa6bpTfnfTmPd92OjcDIo9fEp4+lE7Q29Obp5zFSCLj9P98SBk4fasv4eSoRr6saKMHHqiw7xdHvMNNwT0ZO9aMCD9ioztjhz26FG7r+42P3sd6cqgiPTBbX7esizQphCg5QDm1u3Sl1xwuxFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586845516419.83393854872236; Fri, 19 Jun 2020 10:14:05 -0700 (PDT) Received: from localhost ([::1]:55380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKaa-0008C9-5N for importer@patchew.org; Fri, 19 Jun 2020 13:14:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUN-0000qk-9T for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:39 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUH-0004Ps-8A for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:38 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:28 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:03 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586458; x=1624122458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oPLJE6KNzWJHMq3vdNFTZOYl4tq3PNDGEUzIW+NYt6w=; b=msg7rmZUeywedDCNSzZNarK1dTE0biOSgHtOhoxINYSfPL7AV92jhqtx VIFc9tf/LSUmBqroIVBz0MTL1/BmglZn3hrxuPHtsjbCIMehXlzXi/y02 TPTuh7xyh5d8y3Oxv2hpX4FeraRNPYW3mKdtJBbsegDFYAdQwMUI6Izzj sGaGH406u9r6hExJXsjq9LMaJrpw7Km/HCm2GTiNv68230RZmDqbS6YxV 4eJBsYKTLCWleV6JWOt+z6FPNnL1TcRMW3OcJ0GGZG6aUWB4r6+azeO8y vPAMynwBOVqR8z/c+wXs572Sgu+pepRiJvaX48AY3s/oeXIiT0gN1HPu2 A==; IronPort-SDR: qYS1kLBW/isHgeHtXzsW6CFm/w21SLd6sW6RQUeIJZE4T31H6Ib22oDPL4GFD6S0fTMEoRCimr 55wlkHp/4npN6vYBuiNoK98KBV73r0FWhrae9X/UrC66xxY1mzKvRRNIEU8xPYT1weeUF669Ye DFwl/eZ75jc8DeeOE8WQgIXGVSopHSqhcudl3/vvpIg5KGiVjqjWkd2NERacQr8sn22BAQlpuv IlQ5myB2pNZjJlQAbzsE1Fjtv5kG5gZA2zYJYBGa9sBx2fNv4dox57cqqGSCC13FXCQg2/i/VX x0A= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417007" IronPort-SDR: E62XRyNfRXlvkN8oWxTo6mhMPG1CtROk66TX3Jam2XmJt948NLqDpodf/xlDvOFS9mSNR0h/iq yaUq6W6ev83yIlDCz2iql/OkspJsWwC14= IronPort-SDR: IL3tNfyim1hKFCi9NsZDOLE/GJGY911phuibiJqFnWRuSxtvKVzEWaf+q9wOYnddXim6azv8zA 66A9xUUjf/kg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 22/32] hw/riscv: sifive_gpio: Add a new 'ngpio' property Date: Fri, 19 Jun 2020 09:58:07 -0700 Message-Id: <20200619165817.4144200-23-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Add a new property to represent the number of GPIO pins supported by the GPIO controller. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-7-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-7-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_gpio.h | 3 +++ hw/riscv/sifive_gpio.c | 30 +++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/hw/riscv/sifive_gpio.h b/include/hw/riscv/sifive_gpio.h index ad915b26d6..cf12fcfd62 100644 --- a/include/hw/riscv/sifive_gpio.h +++ b/include/hw/riscv/sifive_gpio.h @@ -68,6 +68,9 @@ typedef struct SIFIVEGPIOState { uint32_t out_xor; uint32_t in; uint32_t in_mask; + + /* config */ + uint32_t ngpio; } SIFIVEGPIOState; =20 #endif /* SIFIVE_GPIO_H */ diff --git a/hw/riscv/sifive_gpio.c b/hw/riscv/sifive_gpio.c index c9cffa2eba..0d0fd2ba5e 100644 --- a/hw/riscv/sifive_gpio.c +++ b/hw/riscv/sifive_gpio.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" #include "hw/irq.h" +#include "hw/qdev-properties.h" #include "hw/riscv/sifive_gpio.h" #include "migration/vmstate.h" #include "trace.h" @@ -28,7 +29,7 @@ static void update_output_irq(SIFIVEGPIOState *s) pending |=3D s->rise_ip & s->rise_ie; pending |=3D s->fall_ip & s->fall_ie; =20 - for (int i =3D 0; i < SIFIVE_GPIO_PINS; i++) { + for (int i =3D 0; i < s->ngpio; i++) { pin =3D 1 << i; qemu_set_irq(s->irq[i], (pending & pin) !=3D 0); trace_sifive_gpio_update_output_irq(i, (pending & pin) !=3D 0); @@ -41,7 +42,7 @@ static void update_state(SIFIVEGPIOState *s) bool prev_ival, in, in_mask, port, out_xor, pull, output_en, input_en, rise_ip, fall_ip, low_ip, high_ip, oval, actual_value, ival; =20 - for (i =3D 0; i < SIFIVE_GPIO_PINS; i++) { + for (i =3D 0; i < s->ngpio; i++) { =20 prev_ival =3D extract32(s->value, i, 1); in =3D extract32(s->in, i, 1); @@ -346,27 +347,35 @@ static const VMStateDescription vmstate_sifive_gpio = =3D { } }; =20 -static void sifive_gpio_init(Object *obj) +static Property sifive_gpio_properties[] =3D { + DEFINE_PROP_UINT32("ngpio", SIFIVEGPIOState, ngpio, SIFIVE_GPIO_PINS), + DEFINE_PROP_END_OF_LIST(), +}; + +static void sifive_gpio_realize(DeviceState *dev, Error **errp) { - SIFIVEGPIOState *s =3D SIFIVE_GPIO(obj); + SIFIVEGPIOState *s =3D SIFIVE_GPIO(dev); =20 - memory_region_init_io(&s->mmio, obj, &gpio_ops, s, + memory_region_init_io(&s->mmio, OBJECT(dev), &gpio_ops, s, TYPE_SIFIVE_GPIO, SIFIVE_GPIO_SIZE); - sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); =20 - for (int i =3D 0; i < SIFIVE_GPIO_PINS; i++) { - sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq[i]); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); + + for (int i =3D 0; i < s->ngpio; i++) { + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[i]); } =20 - qdev_init_gpio_in(DEVICE(s), sifive_gpio_set, SIFIVE_GPIO_PINS); - qdev_init_gpio_out(DEVICE(s), s->output, SIFIVE_GPIO_PINS); + qdev_init_gpio_in(DEVICE(s), sifive_gpio_set, s->ngpio); + qdev_init_gpio_out(DEVICE(s), s->output, s->ngpio); } =20 static void sifive_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 + device_class_set_props(dc, sifive_gpio_properties); dc->vmsd =3D &vmstate_sifive_gpio; + dc->realize =3D sifive_gpio_realize; dc->reset =3D sifive_gpio_reset; dc->desc =3D "SiFive GPIO"; } @@ -375,7 +384,6 @@ static const TypeInfo sifive_gpio_info =3D { .name =3D TYPE_SIFIVE_GPIO, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(SIFIVEGPIOState), - .instance_init =3D sifive_gpio_init, .class_init =3D sifive_gpio_class_init }; =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587385; cv=none; d=zohomail.com; s=zohoarc; b=GziHSPtU1nI8cmq36h8bzS8+AM/oW8ftYQBNNQO8wx/Zn58kb7xAMEu48PM3WJRidY5xBE4MXNWTHjqWFvRBB1b/TtpK2hbAIxX1D2aroYSN2+MJ5HzGmtdhqmksxG5ViDSBc5mBNSnQs+WfbqmO3TdQDqwoSXuI/XMJkzI12z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587385; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m0pNiNxM6+qvq9rJGWLyjTjYzVYI6EUrUZFXuMt5zbs=; b=mq1cK8meJSBHZuZAvA069xF/dU+apwJ19/mtsTHJfUuTbGAA8QbBTh8pSbnwDDQRINRkEE8liTkz/0TY4tU523Qaz7hMXVHYznPaDDMOIACDJC8IshEjcZkIMJg6OETC2k+SF68R/EYNt3SwMQnk5SEwLdt2p9HtVOPRFv0UK44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587385005625.7109870165567; Fri, 19 Jun 2020 10:23:05 -0700 (PDT) Received: from localhost ([::1]:39096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKjH-00024M-OY for importer@patchew.org; Fri, 19 Jun 2020 13:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUQ-0000sx-74 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:42 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUM-0004Pk-UO for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:41 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:28 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:04 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586467; x=1624122467; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OkbSeEt8d4QhxTt7wrMb8feZC4BTffnkVC2ibOszsG4=; b=J+s8JWS4X9ovmbQqQgqOt4952dwCZglA4p/zL3+NJ2KtAFe0+Ok1p/Wx m0ybNmMMJkwOAe+qjM+8n+o5zNQT+t/m8nFOqFI8Z+rTkIY2T2zRj/dt2 EgWpMw+DBSnyHctxsvCUB8YM80ExMuZpQUaq1zIzaa2SofFuFa0W+sdTT dhZhcTZIO4FySks0YEnIiP5KgMjcMx5Tzy8ZzW7FqkZQTZJCahaG9jjki UUFsyeR+Ngd5OopMiMfUmLScqOY3dEuFozxGLSu6sABfVj3bpJmzfvGeU UJA90F9CYjdi9/E1MY0ONYmwZc7w5N2HTeAWLwBrM4VfaWyvR6IGMGWn5 Q==; IronPort-SDR: yDtaU66bVJydsFjeXjrRSk+/exb17VdFvxQmr3YItG7TCLMH7aqQj/kIcRXzBcMbxHg+Tdop19 Szauclo6u1mRKwE2cqKJALhpCatXfulljzCviz/3Q2xSNnv026EVrVxk5Nki3ZID+QltTRsxxQ SH1WL9zRSujvyF9Kmqbw2BfKI7nNlaY7XBTKASslFTMg0MyPl3WEpnqlyqhKQYTs78V04qiJkS cmCL428QPuQpIrnQUui0wSBSBaZWrzpIkgt1sC9efc6WiIDDvlsP3VIEq+NqiQR9tpoaRj9xlB aa4= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417009" IronPort-SDR: PSZPz3K7H8uALh8i2rQHDTI1/rYaBj0ct9PpRmS96RxFLNs9Nz+dQkemdJ1n9gXx3P3PHcDU6i zbqxYBw9ys5LmtQLOl2Dgdq5U9oQuutgI= IronPort-SDR: 7wKwWrh92ZdJ4OOW8T2ycI/DnDvHP0SUWZy70E31VIeO6qxTWG556g5vIBAC6H0gewXgROZKdb 5wTXhgFxx+GQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 23/32] hw/riscv: sifive_u: Hook a GPIO controller Date: Fri, 19 Jun 2020 09:58:08 -0700 Message-Id: <20200619165817.4144200-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng SiFive FU540 SoC integrates a GPIO controller with 16 GPIO lines. This hooks the exsiting SiFive GPIO model to the SoC, and adds its device tree data as well. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-8-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-8-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_u.h | 19 ++++++++++++++++ hw/riscv/sifive_u.c | 43 +++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 5f62cf5f85..b1399a90a6 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -22,6 +22,7 @@ #include "hw/net/cadence_gem.h" #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_cpu.h" +#include "hw/riscv/sifive_gpio.h" #include "hw/riscv/sifive_u_prci.h" #include "hw/riscv/sifive_u_otp.h" =20 @@ -40,6 +41,7 @@ typedef struct SiFiveUSoCState { RISCVHartArrayState u_cpus; DeviceState *plic; SiFiveUPRCIState prci; + SIFIVEGPIOState gpio; SiFiveUOTPState otp; CadenceGEMState gem; =20 @@ -73,6 +75,7 @@ enum { SIFIVE_U_PRCI, SIFIVE_U_UART0, SIFIVE_U_UART1, + SIFIVE_U_GPIO, SIFIVE_U_OTP, SIFIVE_U_FLASH0, SIFIVE_U_DRAM, @@ -83,6 +86,22 @@ enum { enum { SIFIVE_U_UART0_IRQ =3D 4, SIFIVE_U_UART1_IRQ =3D 5, + SIFIVE_U_GPIO_IRQ0 =3D 7, + SIFIVE_U_GPIO_IRQ1 =3D 8, + SIFIVE_U_GPIO_IRQ2 =3D 9, + SIFIVE_U_GPIO_IRQ3 =3D 10, + SIFIVE_U_GPIO_IRQ4 =3D 11, + SIFIVE_U_GPIO_IRQ5 =3D 12, + SIFIVE_U_GPIO_IRQ6 =3D 13, + SIFIVE_U_GPIO_IRQ7 =3D 14, + SIFIVE_U_GPIO_IRQ8 =3D 15, + SIFIVE_U_GPIO_IRQ9 =3D 16, + SIFIVE_U_GPIO_IRQ10 =3D 17, + SIFIVE_U_GPIO_IRQ11 =3D 18, + SIFIVE_U_GPIO_IRQ12 =3D 19, + SIFIVE_U_GPIO_IRQ13 =3D 20, + SIFIVE_U_GPIO_IRQ14 =3D 21, + SIFIVE_U_GPIO_IRQ15 =3D 22, SIFIVE_U_GEM_IRQ =3D 0x35 }; =20 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index a6dfce4273..f6976a0d09 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -11,8 +11,9 @@ * 1) CLINT (Core Level Interruptor) * 2) PLIC (Platform Level Interrupt Controller) * 3) PRCI (Power, Reset, Clock, Interrupt) - * 4) OTP (One-Time Programmable) memory with stored serial number - * 5) GEM (Gigabit Ethernet Controller) and management block + * 4) GPIO (General Purpose Input/Output Controller) + * 5) OTP (One-Time Programmable) memory with stored serial number + * 6) GEM (Gigabit Ethernet Controller) and management block * * This board currently generates devicetree dynamically that indicates at= least * two harts and up to five harts. @@ -75,6 +76,7 @@ static const struct MemmapEntry { [SIFIVE_U_PRCI] =3D { 0x10000000, 0x1000 }, [SIFIVE_U_UART0] =3D { 0x10010000, 0x1000 }, [SIFIVE_U_UART1] =3D { 0x10011000, 0x1000 }, + [SIFIVE_U_GPIO] =3D { 0x10060000, 0x1000 }, [SIFIVE_U_OTP] =3D { 0x10070000, 0x1000 }, [SIFIVE_U_FLASH0] =3D { 0x20000000, 0x10000000 }, [SIFIVE_U_DRAM] =3D { 0x80000000, 0x0 }, @@ -268,6 +270,28 @@ static void create_fdt(SiFiveUState *s, const struct M= emmapEntry *memmap, g_free(cells); g_free(nodename); =20 + nodename =3D g_strdup_printf("/soc/gpio@%lx", + (long)memmap[SIFIVE_U_GPIO].base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cells(fdt, nodename, "clocks", + prci_phandle, PRCI_CLK_TLCLK); + qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", 2); + qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0); + qemu_fdt_setprop_cell(fdt, nodename, "#gpio-cells", 2); + qemu_fdt_setprop(fdt, nodename, "gpio-controller", NULL, 0); + qemu_fdt_setprop_cells(fdt, nodename, "reg", + 0x0, memmap[SIFIVE_U_GPIO].base, + 0x0, memmap[SIFIVE_U_GPIO].size); + qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_GPIO_IRQ0, + SIFIVE_U_GPIO_IRQ1, SIFIVE_U_GPIO_IRQ2, SIFIVE_U_GPIO_IRQ3, + SIFIVE_U_GPIO_IRQ4, SIFIVE_U_GPIO_IRQ5, SIFIVE_U_GPIO_IRQ6, + SIFIVE_U_GPIO_IRQ7, SIFIVE_U_GPIO_IRQ8, SIFIVE_U_GPIO_IRQ9, + SIFIVE_U_GPIO_IRQ10, SIFIVE_U_GPIO_IRQ11, SIFIVE_U_GPIO_IRQ12, + SIFIVE_U_GPIO_IRQ13, SIFIVE_U_GPIO_IRQ14, SIFIVE_U_GPIO_IRQ15); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,gpio0"); + g_free(nodename); + phy_phandle =3D phandle++; nodename =3D g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); @@ -515,6 +539,7 @@ static void sifive_u_soc_instance_init(Object *obj) object_initialize_child(obj, "prci", &s->prci, TYPE_SIFIVE_U_PRCI); object_initialize_child(obj, "otp", &s->otp, TYPE_SIFIVE_U_OTP); object_initialize_child(obj, "gem", &s->gem, TYPE_CADENCE_GEM); + object_initialize_child(obj, "gpio", &s->gpio, TYPE_SIFIVE_GPIO); } =20 static void sifive_u_soc_realize(DeviceState *dev, Error **errp) @@ -600,6 +625,20 @@ static void sifive_u_soc_realize(DeviceState *dev, Err= or **errp) sysbus_realize(SYS_BUS_DEVICE(&s->prci), &err); sysbus_mmio_map(SYS_BUS_DEVICE(&s->prci), 0, memmap[SIFIVE_U_PRCI].bas= e); =20 + qdev_prop_set_uint32(DEVICE(&s->gpio), "ngpio", 16); + sysbus_realize(SYS_BUS_DEVICE(&s->gpio), &err); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, memmap[SIFIVE_U_GPIO].bas= e); + + /* Pass all GPIOs to the SOC layer so they are available to the board = */ + qdev_pass_gpios(DEVICE(&s->gpio), dev, NULL); + + /* Connect GPIO interrupts to the PLIC */ + for (i =3D 0; i < 16; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), i, + qdev_get_gpio_in(DEVICE(s->plic), + SIFIVE_U_GPIO_IRQ0 + i)); + } + qdev_prop_set_uint32(DEVICE(&s->otp), "serial", s->serial); sysbus_realize(SYS_BUS_DEVICE(&s->otp), &err); sysbus_mmio_map(SYS_BUS_DEVICE(&s->otp), 0, memmap[SIFIVE_U_OTP].base); --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587451; cv=none; d=zohomail.com; s=zohoarc; b=QgH07KmKUWN4RVt05GNPvnC07zxLm5jdPPrNw5139egWEFPf9biBlkV2z3S+NOi4V48roBamqOK4pX+25OQGc8DgrbeY4oX7afofZkKTVGENFm9PP1vLjnBytdiTzFVWn8AMufAlye6Z0RaqGCDk64rG8agsnjDkhf85UNjrw4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587451; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i/vLity0V9YN+k6N8WRaXbR9bRMqoLPKSArdx7hMqyc=; b=aY+EwhGDwI39obaZ/R214G+hh2ioFlYbBOu2S5L3uaMx+MPkM22iWLRzqyaKx9TQFCaDpFb0buLRqInxVwAeoz9RPuzVaExlACUnvl68H+9cmAHh8qAZhSlQ4tjRSNYzg+2pYTE0VuQtYlt+VHnomYqaQGAZ/6zZ6bcKWaEw9Qo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587451136824.0697549514327; Fri, 19 Jun 2020 10:24:11 -0700 (PDT) Received: from localhost ([::1]:43058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKkL-0004XF-W0 for importer@patchew.org; Fri, 19 Jun 2020 13:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUQ-0000ui-TH for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:42 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUN-0004Ps-Qc for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:42 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:29 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:04 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586468; x=1624122468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=awiPom2MLm4GSUph2K8Os6CU9vKiSvuIpuRuIMNfHzs=; b=Wiud7yBrj4QtFNn/8QFcuvHgrvWbXa+gJaZOcnSD1wc7Bi/GXQNXMswx D2Bp5HLzGzbpmxUFPLK7hdbgxw3UAHwPq5Ikn93pduB6WjwaNPEdd3n+t pm2A52iQtwgvl3gl1QCbNh9IVSA1Y6H+iQ4mv1Frt3CEZVlWuevpwv4gz g+inFV+b4S9O2EAH11htCNDzWo5QEfue5pEljpLyPkN9FnlyiBrSe/m8Q z1lHqdBQ8Z7kjGhZ6XyGG+GpS7pePFE1MStvOueV+ODZ6A/Zr6pWeXXlt G8+ecpzRF7HjU5DBMofWZwVMm1zyKvi/5Vfhln9p8wBL+kL68f2LfHrUK A==; IronPort-SDR: D3SzsxhkntV8jQMxiKGY2xwPVcc147raH2PNC3Oig7cLD1QsNi50/Zc56xaUk5WYLL/y1xXttO l1IMx6DtEABAeLVQm/2rFPxxOBPDu6dnOrWUMUtau0ygmtQ+sV/Zyz/OdES+HQiR/NCML2MOzp I+N5wjgrvXNT5cyF9nySHRyLzgxnVw/6cRvZMR86BvVqrXWykXiARcZ7HzTz/1bkTAwZlTlciO HDdg4gdKexaTgkaUKYH5cTmR27wBiF0tc7EA8x/RbtomHFAR+t6KB8BJPZn3fp+g1/FyodSqN1 3Mo= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417012" IronPort-SDR: Gbdt2w1RBiaEWpwP1wFdrJG1TL9g74AE4viYJsDnMh42xm3odZ6vSmiFvwG0J6cB/7WKJvhPqg eDF8VhNTYUUFOGCNFKsQHp1D59HuwbUfM= IronPort-SDR: bWhma3ycjeD7EZVFJguWugMJAPaMigYkcXp1FcLRv74xmyzecFlKIC/Jt7BbdQ8qUTCc+v2/cj iGEo1SbJY/bA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 24/32] hw/riscv: sifive_gpio: Do not blindly trigger output IRQs Date: Fri, 19 Jun 2020 09:58:09 -0700 Message-Id: <20200619165817.4144200-25-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng At present the GPIO output IRQs are triggered each time any GPIO register is written. However this is not correct. We should only trigger the output IRQ when the pin is configured as output enable. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-9-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-9-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_gpio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_gpio.c b/hw/riscv/sifive_gpio.c index 0d0fd2ba5e..aac6b44cac 100644 --- a/hw/riscv/sifive_gpio.c +++ b/hw/riscv/sifive_gpio.c @@ -76,7 +76,9 @@ static void update_state(SIFIVEGPIOState *s) actual_value =3D pull; } =20 - qemu_set_irq(s->output[i], actual_value); + if (output_en) { + qemu_set_irq(s->output[i], actual_value); + } =20 /* Input value */ ival =3D input_en && actual_value; --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587562; cv=none; d=zohomail.com; s=zohoarc; b=NoNZW1j9fq1vg8Uj3esv4x089y/V20vHGimfNhUZU7/tmeQWmoneNTvi/Uc8smuToxvHN2CwscNJWaBX4uJtGMnZVVGrhGygfmsSvw9dYjHFCRIt5WPLDyt6Wv5W476PyKkAKc5Cc0HvCbhw/hR7z8Fdm/IT5nmOpE4+v1ZwMYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587562; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zcp7Kvfx6NV18ZOJnCuyaS9iFGIUeGFtlAr8E29E2a8=; b=nWyiKWTD+0wC1V5E3zEUUCA4I2kU6o/q5EzTjvONznMjvwkrGF7Tt+D+swcL5SZENl8B4CI9V0SMzQLrz948yQXWwuqZqaMPpAYzuCDXvrGtWv2KrtiKTdkpSPKnuiRAgWpsmFMNOYOdDkeKauSfHHUEbL8mt2SBjH4TNGUuSXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587562588808.1245030858187; Fri, 19 Jun 2020 10:26:02 -0700 (PDT) Received: from localhost ([::1]:50750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKm9-0007sX-E9 for importer@patchew.org; Fri, 19 Jun 2020 13:26:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUa-0001Id-SQ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:52 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUY-0004Q3-E6 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:52 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:29 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:04 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586484; x=1624122484; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yU1w/2ChxleBtSEiU9l9Zar9wc4r3sXiHuSdviJAICw=; b=fxBe6v2mpSIGdomDtuoI023z24K+IVOek0gW3uK0q4+7vHe2OEuxi9oH hvUxFa8+mlzRwMTMghbJoJmH5oGn0NkcK6PEt3h+CDORbb2TOnzCjkQcn RR/pt0BkmyaTy5vD7qUojCMj4T8KxYxTrW+KVk7GkmSBh85YybwQu7cSD Af0hxLTx+9H7QQELLgHAE33sLu3Vp/Su9/JQaRcArQ0UG/F9FEPrx/rg8 bDs54pZ80rbGLCx/kC5i4BJxHcYsNIQY7MMvT6NA0cDNudQrLoM9+2k4N IHiV/1RsIB63PsKHphrB52rCGuBM8f6hEi/qPKNd54mYmGKBGAm19sHAl Q==; IronPort-SDR: xUEMIt5R7iE/0W+sqPALi11K7dN172vNkwLK+hSKKUrdiATomN+IH4klAk0OHMqFTTNc7RZXk3 A7TJmrNY+f1ecoWuWG/uio+teIcsMgqBNeEiXtcth9nc1ZW0pHhPBg77JE1QAHkhzhl8DjXp6Z YgkNdjclVLdroMujKTbUU2b0JZyAiEGb0pmZj6d436r8BN4SAI+DF1IFEkQWD8uvBKs9L5ENlG pngiC8EvCMbFz+KRk+0q2gRKwHPXGjnb7dMK2y1+98qs/0ycMxYV8ZDOU5XbQ5qY6C8UTU0L+b KTc= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417015" IronPort-SDR: iAW9UzpACxic6iGpNa8SFixZ7LoEIWU7SQ4R+HyeCo7OgGiVy2UBP367Mu1msxRR4ReNo0g3Ru ExLinvgj18wnnGz5vvNRh1nFDL5Jznr8s= IronPort-SDR: SRLQiOiflX7rtXFmDepbmU0DKVEAdZkfcC3ef2lOwidwoDknxX1uUHB+DC8XYc3wpWfTdj71qq a5zq1Ulhgmkw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 25/32] hw/riscv: sifive_u: Add reset functionality Date: Fri, 19 Jun 2020 09:58:10 -0700 Message-Id: <20200619165817.4144200-26-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng The HiFive Unleashed board wires GPIO pin#10 to the input of the system reset signal. Let's set up the GPIO pin#10 and insert a "gpio-restart" device tree node so that reboot is now functional with QEMU 'sifive_u' machine. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-10-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-10-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index f6976a0d09..b9d2185c04 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -37,6 +37,7 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "hw/boards.h" +#include "hw/irq.h" #include "hw/loader.h" #include "hw/sysbus.h" #include "hw/char/serial.h" @@ -53,6 +54,7 @@ #include "net/eth.h" #include "sysemu/arch_init.h" #include "sysemu/device_tree.h" +#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" =20 @@ -96,7 +98,7 @@ static void create_fdt(SiFiveUState *s, const struct Memm= apEntry *memmap, uint32_t *cells; char *nodename; char ethclk_names[] =3D "pclk\0hclk"; - uint32_t plic_phandle, prci_phandle, phandle =3D 1; + uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle =3D 1; uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle; =20 fdt =3D s->fdt =3D create_device_tree(&s->fdt_size); @@ -270,9 +272,11 @@ static void create_fdt(SiFiveUState *s, const struct M= emmapEntry *memmap, g_free(cells); g_free(nodename); =20 + gpio_phandle =3D phandle++; nodename =3D g_strdup_printf("/soc/gpio@%lx", (long)memmap[SIFIVE_U_GPIO].base); qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", gpio_phandle); qemu_fdt_setprop_cells(fdt, nodename, "clocks", prci_phandle, PRCI_CLK_TLCLK); qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", 2); @@ -292,6 +296,12 @@ static void create_fdt(SiFiveUState *s, const struct M= emmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,gpio0"); g_free(nodename); =20 + nodename =3D g_strdup_printf("/gpio-restart"); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cells(fdt, nodename, "gpios", gpio_phandle, 10, 1); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "gpio-restart"); + g_free(nodename); + phy_phandle =3D phandle++; nodename =3D g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); @@ -352,6 +362,14 @@ static void create_fdt(SiFiveUState *s, const struct M= emmapEntry *memmap, g_free(nodename); } =20 +static void sifive_u_machine_reset(void *opaque, int n, int level) +{ + /* gpio pin active low triggers reset */ + if (!level) { + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + } +} + static void sifive_u_machine_init(MachineState *machine) { const struct MemmapEntry *memmap =3D sifive_u_memmap; @@ -380,6 +398,10 @@ static void sifive_u_machine_init(MachineState *machin= e) memory_region_add_subregion(system_memory, memmap[SIFIVE_U_FLASH0].bas= e, flash0); =20 + /* register gpio-restart */ + qdev_connect_gpio_out(DEVICE(&(s->soc.gpio)), 10, + qemu_allocate_irq(sifive_u_machine_reset, NULL, = 0)); + /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587622; cv=none; d=zohomail.com; s=zohoarc; b=V3fOAjZ4yLFr9cx3enxRaD8iSIdrSOk2wEPyI5OZdEpb/27WQrIgq1IhRuLtqoh0WRu+vpWW0Cb1jcMEPEzFBcWfG4zdudms87Zsvgpw6t7Ye/N2z0RNXinOdeeJNGdw2ZE6k+H2cQT7EvFX0WaX+gkaneWfDF5pPfeAfs6Rl64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587622; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ysD8/g+ioSPRAPN6wH0hK6skRlMrmH/jr02gzJugKhY=; b=c+3l/nuGcE+qAhWBZOIcVip5INg36u6bjJr6Ne2RmyEvLpTfp069xsKijOE2eE9OypaymPPw+lgV5RUFSXIe0M/OFuz/HIFKS3GIFkNfGZqHpZaGzFvDXBu+wWxIqwpI3hq1Px4CxMVa4dvJNRDDJF2sfHY7LyQ+Ba9dyieXDrc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587622597846.3598795731779; Fri, 19 Jun 2020 10:27:02 -0700 (PDT) Received: from localhost ([::1]:53792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKn7-0000ih-Da for importer@patchew.org; Fri, 19 Jun 2020 13:27:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUc-0001M2-9q for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:54 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUa-0004Pk-EZ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:53 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:29 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:04 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586487; x=1624122487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YgHV8IgDygqAPja2o6Anh1ZZN76opAAD7h7m5VTQjuM=; b=oub3hitlXHc392ULyuYxypvr10Z2o33ALlu4d9yXTOOKHJRwPiFTgojB xFA8wlb7dIngzo18KmAoEevkkaQ6DbyKFHfpR92+C5Dn83RxnI7aIML4u +ZzlGcl7fcHjK5hzpZguQmgQJOenf/fqi8YANh7P1xHXDzaXe4sXhfx02 BrjaZc+AfgUV8bODTAg2tlYh/Fn+CFjNLQPM6hp+e6JA2b8NwqpTlqJDI j6SV4dY5EoRBwsjH5oWku5oGjSrrH3xcCmHzO9xkRfeoM2m700uwudV4z txGo/LV72rCquZFgURmVBzUjrJpZLAMiHrh8oxVzMxwv4ILPEq0BVe8wg A==; IronPort-SDR: nQoK3gu3H0ad085IDV6LScN35LcPRJPAcOgW9jo1cVtr/0yVBiD/6Hx1B40bKyfcC7/kraU9up 5ySnzwCaF9eAd2wRWrEHsqTi6WLJNabMoxOxng9BkNwIwQUTPa429+ltIKQZkvMBuyFBwzrsJz gGdZi+HmJv8jg7LsJz+1Pur+nu4QzRlQgheChPb5H7ApG3DhUW43dW6UOSsE2UJJAbiaI/+Ekw zQyzB58OG9+SwJ2yGygaf5ouaSJUEr1HgwczDhyEA6NiIJBTZptfk146Uh94kWmV2c+GhG9nhX Bwg= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417016" IronPort-SDR: d8AhczbrTEBRxSKb28ssFGiD0CIFLldYF9MsyzMax3Gty7FbxHP8d3BRyMqo2vRr/QJ0avRZie 6mE05X46gcXt81oj3f5tRKqRhz4DkWbCo= IronPort-SDR: pH4TmANHb9en0o7TqnaM46rqBg/7X/3xYXElVfCoJ7B6d0VHtsjP346PhYrLBLshIkWqR4jLPq S6Ig4YqjJvbQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 26/32] hw/riscv: sifive_u: Rename serial property get/set functions to a generic name Date: Fri, 19 Jun 2020 09:58:11 -0700 Message-Id: <20200619165817.4144200-27-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng In prepration to add more properties to this machine, rename the existing serial property get/set functions to a generic name. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-11-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-11-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b9d2185c04..6dac662910 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -478,14 +478,16 @@ static void sifive_u_machine_set_start_in_flash(Objec= t *obj, bool value, Error * s->start_in_flash =3D value; } =20 -static void sifive_u_machine_get_serial(Object *obj, Visitor *v, const cha= r *name, - void *opaque, Error **errp) +static void sifive_u_machine_get_uint32_prop(Object *obj, Visitor *v, + const char *name, void *opaqu= e, + Error **errp) { visit_type_uint32(v, name, (uint32_t *)opaque, errp); } =20 -static void sifive_u_machine_set_serial(Object *obj, Visitor *v, const cha= r *name, - void *opaque, Error **errp) +static void sifive_u_machine_set_uint32_prop(Object *obj, Visitor *v, + const char *name, void *opaqu= e, + Error **errp) { visit_type_uint32(v, name, (uint32_t *)opaque, errp); } @@ -504,8 +506,8 @@ static void sifive_u_machine_instance_init(Object *obj) =20 s->serial =3D OTP_SERIAL; object_property_add(obj, "serial", "uint32", - sifive_u_machine_get_serial, - sifive_u_machine_set_serial, NULL, &s->serial); + sifive_u_machine_get_uint32_prop, + sifive_u_machine_set_uint32_prop, NULL, &s->serial= ); object_property_set_description(obj, "serial", "Board serial number"); } =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586851; cv=none; d=zohomail.com; s=zohoarc; b=nXAn4NAO3dpsgxZPryiigIGAITjQ5d5TntBYrt1xFMPmbLjH7ofVZZkjwmBiQDU/+t74tg4vq75HuXTF5hhJfnMhG24ACxAEfpnE05wM7fpWgJSTrsHAQIlJ/CPhly3byUuok26pFBfd6GSFATaXJYiKUO3THvZITYf/E+z18bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586851; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5n1DRQXSJ9ax3nVNL8XKWya21IZCIM5FVqJfhvSzRhE=; b=hO0s9AVzJCzqZ74+z1h/Y3WUpoaB2ouIJkjwQ1TcqDsZTBV+KPoTvBr8mkQvlQUZPhetjmmie/iu/XzgTukWIzbfy6bSL+b7oVPUbIuLWUHAnQStQcYN+pc5YY/WGPUl3xAIMepSDIkp1lCDcVvmI6XP+Rm9UhIq1yJln2E53Ic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586851368383.97523226548196; Fri, 19 Jun 2020 10:14:11 -0700 (PDT) Received: from localhost ([::1]:56010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKag-000057-0i for importer@patchew.org; Fri, 19 Jun 2020 13:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUd-0001Nl-7f for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:55 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUb-0004Ps-7c for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:07:54 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:30 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:05 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586489; x=1624122489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3BNyEnS/wqJC6Kgxw6ca4gmdTiZrgKGEhDv3YvYD+r0=; b=QAgu3rlzcu+5BjNjBp4wVvqVJDyDDNnMwe5xMmBU5c2fSncI9XbV8Qq9 HnslRy35W8/dffqxXW/unHBTMJVLhOYzJgJYQLOLW1/yNTIxXwSLyZudJ MEa1fwx6j9Yq7RM6oHQP/0o+ft3unCU2IXkQUq7d8Xr9uSITIJ3Yl/2j6 eSYpqx89Za0C9EQC2qhqE8+LC7uURMibhK0PIqv4HmKENu0vwdqXJNtzt eKcZ2pQc8LZL8cGL/uk/5wY2wuDhSFzuSdUEPJYMehibfHWqPycIGv2eH 1SCr2yk79evru8fCwo7a5CxO/+ru/q1xOIOVHxu1UBOBPLF+ZkR22ynZB A==; IronPort-SDR: 27pWBI0J4FXazzkZzEoA4h/q35kuQqTE/fwX3gVqBgruTnrkOFhjbABSCMLbPaq4H41rxHehSG 00L07rMl50cUYqZGFE0x7j5xna3GgkwjsR/xMmHJie4AZOGEe+P3gO5s3xnLDBHDPPIA9vpSW8 E9M9Ynuqoispfa6yz+QkjCi3k3dU5cMnAhXD2jYqU9eJiN1yBNm/aNkmGpOrioxsG/JkpypFSL KGx1Z/xaztaXbAYV1gHN2E6P53dStfntgFrfJDFwA18T9DRDJ1ZAzkunSrtdS3e0mHWoHPvZqj US8= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417017" IronPort-SDR: VYkmsg4snV6szQ/K9Zcc398bCjNFX7viu1Wk1YpTo1/f82364xPkHwing2G9WDRDc1jVAYcQFr M70VTL9LhkXbf/JhaEqicaOgSIAtYBfzM= IronPort-SDR: OpeClm3pfqXOOErKkYP22v42QvPEWXCLuM6q/08jhyccUAsEK85kOPKZCagmwCLpWFHKnUesXC nCTx8LcZXibg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 27/32] hw/riscv: sifive_u: Add a new property msel for MSEL pin state Date: Fri, 19 Jun 2020 09:58:12 -0700 Message-Id: <20200619165817.4144200-28-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng On SiFive FU540 SoC, the value stored at physical address 0x1000 stores the MSEL pin state that is used to control the next boot location that ROM codes jump to. Add a new property msel to sifive_u machine for this. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1591625864-31494-12-git-send-email-bmeng.cn@gmail.com Message-Id: <1591625864-31494-12-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_u.h | 1 + hw/riscv/sifive_u.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index b1399a90a6..f6d10ebfb6 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -63,6 +63,7 @@ typedef struct SiFiveUState { int fdt_size; =20 bool start_in_flash; + uint32_t msel; uint32_t serial; } SiFiveUState; =20 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 6dac662910..b04be42167 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -504,6 +504,13 @@ static void sifive_u_machine_instance_init(Object *obj) "Set on to tell QEMU's ROM to jump to " "flash. Otherwise QEMU will jump to DR= AM"); =20 + s->msel =3D 0; + object_property_add(obj, "msel", "uint32", + sifive_u_machine_get_uint32_prop, + sifive_u_machine_set_uint32_prop, NULL, &s->msel); + object_property_set_description(obj, "msel", + "Mode Select (MSEL[3:0]) pin state"); + s->serial =3D OTP_SERIAL; object_property_add(obj, "serial", "uint32", sifive_u_machine_get_uint32_prop, --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587723; cv=none; d=zohomail.com; s=zohoarc; b=FcNNJmdwajezmgDAjySl7OT3pPXb4+YcfIuFJ+UFfwxFvvQnQ1ktA3hc1q5z/5xujc3Ai6PBC5VbkzPl8Z2cxHOqacEG6anz7XatlSZAeif7HbA9LOZp8hAARJQ5nXAWqixH6mMM4WSdpnwFpzSZD35ua1LhxZlyi1MJ3NlSjUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587723; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qmdJhu2l7OAPEcUkT0+BZbilmgtY49SGTMU3MHuOMT4=; b=kcNAcvfRBUHNY4LeoA8+Vu0wd5Z2G9sQhHgjv8s/tIgRWQkuHJdLTK3pIKlQK44XMHwXtYaDylYphVucbugDH9U8gbMMFtmtfI1tFhrR2LN3NteGJIiU9/0PU/EGPUxYj1rePWVqn7ufqH6URjdpLajWtRq7Xq4EXbJFLr/SFAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587723780556.3948106592469; Fri, 19 Jun 2020 10:28:43 -0700 (PDT) Received: from localhost ([::1]:59440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKok-000344-FO for importer@patchew.org; Fri, 19 Jun 2020 13:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUm-0001lB-V3 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:04 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUl-0004Q3-4x for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:04 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:30 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:05 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586504; x=1624122504; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mNUxJaBqscecrc5iYSnB5gf7mz+p8sMw9gNqAnpXd2M=; b=M9hyhgG338vwwudBOd8egHYDVM7ZapHlv6DSmQn8HQUDfOpsvcP4DfTk WDVm9hKDkOUOB7FFau1oRB5t2dcUOnDdbTqUsCJUcX/sFarSy6ugS8Yk+ 0CT8/z4HQjp2cuya8FW9//GQJtwXLMtwTERFRkNIkN34HdlR9mZnERYyg Tw8j662OTa13qsITO7xpzeEwZdKQ7FTse52nL4O8ABFt08FgLS0NYUK6o fyEIoUzDTmMh9I1FSa3ttJ18H4pFFJ8m+78mF4g5CTqhjHTXWxXZBIOH9 S6ZXkw09NDAboy/aJ+qB/AgQgbCJ8DYn4gkFZEWW1dgPyOxswC1c/I8mR A==; IronPort-SDR: is6wj0Qnp94Akq2OvB9xy2kZd9NzhG7ecWlsno1miOnqajZ0QdjZ/DXp72i4p9VO+YVy+8/9LJ a54AQlcygzJFbyK0H4J0zof1zLYFkrVwhA/Z9TlD17iCLIeLdxMzOww0HlXuw/yoCAebfjgSsM DibpDU1UuWGunZmt7DvE45P6Hy1EOp8TE5GFdvvf1QviW46HYKYpYb92PY1TwkP30U9ikTzTb3 238+lFYYbVEPADcaS416k4wXcFAM7VdQQW+pVkdA8Ag6OkgzCQMqb2FIdMxfX3e6U4tdroHcBe IL8= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417018" IronPort-SDR: eOrFYqMV2CPwS02EuE14M1wAnHckxwPAcSHMWzHJohaoBQsFgexC5yyZV5Fs5pac4H1Be0Ey21 6NJ1ByAa3WAOAT5fxvUy0t+G09nU0bihg= IronPort-SDR: 57eTFWrET4M8r4VoY8A6+MK96EopGp3RWdekN/x7NU4VkYZo+SS+Ibv3zpviMDrxn1v2ttGSd3 bC8EJMLcnzFQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 28/32] target/riscv: Rename IBEX CPU init routine Date: Fri, 19 Jun 2020 09:58:13 -0700 Message-Id: <20200619165817.4144200-29-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Current IBEX CPU init routine name seems to be too generic. Since it uses a different reset vector from the generic one, it merits a dedicated name. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1592268641-7478-2-git-send-email-bmeng.cn@gmail.com Message-Id: <1592268641-7478-2-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e867766cf0..5f034588ec 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -153,7 +153,7 @@ static void rvxx_imacu_nommu_cpu_init(Object *obj) =20 #if defined(TARGET_RISCV32) =20 -static void rv32_imcu_nommu_cpu_init(Object *obj) +static void rv32_ibex_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; set_misa(env, RV32 | RVI | RVM | RVC | RVU); @@ -577,7 +577,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), #if defined(TARGET_RISCV32) DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32_imcu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32_ibex_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rvxx_imacu_nommu_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32_imafcu_nommu_cpu_init= ), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_gcsu_priv1_10_0_cpu_i= nit), --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587794; cv=none; d=zohomail.com; s=zohoarc; b=D+LncUI6UajG+frHzVnJ6Fg8oY0mcAFiV1Z/BH9046ierf+64X02Y+58gT+Pvr01FUrs8FJ66SK441IrebNMidfP+uEG6cHDqm8zrCCpUNtunxC1TuTDD0IZ91YN3pLurliyTme+HO9q8Sa1eFaiOoB5aXra2H/IP+XarSMK5bE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587794; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z2/3FwZ/H/fibJnWNKv1KuMz0rqCicWg7JbXhcN/R6Y=; b=maH4ZjwHxzOeEqzwUrVTdkAwmxVBVUcHu3Uj4Ez5rrMYXZU+m7OMQq69LMgVAMRdN3WV+kFuteOVL+nNQuVtuUrbMXhBe23MAWEvNTRzRL0zi/Grs4KHZDw3hxPGeYwqE1ZE232CROMOMNeEeNk5tSMbhTPngZCGFyeFG5ipZXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15925877946641014.9598658376668; Fri, 19 Jun 2020 10:29:54 -0700 (PDT) Received: from localhost ([::1]:35518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKpt-0004ug-HR for importer@patchew.org; Fri, 19 Jun 2020 13:29:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUo-0001ny-Ih for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:06 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUm-0004Pk-Kp for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:06 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:31 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:05 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586506; x=1624122506; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G/iOs6farnNl/qXC6bQwZ8DLkLUv1s/70S5FD6K0SuY=; b=WNZsf1ZxYqnM/kji81T75+cpCuyoequA2NmwWJ5ybiXNCkaTXUdj+Dw4 tpaaHgB55KToot5CF21pC1ck0TokZVx0JkAjQ/XHoNUK411beTU0E/OLq 2jeV0r0lgF57FTVldGMvjci66TZGZKQu0RXzK6Z0b+uh62S8ij2WZNH8C 98prJiRjYMBWvE4JZotp68PLdBUAhz1B0dG41Ww4b1V3f6OE8ALjwlJQr DIxyRBeWHer0eihk4JE2d+MlIRK811UGOirYEBS1Gl3okk8SrVsoqHFkE bI7B6GVp+/skOcLFiGSpGQ4HQRJTOtqae/KCBHozY0bmbjtA6N3U+awM+ w==; IronPort-SDR: ZuzRqqt0WIlF0Zz5WzU9GKzq8DDD3R+gdEqsO9uBtMlXajKqSf/KFTzuyHiu9F7SJlbVidq4Vv K0IG+iSNd+nYBH+2BxuL41omRSz0eQyANIY2rBqTw7ehnLxm6W9Pm52vn8PEmxF1TxxW0k4uT8 cnd1ICg+RjnnpHThwNpkIqgYQ/qTViEHhxIc+ISwceKaPLNw/h+KFI/0+bB+MSzBGP7p/djDVU vppcGhCoTrLveh9TSiunLIbwCF0PXjkkoi7hwuuwUYR/nxuNGpSu3UJdMkXTy4DOzkucr34Oov h1E= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417019" IronPort-SDR: tpv7y/8DYjmZ50X0WXBHZzeFxyi4nKxSV+x4hAUhcOTEn8SFIWB3FEHSCBGXxkGlUpGD46BgwI XQI52v/3rYLY9SbamzHAKOl9XzLKN9TKw= IronPort-SDR: acATbtYKyb9h422MO005J3j/nzAATxPzBS1WVjcOLCumoTTOxdf7D0p9bEicQKc6QAjniG7BqP d2+s/5IHylOw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 29/32] hw/riscv: sifive: Change SiFive E/U CPU reset vector to 0x1004 Date: Fri, 19 Jun 2020 09:58:14 -0700 Message-Id: <20200619165817.4144200-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Per the SiFive manual, all E/U series CPU cores' reset vector is at 0x1004. Update our codes to match the hardware. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1592268641-7478-3-git-send-email-bmeng.cn@gmail.com Message-Id: <1592268641-7478-3-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_e.c | 10 ++++++---- hw/riscv/sifive_u.c | 6 +++--- target/riscv/cpu.c | 16 ++++++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 01626820bb..0cb66ac4e2 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -95,14 +95,16 @@ static void sifive_e_machine_init(MachineState *machine) memmap[SIFIVE_E_DTIM].base, main_mem); =20 /* Mask ROM reset vector */ - uint32_t reset_vec[2]; + uint32_t reset_vec[4]; =20 if (s->revb) { - reset_vec[0] =3D 0x200102b7; /* 0x1000: lui t0,0x20010 = */ + reset_vec[1] =3D 0x200102b7; /* 0x1004: lui t0,0x20010 */ } else { - reset_vec[0] =3D 0x204002b7; /* 0x1000: lui t0,0x20400 = */ + reset_vec[1] =3D 0x204002b7; /* 0x1004: lui t0,0x20400 */ } - reset_vec[1] =3D 0x00028067; /* 0x1004: jr t0 */ + reset_vec[2] =3D 0x00028067; /* 0x1008: jr t0 */ + + reset_vec[0] =3D reset_vec[3] =3D 0; =20 /* copy in the reset vector in little_endian byte order */ for (i =3D 0; i < sizeof(reset_vec) >> 2; i++) { diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b04be42167..ed13bc043c 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -430,18 +430,18 @@ static void sifive_u_machine_init(MachineState *machi= ne) =20 /* reset vector */ uint32_t reset_vec[8] =3D { + 0x00000000, 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */ - 0x02028593, /* addi a1, t0, %pcrel_lo(1b)= */ + 0x01c28593, /* addi a1, t0, %pcrel_lo(1b)= */ 0xf1402573, /* csrr a0, mhartid */ #if defined(TARGET_RISCV32) 0x0182a283, /* lw t0, 24(t0) */ #elif defined(TARGET_RISCV64) - 0x0182b283, /* ld t0, 24(t0) */ + 0x0182e283, /* lwu t0, 24(t0) */ #endif 0x00028067, /* jr t0 */ 0x00000000, start_addr, /* start: .dword */ - 0x00000000, /* dtb: */ }; =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5f034588ec..391a0b9eec 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -134,20 +134,20 @@ static void riscv_base_cpu_init(Object *obj) set_resetvec(env, DEFAULT_RSTVEC); } =20 -static void rvxx_gcsu_priv1_10_0_cpu_init(Object *obj) +static void rvxx_sifive_u_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, DEFAULT_RSTVEC); + set_resetvec(env, 0x1004); } =20 -static void rvxx_imacu_nommu_cpu_init(Object *obj) +static void rvxx_sifive_e_cpu_init(Object *obj) { CPURISCVState *env =3D &RISCV_CPU(obj)->env; set_misa(env, RVXLEN | RVI | RVM | RVA | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); - set_resetvec(env, DEFAULT_RSTVEC); + set_resetvec(env, 0x1004); qdev_prop_set_bit(DEVICE(obj), "mmu", false); } =20 @@ -578,13 +578,13 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { #if defined(TARGET_RISCV32) DEFINE_CPU(TYPE_RISCV_CPU_BASE32, riscv_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_IBEX, rv32_ibex_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rvxx_imacu_nommu_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E31, rvxx_sifive_e_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E34, rv32_imafcu_nommu_cpu_init= ), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_gcsu_priv1_10_0_cpu_i= nit), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U34, rvxx_sifive_u_cpu_init), #elif defined(TARGET_RISCV64) DEFINE_CPU(TYPE_RISCV_CPU_BASE64, riscv_base_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rvxx_imacu_nommu_cpu_init), - DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rvxx_gcsu_priv1_10_0_cpu_i= nit), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rvxx_sifive_e_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rvxx_sifive_u_cpu_init), #endif }; =20 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592586957; cv=none; d=zohomail.com; s=zohoarc; b=TWTZdQamOpetw7bqULsaLSn+yl0NoWYkDbXfE2rSG+WtkctTND1Tz93yYtuvI/086VvHwH3bMPvwuhMJDXG+ZFtjig6uA67ofG9YpU5FeytiWBoclS9UR9NrFw5Ph260GcPGx4mejkVpKDjBkATcW/EjYuZu+ueIwz20ypn5Rak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592586957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=65KGS0NdjC+d0G0C99LVSlM4bBOF0UkybiaiX+FYciM=; b=gJp0vFgaw7gx/BJFYstFKFXqmkU1UxbawyXGZK8h9XXydOHRurs1sewZHH9VVhDlDDe7OQmSbCe3u6bFkoeh5NCoSuPRGuenM98TW6QMcO4h8bHcEvb4QXQQ56la+RAxIY/2ki2kvoaPgnQNTQ1Vkc2LUUxSON6sx9RV0SpCD20= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592586957324968.4475166397319; Fri, 19 Jun 2020 10:15:57 -0700 (PDT) Received: from localhost ([::1]:36288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKcN-0004AE-0G for importer@patchew.org; Fri, 19 Jun 2020 13:15:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUq-0001r8-CV for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:08 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUn-0004Ps-ET for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:07 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:31 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:05 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586507; x=1624122507; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l12nKCebLDNm8crHR5U10P9+ehRAVHXDgPahy6nhwdg=; b=AHwvbOvHip1sMEh5IDe705+CiIE/3H+lD4UTTifofTep4Op29tvTW+Ul OEKHbykuwXknEwmW1JPXHQzHra9x1lXLGVAXkhr6fosvS87b5lef1A0fq 3eRb1N/2cL9QjKv9ZloYlLAMd9vv7+0b/gxyO00i81LXGfHHHQ6fgQ6Wn ltFW1FO5z8NAbQYm2rcuF21iIiV4kepKbOvnu+CkhYaQglCkxXSWxXc3w xApFBEhG7ODthhHHTA63jfIf749niYM2Asb5U3qa6MpLwF+lomBJlvqzc PVQVpDGFdAZmFGWSb8slmJRaHoFdGZmJj2P3FbpvDTBjcjBGqOjGu6fvf A==; IronPort-SDR: +uNRTvNFAOKqISOJs6+VK3BxJHwBEVBSGEsqnY8onyA9+xvw1oEv0OR/FWH6H9NXZeSeXwzWvM K/5cEnKwXsju5W8MyQqpP2xtLzLWB8xEjs9jf+dPtuEuqzqvG7TW7zFhB8WFtypn7HRe/ssGM9 aF6IVwX+aaQ0xsvurW6Z6jbj1wvX2anTynv6vW52OZszP/GS8N0eKYBsvZ4ld2vIYUYAUftoBp U2w71jXfPXVE3bxYYl+AOYQifUPxCQkEnnOaHdjFh5BrLG6dvNl7wE6j1S21u1vbZzfLzuXeq3 WCg= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417020" IronPort-SDR: CgRQBp62ptm6LjyKv9H1inJJIeJHm6c503LVyF37+Glu6dAV1PeZ1QHB+L1HONWut+G5znHlVb F3gXqBWc8APurm8VdLyaGZzqAXLDS17pI= IronPort-SDR: BP7TMIBBijXalVdU7P2rM0X9oBeAWiLNiuvGeWLshLrDBdjWI19FGlZ/lTaPQMQnnhiSWCvRxX Rr0jnEHuYdAA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 30/32] hw/riscv: sifive_u: Support different boot source per MSEL pin state Date: Fri, 19 Jun 2020 09:58:15 -0700 Message-Id: <20200619165817.4144200-31-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng SiFive FU540 SoC supports booting from several sources, which are controlled using the Mode Select (MSEL[3:0]) pins on the chip. Typically, the boot process runs through several stages before it begins execution of user-provided programs. The SoC supports booting from memory-mapped QSPI flash, which is how start_in_flash property is used for at present. This matches MSEL =3D 1 configuration (QSPI0). Typical booting flows involve the Zeroth Stage Boot Loader (ZSBL). It's not necessary for QEMU to implement the full ZSBL ROM codes, because we know ZSBL downloads the next stage program into the L2 LIM at address 0x8000000 and executes from there. We can bypass the whole ZSBL execution and use "-bios" to load the next stage program directly if MSEL indicates a ZSBL booting flow. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1592268641-7478-4-git-send-email-bmeng.cn@gmail.com Message-Id: <1592268641-7478-4-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_u.h | 6 ++++++ hw/riscv/sifive_u.c | 39 +++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index f6d10ebfb6..27dc35e0a3 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -111,6 +111,12 @@ enum { SIFIVE_U_RTCCLK_FREQ =3D 1000000 }; =20 +enum { + MSEL_MEMMAP_QSPI0_FLASH =3D 1, + MSEL_L2LIM_QSPI0_FLASH =3D 6, + MSEL_L2LIM_QSPI2_SD =3D 11 +}; + #define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 #define SIFIVE_U_COMPUTE_CPU_COUNT 4 =20 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index ed13bc043c..eb767aa863 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -405,8 +405,34 @@ static void sifive_u_machine_init(MachineState *machin= e) /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); =20 - riscv_find_and_load_firmware(machine, BIOS_FILENAME, - memmap[SIFIVE_U_DRAM].base, NULL); + if (s->start_in_flash) { + /* + * If start_in_flash property is given, assign s->msel to a value + * that representing booting from QSPI0 memory-mapped flash. + * + * This also means that when both start_in_flash and msel properti= es + * are given, start_in_flash takes the precedence over msel. + * + * Note this is to keep backward compatibility not to break existi= ng + * users that use start_in_flash property. + */ + s->msel =3D MSEL_MEMMAP_QSPI0_FLASH; + } + + switch (s->msel) { + case MSEL_MEMMAP_QSPI0_FLASH: + start_addr =3D memmap[SIFIVE_U_FLASH0].base; + break; + case MSEL_L2LIM_QSPI0_FLASH: + case MSEL_L2LIM_QSPI2_SD: + start_addr =3D memmap[SIFIVE_U_L2LIM].base; + break; + default: + start_addr =3D memmap[SIFIVE_U_DRAM].base; + break; + } + + riscv_find_and_load_firmware(machine, BIOS_FILENAME, start_addr, NULL); =20 if (machine->kernel_filename) { uint64_t kernel_entry =3D riscv_load_kernel(machine->kernel_filena= me, @@ -424,13 +450,9 @@ static void sifive_u_machine_init(MachineState *machin= e) } } =20 - if (s->start_in_flash) { - start_addr =3D memmap[SIFIVE_U_FLASH0].base; - } - /* reset vector */ uint32_t reset_vec[8] =3D { - 0x00000000, + s->msel, /* MSEL pin state */ 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */ 0x01c28593, /* addi a1, t0, %pcrel_lo(1b)= */ 0xf1402573, /* csrr a0, mhartid */ @@ -502,7 +524,8 @@ static void sifive_u_machine_instance_init(Object *obj) sifive_u_machine_set_start_in_flash); object_property_set_description(obj, "start-in-flash", "Set on to tell QEMU's ROM to jump to " - "flash. Otherwise QEMU will jump to DR= AM"); + "flash. Otherwise QEMU will jump to DR= AM " + "or L2LIM depending on the msel value"= ); =20 s->msel =3D 0; object_property_add(obj, "msel", "uint32", --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587070; cv=none; d=zohomail.com; s=zohoarc; b=HJqZ1GrkFIi2XOBg3RlYvrN2tIUf8maTZz8R7WO/VyXQpIrlpM59Eo+7g1lnAumVoUoqbfpA/VZJ3hlPZ41H+/WFN7xSvd0ws/PFGLKPQDOY41oDFKwN3S8zWjgIzt5IirkkS6pK+60e6KRRACH5p/7zOJN1sAobZs3vOq0rk48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587070; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X+w9UL2IpuYFnfj3ziNwMPaHeAULh3q9rI+NXqOcjhE=; b=m2e7xvhawJ0ryvw88I5clsLLgP/b1XSzZN9fCzWBTzDi6fr7kRUGPohKikUVW6qaBLj+lGFew55NOTrdJE3p2oggnbAd2/B3ZC2j7eN6cL7+7e5YbGfVJmRATV/72t6xBwKFS1CjUit+xVXUe/DSj6cGrdycWVuiAp8Cww+OnbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587070922542.8624184196033; Fri, 19 Jun 2020 10:17:50 -0700 (PDT) Received: from localhost ([::1]:44366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKeD-0007ZN-Kz for importer@patchew.org; Fri, 19 Jun 2020 13:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUz-0002AR-31 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:17 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUx-0004Q3-71 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:16 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:32 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:06 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586522; x=1624122522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K0/g3Jw66ncRXZnSbPM1niIHhe1e2k1srPccWkUeogE=; b=ggCQZLTwtGqtDqdBzGpEAdeJNWP2QjbNpCB5i0aiSe0CZvzKshys4TXz Kg0U/6ZQYqhoNJL/ZU0/EIIA28xobSlifx+X295mYb5CS5yxlox1kO50s vt8uAoN060GOHy8OzBa30tJv3zurSUFMvDwTRoqJTcFgDIZBuGR9UBAPB Nq5VVGT3bMO+OSI69vMumI6eCt3bTi1FgW/TXvkHgOA1L0YzEXipkQlK4 TsBOE0JyUNR5aWPoSKBtg2H1ZSz2S+gV2oGZkWEBNY5Y+C9W6PAU1+uZg IPCRMPGkJMq83+7lBYTL35BVPXKWidQbJRgzeHRa5NQdXPg4dFnD7vWj/ A==; IronPort-SDR: QjbyWE0ROaufohZa3iCaze0VpeDXTKF/BsPowVsIda3ytoSy2HlFL3wCYjSpoYzZUvbr/4Em3+ d1GORhi0b0Mpvx1rQVBPtOO+rzC6KXu43xGrOtvdXTBYzGdhnjfQv2GxuTmuzJwQCPqlIFX1Uz tTcIh/AYJPQQqzOukltlwAHuGzIU0MtxlhApjqXQkq/jVuA9io4F2DU+QkTTj/UeesuojE8hZP k4fSnMoff9rZa9xc5B9KwKJt/f1gU/Ms7TexfEe0le6yYb3b140toyJlFu9VhXXdGb041AtOhI Y2Y= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417021" IronPort-SDR: a9c5ZPhi045rhlJZbj9uOMt4tz8B/tTyrkHX+Ad+sfn8VxNJZgSBkaykQpN7aAE+L8K3R3Rsvl Ov2pF6O0YmEANE7b03j6GSXEwWgVmBwhk= IronPort-SDR: 0Os/I/D2aaYaBuQQh6nbAQxdFKMZSsxdNeRUo0vquCOIbx4Hjz4Y8eBRvXHy05qtPHt/Di4c1z RWvzVvTYdDUQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 31/32] hw/riscv: sifive_u: Sort the SoC memmap table entries Date: Fri, 19 Jun 2020 09:58:16 -0700 Message-Id: <20200619165817.4144200-32-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng Move the flash and DRAM to the end of the SoC memmap table. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1592268641-7478-5-git-send-email-bmeng.cn@gmail.com Message-Id: <1592268641-7478-5-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index eb767aa863..b9d0a6901a 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -80,10 +80,10 @@ static const struct MemmapEntry { [SIFIVE_U_UART1] =3D { 0x10011000, 0x1000 }, [SIFIVE_U_GPIO] =3D { 0x10060000, 0x1000 }, [SIFIVE_U_OTP] =3D { 0x10070000, 0x1000 }, - [SIFIVE_U_FLASH0] =3D { 0x20000000, 0x10000000 }, - [SIFIVE_U_DRAM] =3D { 0x80000000, 0x0 }, [SIFIVE_U_GEM] =3D { 0x10090000, 0x2000 }, [SIFIVE_U_GEM_MGMT] =3D { 0x100a0000, 0x1000 }, + [SIFIVE_U_FLASH0] =3D { 0x20000000, 0x10000000 }, + [SIFIVE_U_DRAM] =3D { 0x80000000, 0x0 }, }; =20 #define OTP_SERIAL 1 --=20 2.27.0 From nobody Tue Feb 10 10:19:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1592587895; cv=none; d=zohomail.com; s=zohoarc; b=oKTEREvWx8wBcJdeW9BQpqvz8Rxsgbc3EC2RK1nparztbZl3l1dtQP+a4GWVWOYxlNhZOjn2exPAuVaCFkF5plKmQQw6P9Ey/6kFnBLJK9qErojs9uen+4cI5PIP0ht5RwELpmVZpLZGaSHhlIgk4MHFYFXI1Bq1kjRuMWWRo9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592587895; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IVNProSusYHH73IrdRVoq6wTZbH7wk8ftcpRCiK1yGo=; b=AjTCi7dLeHrvqTB4ywayEDI5n4uIkKE6BbJmJsyOM8xqFtmbEhw+Soku2BhAwD8rrb8+D75lZyL9FU1NWcsIwIeFghQoKlCGtPi//Lq1PPrc1xWYk5Awt9Qnp/dQbr1elFt/lXFY01E39+C9cRXMHz6gTfhfTm70PTgRQwCa4dQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592587895348632.203164347923; Fri, 19 Jun 2020 10:31:35 -0700 (PDT) Received: from localhost ([::1]:39936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmKrW-0007TI-3j for importer@patchew.org; Fri, 19 Jun 2020 13:31:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKV0-0002E4-MZ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:18 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmKUy-0004Pk-R9 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 13:08:18 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2020 01:07:32 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:56:06 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2020 10:07:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1592586524; x=1624122524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JwztKMtvyHRO+8rsE3rkWQvqEjJezYk1Ew7ePUs8op4=; b=hWq8Vm6j/LkEOan4CRm3NBXkO1f6KvS1Or7w4I++UoT3kcfeq/Bo2JRL cgLFu7Z/oWBoyT0mP8dFrEqNFN8UwoHOpyggQv5hgeRpP4MePUcMa9KAl T4zxL53W4VVG800dlvyrohgFRi0MkcwnNHWo4CCO/tH37ZoXwlgq3AlPf /KekH7Ru2z1fQbYBaCvIBnn3jr2Rwf2YIdVQhJU1Dgo9eWNWMupRCusqV OPl8jLUKKcB7EHR8wWl8BAymhjqU6qkri7L4MDQ9RdE7lO8e3a6jAOyr1 GiM6rtBYBmWeX/gWtIvLHOGILOOtfhtdk/E+BOuG5+Yxg0n5BKPQb1toK A==; IronPort-SDR: kicLeLw134wVzL3sSvHKrF3lLO/Xi8LYcycRx7RInZADCflmhHQC4Dp6lio2kppGo0+WBBK4dH VBzbfpO/deZ1gR7a1mV/ktbWd0ABHJeXfa1zKfc83dtPp4Tfshjaf9GegFgNJ/N7/RaJZFRfmL 3w89FUDMqdS13IqJRA9BzDpIBHhawuMDZzsoqZNIdkGnhwHcejQvqdhdBkiYT3qdppmTfhISwc VPldXs4p2jX4cEYN8cblwVjOkXdVaS016P9iMJwk1bSs2gj3K3X7FMdtVkKmrITuftxztZuKM1 1T8= X-IronPort-AV: E=Sophos;i="5.75,256,1589212800"; d="scan'208";a="243417022" IronPort-SDR: DCi/8Ay6onhUGjp286PAw1FE3djgSO5NoxNHiIjoyHeb1pZJfH09IDxYvfwZ6Ylj7pX825l8F0 3DwbCV9OwxYloewdh+T5TDxxBWufNEEtI= IronPort-SDR: tv78s7XmN5qRmP8lGC7jX34+eW36k5Ol0w4tD3eLTuwR1qWe3cm0kT6pubXftK+IfaiIL8Q4M8 hkG+p+7t3N3w== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL v2 32/32] hw/riscv: sifive_u: Add a dummy DDR memory controller device Date: Fri, 19 Jun 2020 09:58:17 -0700 Message-Id: <20200619165817.4144200-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619165817.4144200-1-alistair.francis@wdc.com> References: <20200619165817.4144200-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 13:07:24 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng It is enough to simply map the SiFive FU540 DDR memory controller into the MMIO space using create_unimplemented_device(), to make the upstream U-Boot v2020.07 DDR memory initialization codes happy. Note we do not generate device tree fragment for the DDR memory controller. Since the controller data in device tree consumes a very large space (see fu540-hifive-unleashed-a00-ddr.dtsi in the U-Boot source), and it is only needed by U-Boot SPL but not any operating system, we choose not to generate the fragment here. This also means when testing with U-Boot SPL, the device tree has to come from U-Boot SPL itself, but not the one generated by QEMU on the fly. The memory has to be set to 8GiB to match the real HiFive Unleashed board when invoking QEMU (-m 8G). With this commit, QEMU can boot U-Boot SPL built for SiFive FU540 all the way up to loading U-Boot proper from MMC: $ qemu-system-riscv64 -nographic -M sifive_u,msel=3D6 -m 8G -bios u-boot-sp= l.bin U-Boot SPL 2020.07-rc3-00208-g88bd5b1 (Jun 08 2020 - 20:16:10 +0800) Trying to boot from MMC1 Unhandled exception: Load access fault EPC: 0000000008009be6 TVAL: 0000000010050014 The above exception is expected because QSPI is unsupported yet. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 1592268641-7478-6-git-send-email-bmeng.cn@gmail.com Message-Id: <1592268641-7478-6-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_u.h | 1 + hw/riscv/sifive_u.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 27dc35e0a3..aba4d0181f 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -78,6 +78,7 @@ enum { SIFIVE_U_UART1, SIFIVE_U_GPIO, SIFIVE_U_OTP, + SIFIVE_U_DMC, SIFIVE_U_FLASH0, SIFIVE_U_DRAM, SIFIVE_U_GEM, diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b9d0a6901a..7d051e7c92 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -82,6 +82,7 @@ static const struct MemmapEntry { [SIFIVE_U_OTP] =3D { 0x10070000, 0x1000 }, [SIFIVE_U_GEM] =3D { 0x10090000, 0x2000 }, [SIFIVE_U_GEM_MGMT] =3D { 0x100a0000, 0x1000 }, + [SIFIVE_U_DMC] =3D { 0x100b0000, 0x10000 }, [SIFIVE_U_FLASH0] =3D { 0x20000000, 0x10000000 }, [SIFIVE_U_DRAM] =3D { 0x80000000, 0x0 }, }; @@ -714,6 +715,9 @@ static void sifive_u_soc_realize(DeviceState *dev, Erro= r **errp) =20 create_unimplemented_device("riscv.sifive.u.gem-mgmt", memmap[SIFIVE_U_GEM_MGMT].base, memmap[SIFIVE_U_GEM_MGMT].size); + + create_unimplemented_device("riscv.sifive.u.dmc", + memmap[SIFIVE_U_DMC].base, memmap[SIFIVE_U_DMC].size); } =20 static Property sifive_u_soc_props[] =3D { --=20 2.27.0