From nobody Mon Feb 9 21:27:02 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=1592548711; cv=none; d=zohomail.com; s=zohoarc; b=FeKdOn1sdW3rpt3OYNjTBo1Bj0te8fuycw4bjiW9aJG8/QFsq88k966mepCADWuNU/D9uyhL9oVKzFjVye8zH2+lzlFRBvPm055XP2HZsMpsE0iCQpp9N5NvWedpjZMNop9kVFUidwA8r+GIRgVM8kipgUNyGzT21jpuE1QfNJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548711; 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=f2sRES4mG8usxJEhWSgo5zHwBVxqUpS1MMyoIHp1lKjp2jaI470H48+3dgkQ8sJT8iod4B7eXuZJAbve3+Ej00H4lWNVMJ60quGTSKdBS6elbBkvyneYwYwWh5InqJM6a28r52O5c5XGeZCR5ITgSmmw0a36wfUbG90gv9MNL84= 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 1592548711435518.3738402816504; Thu, 18 Jun 2020 23:38:31 -0700 (PDT) Received: from localhost ([::1]:50348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAfW-0002l7-28 for importer@patchew.org; Fri, 19 Jun 2020 02:38:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-0005Uq-A9 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbe-00028J-Q8 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -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; 19 Jun 2020 14:34:26 +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; 18 Jun 2020 23:23:37 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548471; x=1624084471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRlfmAxnNO+uf1echkK6NudzAPtFUGkmvCQ9SmWv+Zg=; b=B7FATe/qb7aCWBX+urEodRZ4SQ6lgkAhwcTMq2OL5Au3CRyHWGtpFsVt 6a8d17CuOy1NC7/Jh7PvA0NiAvTN2J4+xhOnKekBuOQJu10blGALsD4/b DA6OoEH8gYOG9Aa/8gRn38WDxKVZUXWuZ8DEG3UtYODpFAfmNqVi6PqQv 4JvfVD2+rUB/BsUXpjNCCZSoX5Cntt+BZIM+mIJ574bLukp/qGHkJvuB+ 3NYaP33Le2NL1tmsBgDOTERZUu+qMB6XVKX5P5jfQKSzmY3JTEO+SeqFg jEUn5mfadELRMO3tzWdBI/0I7ruWIdESpgfr1yjp/g2pGqBDjclR3H7vl w==; IronPort-SDR: hDu26MX/st0H9H//tJ9x7BQQR8ro/ngrvWcNlv6YqOUCxvQl7z+b9UjZ4SnxNIG5UPvFqRsGTH nkKqIuJvKagp54yqeV0UGUmR57x9oEc0MesEnFBbv27ux7799XwkWassZnWaAG8RIO2MPbBsyz K3VdO+fbEcpHyo5onwnnQeBiGT7JIQp56Hi8XlyBgqkLng1WLrD4Kl1/1xsVsJZ0d+9O6i1IqC dXm3be/ooSMubGfxmuHc9EN2kGD9MdbQTaG+rTBfzCmi0S4ewtQy78il1TJjKChqE7MyeWmQ8B QRg= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724272" IronPort-SDR: tiA/Fb9saJbbn6F7TGBvCvn/AyGh/JRIUccjEB54oWgEgurK+N3Q+mOCsfi1AQQmGQcuZBTzQd TnkMF6YtLfbScBIwS6RSq0OGilsNkhmYY= IronPort-SDR: EweuxRxb4RKH6Eruc4USL4sMFXqfaGu0v2LrKqDCh2o/W/phEn3nDa9GnPABlsf2znzTCObXNF 7admaHt99udA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 01/32] riscv: Add helper to make NaN-boxing for FP register Date: Thu, 18 Jun 2020 23:24:47 -0700 Message-Id: <20200619062518.1718523-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592548596; cv=none; d=zohomail.com; s=zohoarc; b=J/omOGYqxVZZg7WwKUf038gIa5d681hzphk/cUPP+Ty+wtw2ofRA7l31sC6hJH9d2CcBLd2aJN6ilwz5QeNClWk30mvehBmv6LEqRVcEcYbtFokJs6KVNf5+eLtHZuzt2uj0ws19WawOmMcWCgZbUr/lDahfoQlB2IHtHQBHWTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548596; 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=gb6Pj1CV3IK29K9M+WjdIcclZWCq9bUSVn6jEiD4Ma6fMVZ8hk0iLqKVCiKMSHhBsiPA2kXRoOQCNIwz5JqPoQ2AbWVuSfvw3grlALL8QGnN4+vMdvMdJM5efCtH+smCB29Vg5+gQSl7Tu8fV6NPNbjik0c0WfO4ZqXO1ku/03c= 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 1592548596819280.65155928356046; Thu, 18 Jun 2020 23:36:36 -0700 (PDT) Received: from localhost ([::1]:41934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAdf-0007OI-Aa for importer@patchew.org; Fri, 19 Jun 2020 02:36:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbi-0005Tj-0H for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:34 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbe-00028R-Sn for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:33 -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; 19 Jun 2020 14:34:26 +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; 18 Jun 2020 23:23:37 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548471; x=1624084471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XXem7lAIy5JLne6cVjjQsO7guKTzZZhyfFB1ov8zLOg=; b=cgRmWjVikj2071JeB3c0rHBBVuLXhMhpFuXV77aD8VdYZzLAtQzkZhfa eOy3yBKGwtIGg2GX8SR8sKv7P2D7vY5o9b5ZN/6/nhyz+is9vna/b497A wU3xAR6sCWhZY+yHcIP2QN3z0iCgfh5o2icmUhI/3sxuCig3QrrjJLRRb CnXI4ZdsDPiLj1E89QBjBnEKnK+vapybTZzpJzr/LGRu6yVvfLCEpqp01 pLU9EWBARWYdVpLNqIhXoQpSHeSVb4vFj6vcFJph+lt20hmDnAGPnqbBv 2nyZntzCpwtD6xcXC1O+YG7UaDQiAV0IzkMlxBZ9J0rKGHRLb97wZWmEA g==; IronPort-SDR: TFQ9XjMGLCWarpT088r05XMeI1RHg6y5VyhsZNkZObyyDWWZXW0izl+UkBo0SE5bBxxQb6UGAe GDcwr6fkpcNz3MflODWAYwEjpZk5cLLjq0olo7ElH2p5EP6cgUwJELp2nQ59O1H4+gi7juqyOQ oK+5m6ytmeObEWj2/8Op2YOuv/C/JC1wkWl2SPI+1R4cSYa/Dz9zlQxOkyYwYGltulcWMIcT+f WGQDCwl9xab0ItYcdjS/W7smJCDomxYeuD+qJjUqhmCnoEnptMt4hz1yeAxF6gyvti2210Gm4f u/c= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724275" IronPort-SDR: VvVzRsiW2wv9u21dNy2iSKQuylj1yd9VqLDc0s2XwLSV5qzbk9XjAf0xsrCCwCxlXtypU9aaFr kAK2zdCb0sIK9FM6yTv7T5C/K1mPbUjeI= IronPort-SDR: 1MGTkrQNFI0ltoqwg7lwC2zV3i17156UZcleuCkRjuLzMWYC+j3IDAZDHr3tuPhjV5J5uFaM9d V5NOJBCjIX4A== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 02/32] sifive_e: Support the revB machine Date: Thu, 18 Jun 2020 23:24:48 -0700 Message-Id: <20200619062518.1718523-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592548644; cv=none; d=zohomail.com; s=zohoarc; b=Gl3M1u/Jz96uMI78gsAGuGu8wYHu7wUeCu9z9B9N97X8tYsYvSZT/pywMlDmeBoEvNpeReKZhuoRxKJWOsghFdRd//KLFTOqm+97U/19wYGkzxdhQwO4zMf0W9Fx0yOwATDBYflv/xpgtVprpOzF7TZPNOOfbrXUT3A7ZfZZHHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548644; 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=LPWnk4uwcq/BWs7KVbbcuVWsiMVS7/7lPvqntn0mBb9um2j9B7KWVr/9v/HIq4guD03zEpquyexNlPm5W5Yuf6HCTSS2Nzw9y/JP+YGzZjLyOBoC0XI3Jf07stBqStgNXQT4msE3sL84cQT6iPxDowcm4Be+1SMtJ+1bgi+NcoQ= 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 1592548643996943.2900854547934; Thu, 18 Jun 2020 23:37:23 -0700 (PDT) Received: from localhost ([::1]:44836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAeQ-0000Pn-P7 for importer@patchew.org; Fri, 19 Jun 2020 02:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbk-0005XX-VK for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:36 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbg-00028E-V6 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:36 -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; 19 Jun 2020 14:34:27 +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; 18 Jun 2020 23:23:37 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548473; x=1624084473; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VU9o6OYV0MkgJqJ+P7yL/zRcCvBETb4yUFY3HT80i6k=; b=TLQp+a39oKUO6P9tjTIt1QDvRn+9Pckqs01WxmGZNfN9HYK94MeHqt34 BdA6QyYZQ2M5XMphWPef+opb9RFhauEGg9i72tt8VuI9wlVIMydzWCmKB og7FOjpRoUiFKHoJWayMFB4oQ6NjPyoLaevbLI3468sUyDptz1yLAmEjJ d8eMglFQM1ZqejkuBCidd3tyTmX+8DMi+xWMAdD2G2uwvs83tAb8Pi29/ s7/wVYpZby8aLE/NRxMHWATigwMJ3uyxgNnrzVS1GFrpWjHckwqqu7ZJj qS2MxwUBBxX5Z2iUXmGn/20JxwurUoSpktcdwkzEzi4lyetIx8PpIIBWE w==; IronPort-SDR: rXiDvDYIaiWNv1tcEpl5IF0oRQiakMIHIMD6728UyKY6VXlDhUDSXgR3UeRhTjbo0UKY7tqCpC K4tiKXPqbyzaiJ0LWx30IQYVvH5ERFSl6b2kdBrO9RuEA4zCjAEzG61RyxHf3X9WEAHtoFadE7 wh8BeKIP5+hC0pfFIfhxjjyVFsqO+TfuY2j2cvnNCyINAIcEhzL3w7DcT+6U1qDVz6kPLOEX6I FFHPX4ly5RzN9i2wgeELICsBo5l6eC6SbtDGc9YdhXdyvKamxu3u7DUuZ4ZlRvdXwzngZydJNe tA0= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724278" IronPort-SDR: p3xrMgk3LAnMgXazpQCwYfaMut45D9LgQl8LL1Nx7mi3RQLJg37kwjOsplXsdyEQt8ILMkFSXg Vwt+rTLHcLdjHBwGnd6EWjPQ98bkK/QRI= IronPort-SDR: G1PR93eacqGCGrw5E7lveGDPuuqSXBMwX8RvZTAkJod1P+ocyI3w/NBavKc2Hls1J2iUUWvvnC RpIYWRlE3vpA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 03/32] riscv: Generalize CPU init routine for the base CPU Date: Thu, 18 Jun 2020 23:24:49 -0700 Message-Id: <20200619062518.1718523-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592548597; cv=none; d=zohomail.com; s=zohoarc; b=PQ2JKyHiYxiLk3mmnMwNEnYX5lT2HUKBw+G7HhAaLMhEzdxsUfuwbDSeeZCnkiUwe1pCglM4gcP3XriIEm/4UhjXiKbNDTIFWkIhD+Ye9dezrTcNb7fCH289y8ufDxGcCWU7QxpOEbfftECM1z0uESTXy8LYMGXv7kAB43egl7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548597; 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=RUgl/bi0YxKdUxZipGX/9wD+0lQCFSvcT8eYVD2z2KrfmjQ18tfaPYuDmqqBenKg4ij8P17HYEspEZpDqnRvfbALZ9scEWW+HKVeR98xlGt0LcHy8Rr4NDY4Qve/+WkKOnjd6grGTP3G51O762if/v7keEuPSc/V9ksRxdeis6A= 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 1592548597041926.772787533717; Thu, 18 Jun 2020 23:36:37 -0700 (PDT) Received: from localhost ([::1]:41978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAdf-0007PE-OG for importer@patchew.org; Fri, 19 Jun 2020 02:36:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbk-0005WA-8k for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:36 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbi-00028R-Dp for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -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; 19 Jun 2020 14:34:27 +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; 18 Jun 2020 23:23:38 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548475; x=1624084475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZQTwToslAoo6RGSrCI1CsH1WLRCehMn1IkQjkbVRhY=; b=QKlk35grPW2CgE5QWK4lJ2kXs/yx9RER0xFA+gYPgj3YF5aRar51Q/Zg pPv/gBLV7V43OEwafRfVCdCY/gNfNuT98lVxqQdmCvg/2BrMaDCbCAEWz UV6OvAlSSSf4raa9+e3vH9+F+5e1bfYOwKoyin1bLWAqBWeUQ41BrgtQb yKYlFgokUxtL0kzuOr5NBib8PIn3Tsv/nHpF2M8mqSuyDuhsxJEZoLqiC ajwKx56G6u6PssEEaPjeFdmuJQChyPTbWLYsAtcGEz0sPHuE79VYY4JkZ IrX07x8eHLUmZ93M2web4ahDG4yLAp3GMfu2WKyR1w8KYNWbLndjCIiVW A==; IronPort-SDR: DEDIpuQM0zWmuZrbpBTBaFr/9PY0k+AbF5eqVad0F958dpo4ZnA/RmhAdkAQRmj1KTawD3K9wf qOM/5VjX+c1U8oOvI7KfV2+sFg4gXYcUHgoXTFw7Cp+LYErRow8Gm/JPwF4g97l6+wxlU/CD6h mD2gmM0AG2H00tWbRsCHTrG8qmSgEdDfEEFOQzHdbiyDScmkgK9hdr1iZH94N8qwTb4FGRkGcF SdiIziaAAOYVB4kcx/JnU2bVfVcne01FOydwaDJJDANzwOjKPm694Es7RreJ4wNzWkI5xNFKVY 4Ko= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724280" IronPort-SDR: wMhe3m9h6l40vOye65FrTxlrvGZ3NbtW4zzx+2C0UrTQ2p3LVSRybGWbVA4vGFdFvjIMfsKsqN +TxSskJSXCHKanQnbcU3IKty+TavrvRv4= IronPort-SDR: VTvdtBbFXeDp1nmxcHofCdHHKApkAoRX2gJ4OSQ/8ISmpAeM2XP5uzfLmsROKw6ZG9RO6A0aG/ 5gaSRcD6sW9A== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 04/32] riscv: Generalize CPU init routine for the gcsu CPU Date: Thu, 18 Jun 2020 23:24:50 -0700 Message-Id: <20200619062518.1718523-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549037; cv=none; d=zohomail.com; s=zohoarc; b=k44WPCCEnfoig3NvcaNfdvZLSDPBZ51mTYORnxARtj459XDmRshel2kO877S38tkBQRfrpiK496gBU6sxDwaZJTmguKf3LiklfGKBfojecuwuobOyqtNyhWxb4Q9ypuWGaqiCJnW0/6mkqOLRujV2qKn1hh0uFIpJ9TX7RyLiFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549037; 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=UmVgeompnXsbi9BDrUGaSyoWirUntNSS0J5JFbGqErBkZMJWysSD7KBi2kg60l+jI61FQlEVRmzhQrKaPHa5xFZip24Y8jvkVU4s6gdHLgvkJkKetwUy9Uf6x5HFXCWvJIyFRtiUgERkieL/FmZUVK0kTbC/ucMd8yEKyxfQypw= 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 1592549037935429.9462048181167; Thu, 18 Jun 2020 23:43:57 -0700 (PDT) Received: from localhost ([::1]:39128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAkm-0003St-L7 for importer@patchew.org; Fri, 19 Jun 2020 02:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-0005Yg-Lb for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:37 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-00028J-LR for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34: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; 19 Jun 2020 14:34:27 +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; 18 Jun 2020 23:23:38 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548476; x=1624084476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oVrn5w9HfRb0TvrN5CP3m58pdTdH4CK0+0WfxcCouCQ=; b=DPyoI6GYXclJ+LACt6jB/cLyvrSRNdm8sfr+8OhGvqTxj5i9qzMPLdjN bIVCalg2A4iLATaKc4Rv+8KAvHacI80MhSjkEunmKko15lgA2aTo/90WZ VDW9/7ItBeFkkkWGp0AC9N7wEuK09wd9XoOgNJ18z+oTZUFNwM+mwoxIT FfjCw81pIehGpYlFJnJj9CI0pHBRWOqSOrUkLmdME68dSHj7XeeGyQSFj NFNYSlsrm5Eu3j+JDz5cx9KuK9Lcd8ImRjY+1YZ998meHj7xm5t5HcTHH Eqzl9Pys4XzTzmbu/8ONKLRsw+ObaZD3nY1rWHIqBAWk8zDz5DByn3x6D w==; IronPort-SDR: eCaVqqlSahQ7L6kfdhFYod6rdl8tfJIN1mb/2X8DFnYTJ/TqiHZ0gkmNzWppVDDp7qV3eRtzxw 7S96WZ55Y9Pw8sPocc+FZrJhCChlGCb6Yuw3wqDyZhE/mtDv3tDtFrOeAB0bM7+f8k4T8Y9XYj 7HgWGQXmTjEw2tgzeDyUsXfPLdrn1ZRf3Eyqnfgj7vqzjzhYyGaTnT0yLuHc5U2f3zHAd5pnyl liUNayaOx51DrMIzH6CtFzV8gGnQj4/b8VpbFKHLYuPD9j56hMSG2XUj1uyyPmNf8z/6vEF3pk ulo= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724282" IronPort-SDR: ibxYzGv5RgSY3RYnf4ucQHhNCpswVbkTiI+/MGTd0PHZUGw2BNV48+fpPAVVq87VKwdE2hS/jK gCkmmUyIbCYXE6E5pWukTmt1VzNrKAYwo= IronPort-SDR: EcSwOho8vTgfUNSK7KqPePo9Pv7EkAMBWI2PVqMpP6hbFsUfCF3Z9I1IaT3kuRqBDt5MEYMOXU MSfoq5zboezQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 05/32] riscv: Generalize CPU init routine for the imacu CPU Date: Thu, 18 Jun 2020 23:24:51 -0700 Message-Id: <20200619062518.1718523-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549190; cv=none; d=zohomail.com; s=zohoarc; b=MIWwy1me/vJ6VkUQNQI7k5jm16KMl1JhFcMZyPl7NgUxFhRwHJS8wb0BbcC2Lvo9TM1NOuAhVuM0HJavHL5HeY/3GxnXxFWcITqKLOreq11tUolLzaZPtCNIswgwv65HhZ/lmgOGSjnUr+r8mZY4RbCXqBmaMm+e3/pLZqJ79E4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549190; 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=CKfDbSLThyQzcj84H2o/LI+l2zFCT2R1uqsnT2WkESE79qPP6xHWqe4F/LSXUdV77QnVatrGjIRM8nsjlh46Y0FDQKx3CTA9m2UWH2+74+KnlZBEJIL6kTpFfRcb4qzZwEPgw3rTQo7tA9XJWa5ngbpNr7SXH3+E1Kfjm+j4MGU= 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 1592549190186792.757769967676; Thu, 18 Jun 2020 23:46:30 -0700 (PDT) Received: from localhost ([::1]:47672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAnE-00071O-No for importer@patchew.org; Fri, 19 Jun 2020 02:46:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbn-0005b1-Qy for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:40 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbk-00028R-Hm for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:39 -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; 19 Jun 2020 14:34:27 +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; 18 Jun 2020 23:23:38 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548477; x=1624084477; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K/19YyQZ1dMfa5QzOEJU2PErNtrrLO7t97Cdg6fUhnU=; b=ocFsnWcw41hftBkmvgxKMDVn31kypcaLtqH8ruM76XuIapO1UFKXmNxT EwzPWcCs4oT+/BT9vL4dMKBnKtdSGUwObDstozqlegsI4SAsxNe7f2XKO KNsL9wgqIvCPtBdJ7EYPwdRFdG6/N720Inp+K5p8bFkY2azpmbjFPc5Cz U8v3N0fibgbbhSveXQGZjmpEJMS/Zq1hb8GU1ZD7xYtwE3RxlteJWzeJt tuy0Zu/y1+VIHx5WCZu96UZbW1fmZ0k1wuEPBG+oyXTcpzg2d+Ki2I8Tl RgZg/gaJhrv0RBCBP0JdzKe7aNvtWHLN0xkugKY83SOscMC8Na/5rPLWK A==; IronPort-SDR: ms+R4ipIGguxlxLo8WM19lDprmGxi4whrVx+DB7MOgUwL0gdqpV+b5GVQVpyne+Ox7wuo2a3uR xshQ54aaeFwwiNp0CWfgmQ0AcoJSQsKbkPtVIecis4Kn3e9ZH2fnN2+bXKpRe/rq/xKaBgw7gG UQkXn9mdrkLJXi0zZiLMrcdbuqxGGFueNsEGFV9frGcvUpDxpAigIEXjTuPe7DfGj+5AkLk2wZ EUF2BYNkiYavAS4gOc+Nh3o+bsBDuDl6xGsA5x4M1Tq3fvA4QoLPhxWdHnzuBWSQA/65+u/SGG KlI= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724284" IronPort-SDR: mBGULh5TLLdtgDRd4pEf5Nd88pmBUjDE/4iHMNej0KrNfMhyKfy4zrg0CwjtXNVEiCefWDYGwL xddD3Sk8UJaekdJFgn+f/ZlLxC7WJhjmc= IronPort-SDR: K9UNDtR6J0Yic8L2az0CU/x8Pr0o6vdqMm5kZe3NWNcKuvw9p+7vDUQs9HIFf59uEng6C6E6M6 K7ExbP0ys13g== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 06/32] riscv: Keep the CPU init routine names consistent Date: Thu, 18 Jun 2020 23:24:52 -0700 Message-Id: <20200619062518.1718523-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592548946; cv=none; d=zohomail.com; s=zohoarc; b=SvToSh3AH26p8nSTI7mCBQjh7Vnd+7B8N6wKsvdWgWNGC+XiYqPTUUS6Kff9ksoiRyUXDE46O9WDblNXyFDdG119DlXLhvWImQhSFor/0QqxXPoiI/hZHGxE8yrvcflDwgv/YxWI3aj0cMcM0ctelcDwwjbA1GyB82TeW35cpPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548946; 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=LA7Uoz4Z3LxODlxVfw1Dqu6JQH/quEKya945DXDMdVFkOuIPzmr6PAEpOwX7hyOjUJNV7zB2y8GOCvXZ44GkH0gd7wQN9AePljhegq5PV1GJM8au96HcwlBMcWVEzH8VXO6XqGPdc6uYmvFbBUCMH914aRThO4st4ydOYhTCKXE= 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 1592548946345373.07728928360916; Thu, 18 Jun 2020 23:42:26 -0700 (PDT) Received: from localhost ([::1]:33802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAjI-0000EB-Ug for importer@patchew.org; Fri, 19 Jun 2020 02:42:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbv-0005co-9Y for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:48 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-00028E-Ad for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:46 -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; 19 Jun 2020 14:34:28 +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; 18 Jun 2020 23:23:38 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548478; x=1624084478; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pxVyDAhQ8bumskxZPWWUD2L/widqjE3TyqKlh9liO+U=; b=gulqEDyHxBbvKtS5hiHoQ/eDkkSGnEDbfVnwLCA++sPlq4hW8apwrTzp u91jxkEPtmsuLXXpvJg57WVpOq9mWekZsbU5baVuyHodlmFFvfeZHjZQu L0ZtHQZBENi15xSoubraVJDX5VfnXzjsqJm/THMnCCANtOXm/zWyB4KmG bU5zaMQhhVgbY3sJYq43wWhHTTQ/9zCMKrmmxCgRP3225h38gbKae2fTI TiaS0C8qnwXxhoYBESpnpTUw5kt7pCGyjPLYwVjC0KOeIQ+QcsA2dxMF7 IJXZZ12ep2GYXab7ecgo5jT7NBR0DwmjLv2OxKID5j5odUOo8gfCSDp4Q g==; IronPort-SDR: ayS6wDcGOmCkeIBD0gk1LIdzwmIjjzSGTy7W9HK/WH/4E71r90IfGVwHr8MsnsGdi076UTepiv e/rGYhpCnN8yCgCJRULoowW+RiAN6Vf4Rbxe3Laf0gB5FxKits0BGPgJ87OPrk49Xmze5xkaE/ uYP/EOFweZxoW8zRAsQnkoDep6TqPw28zvKdg5LETpF0pb6TdysDVk//wdghJ9H0EchIFQo3BD hTY3SjcjhlPWYCMC+jC7DnP1nN47JXvo8PilU7GvTqb/XwPGC6+OqkPyW6PNiFqyYWu8y6QWcu EqA= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724286" IronPort-SDR: oXMIwGLBPz/pBNyRA/DIiJIXjymz1QwFF1efpKIP6KQjo+KZry3cLw1EC8TLgydjOgpJrxnUrE YTJ12AMyWheMuFKUQqhQQbQ7RtE/IEDV0= IronPort-SDR: jMGvd7K/RfvAYaXQJwUhKHyrcAurd6wx1E/iNnb9aDnDg3XNy5EjTT6sy2k46qcIoGGoF/y5gZ 6TKZ5GOq1GQQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 07/32] target/riscv: Set access as data_load when validating stage-2 PTEs Date: Thu, 18 Jun 2020 23:24:53 -0700 Message-Id: <20200619062518.1718523-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549039; cv=none; d=zohomail.com; s=zohoarc; b=X8Fvipciciq9BGk8fkhC6Az5S5l1p5mK8MWW6qM+RXZCOP+Gx/ff2uoBXl04syJZsvpnSigQPC0vYJ1RNFWpixk8QSFULR/kAmQwWnJVSiQQqQGsEVhm/7CGjXV7x16vLjYc4wYO17wZjZrE8fg+HLH8wB1Nw0UH1x9Xh9bLWkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549039; 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=ThppyAPfvWdrUR+aR4Uj3c9BAHHyubdivj7f8Gd72UvPMh91IfxH4t965J+CZHJY+4apP40s2LvtVpNhhkZ5lgw3+VwMxegarwTSBghNsqf1SXi8rk0ZUyT7FQmwI2DKISduOJJMiccD/j0ACi3WoCN66+NYY8HzDZNZBFSEBLA= 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 1592549039073567.1982910665879; Thu, 18 Jun 2020 23:43:59 -0700 (PDT) Received: from localhost ([::1]:39336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAkn-0003Y7-QO for importer@patchew.org; Fri, 19 Jun 2020 02:43:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbt-0005cR-84 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:46 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-00028J-Tq for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:44 -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; 19 Jun 2020 14:34:28 +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; 18 Jun 2020 23:23:39 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548478; x=1624084478; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wjfXyN3NWwu3m0SqemYRz9ib0aF+Yfq0vhP7wPn1ngY=; b=ovj9nv8oaHi7uiIyak/JwPdJu1a1iU9/OHZ/csgnD47hXhdj1MLmz+Pm agtNtSUaNWHlt7rBc+NJ7daOawkuB8cljjcWkJLqGOEZhyqhPo9VtcBSX uRNdrcqW6QtLSOXFi20vGqIu+cu7H1unPxoI/JMriACh41/dh1Oyymd5o 87NHsu1PqQXXRJ8Bywtn8e2Bzt5DaYpyZchWAZx102jqZapzHbmEw39m/ p0yDePgQgksLKtzAUQF/LbqqRLtwhgNa3/Qtv6cDWJspkSb8NV0sak5TJ QYYUjCr4SF2kS2Bnd712Rp2yrONIL6mMd5Vh4Lpm3kfWtHELmt6bKwRD5 g==; IronPort-SDR: kSY3812w0xCb+s8D2nX19RM1qdtE4OI71MH6b8OUzL738t216NdTuX3pZNwFQBrP+J6QDwrv6P C5KgDw6S9o+cd/K8iriZ/pK9HVfq+GLz8U4edaBGSvZdtPJVzBQH+Umd1RwZ1/lImnMnkuGcVb lFTrb+Gutd/YraMQQsoi09JrIoZloX2vNaD0nlret1+J5QDRBJwcKp1I5tuEPM6aEHjE9vxelA 5QTUl4i8XAiSXcsd7Yb+J2sAuhFDebYn1VDM+2797FMomG159USe/bviPqWKUIqCMMXgeuEERD kgg= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724288" IronPort-SDR: pXNiBjF1KeZRw1aOAfhQe+tNH+Zd93TJvYfORz9ha+kddfMWSNjNP2W3Sf5vx8qKLciVlwfVly plJx1GJPXFN6ongIr1uM7/lkdwt+p5FS4= IronPort-SDR: AwAwKaPLHJ19qp369xe1LfpJ3BSCjnvwI/5dpASpcMbOOgjYjPDSE6y7KGp4vDZxDHJToxDkvP 2gYcYXKj6cvQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 08/32] target/riscv: Report errors validating 2nd-stage PTEs Date: Thu, 18 Jun 2020 23:24:54 -0700 Message-Id: <20200619062518.1718523-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549304; cv=none; d=zohomail.com; s=zohoarc; b=ebv2FDNhAz90kedL4eSwUhtpPL0PpZu6WTthWIEaNyFb13CCSRUPs9feyDYgWmniSjHdR6ZJ360XgZqwQCsTEo39bB4DKLqenvV2a5N7mvbVa9sOccTTGCyebPnXKEKKDCGsEa9WyArxPVm1Euxr6GPNz7UI5mvhF8ur4YxwDOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549304; 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=Fi4FPfqE+Iy9UMkD+nJ8qzv1E02yUG++93WZIKYF3ws2A7IIWqVMDGS3QblKYof7evYFbcvSprHFgTdPZC1V57Ilr+8I4kOiun09YsXBBpNR6xm2bmVd9nPUZ6K70WtVlt1Rc05ogPz1BebVzBS+k2UinwWJRUJlgtPl5xyRHRY= 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 1592549304585584.7587134099477; Thu, 18 Jun 2020 23:48:24 -0700 (PDT) Received: from localhost ([::1]:56140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAp4-0003CB-Se for importer@patchew.org; Fri, 19 Jun 2020 02:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbx-0005fw-Vd for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:50 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbp-00028R-6o for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:49 -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; 19 Jun 2020 14:34:28 +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; 18 Jun 2020 23:23:39 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548481; x=1624084481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iMetX1AG2MztuekpTz0Vq0px5OhOLtHAmGALKic8XNY=; b=LZ35UPuvgWTHpfSrdgyUZpcOEmCCplR4qd8ylnlyxSAsj8kyAiTIrNCH zxNkyi/wEtRIppC6OK++2W4u/L1RNO6U46Fgq6at2D9w5K1Jn1gP+1rHA wRWp7T2boXL3/4uHISsyVHp60rCHqkspyDJa8vAyA0FZagWmIRNPys7S/ ZVfhvvJTzNQYrK5z8GgTWkNgMapB2zeyRebQ9QiFXtyNY1GopRg2ZSKAd +LmaYYh55c66hQRKfGoMKMWaVW9NJEuUmkeovWQAqSwpeUQOhBJnmMC7H +PwRDpBLB6FSlC4/l+jdDOovS58R/2+dJNeqRiZY3sNGuxTGZm3v+hns7 g==; IronPort-SDR: 10jj6sM6m8bDFxe/Rzf78J5S05hfU3GHGC3yZFgLINkiO+1gfBIImedXGs23gyl9sAhA7Eoj+l wigTmSn1hj3maIytcgnYpZUchG2bMS//9QdH/gCPW3RSHqZEESKZyA/MJWc3T05jiP8QKIvlK+ NWRiHxZpxsv3iYf7PUh8u4ZpQLtUMAhHzd/hIYz6mNyFPr5cKwxtUVCZ1hXrMc6ckGis6cEjeD sLTAWWNSVfFOuvLYbj0RNMsinQV+jXZNHb+SWm7rdbisFZ3XOB71M7kpddBImqPUwXt4jSINrd bE0= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724290" IronPort-SDR: LVLpx5yElZt9O/Nwmx5TvJDqKAtEkLxDOBQVmbiPX3HNm6P6X0G0ppLwnBM/mJs3GTsMVSoDU9 gQ3NdtY/x+H3vie1pC2IlW78QjnyowfF0= IronPort-SDR: DslVcYIr9FOHX+iirK/1GjBiHfZaj3oPoTsqr0gmB1XAOBhRZTI/ff2gVZO9SAFUR5L3K+Ml+6 bUVleipxNdug== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 09/32] target/riscv: Move the hfence instructions to the rvh decode Date: Thu, 18 Jun 2020 23:24:55 -0700 Message-Id: <20200619062518.1718523-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549192; cv=none; d=zohomail.com; s=zohoarc; b=X/KIquWTNio/MyhIaYURKWk9GdN0QZYNH+b2q2idt0gf2QFOTqCEZOg8W7O6dyk1+8nTsbeGXY/9q+lutiJTsWRQyHlEZ48/ehFDaugK+f+MhQpV8MBHCXdy8k4VESgMCKOx6cGjDmi9zPnpA054py0bOsoP3AILvCFVKNip7XA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549192; 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=O1X47WpTgLe58qG/mCH5RbYGY34jci9xvJUOtN8MqS3PIiaZDqRWQd0qxDrq1Qy6/Zf8nXG3q/2LiuzDu4NET9FeWQcjyo9SWliwxF9wvctcfmQk20oo2pskY9iWt1HNRPntIMmAp2HGLvxKT52+H6kPq+Y7Czsygjie+MrJ7Cw= 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 1592549192466943.0434712120966; Thu, 18 Jun 2020 23:46:32 -0700 (PDT) Received: from localhost ([::1]:47910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAnH-000776-4P for importer@patchew.org; Fri, 19 Jun 2020 02:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbx-0005eP-E7 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:49 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbu-00028J-3f for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:49 -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; 19 Jun 2020 14:34:28 +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; 18 Jun 2020 23:23:39 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548486; x=1624084486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=melHyBNyq+GBsmbi68L0crjn+k4ZDNG0okkKwoQJd1E=; b=L6G4cTnxQVbxPEPLKVG/wxUK3GDWyRc/QU2278YafhCOryHIJv4kx8qY vRUFs8TTLUPa4p2sEx1JaWL8NKUyo7dFJr34WH+UcyiI2cP5j1mvw3nVD PRnkXJZWpxSg9rHp/HZgzsb8b6izrsd4cWlKS7viSP5y9P2LTjJG3RnIL 6rIDFsKNjYLbR0007Yss9Zyz6snq+vP3XAEHYxS+n180m8VFgH0ZGsM/9 m1q2S194rPAL1BMXWsJ2qL+DSm6j40XV1TUAqHM/U4vHRG2H70O0EQVip A0By+5+vrDyVQ2mFSlYP7HXBjyAdB6BzOGkESPZivSsmovMfm/4wRZ5xm w==; IronPort-SDR: DR/68362m9RNGcb6gItT73pdRBQbJGKUp92WulbjNUFnqtkLxORupvQ7KC+NgR3BeDwpQLWuRg LIWo0vv7XJdFrcs1MxoQwLPtjDA68btGvK3wRspoXRgpHpHjPdM8CQn+zpLGCXo+LMMKcUucH7 A6Uae+GTzO6QhKvdTMC6EiIyWu+/ma5z81vuTil2G27OO8p0mbqT8cElRRMpP5kTVMcRqqlZtX AluIV3GxT4zWU8Gbp0hkvud6nKpamh7WukmJ9pU9B2e/B0Xm93OspfyGbU1rsoxqQk/aj4PXx/ CJQ= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724292" IronPort-SDR: U1FqOlNtqG2VwS9WKEsoz8vWTFSJ3xc8pjGMUJKKuIEV/s+oDfba9qorW19fvudJODya7lpFzX O/bxa4Wnh01vBfH8X4N7dJsLRpyH93EDQ= IronPort-SDR: JvwDJtS/Gv8XA0FFGVmnwKenL5NIkLT2eutp8R3qgLGytV85IC0qLhfAYlyD4oKmCtyq0vQfsG gt5o4LJwt/qw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 10/32] target/riscv: Implement checks for hfence Date: Thu, 18 Jun 2020 23:24:56 -0700 Message-Id: <20200619062518.1718523-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549079; cv=none; d=zohomail.com; s=zohoarc; b=Zt7TXScwhLZTBmUjAiVHTEkx1jUezpmPgjIxpSimTJtS1TvzV2hsMPTT/dEomXrCRlJXopNTdn0HWPTCY+Wo7a97FkV8kB1EFaHPfG00U438zlHbng9/+QUzWv5qieQcPg4a1rKjz4ocST3bI/Mzap4AHe/eFlrce/knz1jDyhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549079; 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=S2+MQA/540rmcp6fmqO5CfMx7UrjPKNs24ulGnwnpFW5lR/i0JCB/mrFgRzjnI3mobF9gO0Ih/jfMVaBsezC6K/Q1NBDIMoCa1W6SDOOrixl3V+hzSVcJqoItn7+ZXCKTrHjsWUZfVAe9d9OCJ3tQpcS9M4Fk96rSe/PGc3zknU= 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 1592549079932108.3171932518502; Thu, 18 Jun 2020 23:44:39 -0700 (PDT) Received: from localhost ([::1]:42344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAlS-0004ln-Ll for importer@patchew.org; Fri, 19 Jun 2020 02:44:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbz-0005hA-W4 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:52 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbv-00028E-JI for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:51 -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; 19 Jun 2020 14:34:29 +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; 18 Jun 2020 23:23:39 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548488; x=1624084488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LYV/HV2oePnGMNLANWSHYTsEansGO/O7noO72QkqJrU=; b=PLJHq7Vuv6NS1ZawfhrecgtWIX49fz0W+zr9DUSKvK2Y8ypS0WglRg5K sFlyU+l3jckClJzfLC8YfGZ4kTL7Q7TTARiwKgh1b6Jq/wnF7dMGX5iM/ tT4dtlfGYpN9IwKGNjrDwK9fIHHxc5txrehjZyVGTlY1dpXZQFgXn1E2j cc+uxFQcohoqSL9bUfdbke8mh/pFP7AlaxRm0ZPJ+BJ2uKXKw2+xjzvmi Nr3K54yNiHWQVq9CkO9gPKWEPEqu5ah7qxNLvZUaY5oUGi5Ed6WFdmuJ3 3oojY2FjKpgY0NieSfiChdTHMAQudOpYdAhDZllAVWWXXwqYvxKUoGzP8 g==; IronPort-SDR: xxEsy2pSeeTOQrljmUGSJiZdCsh0m8qSahPKms0hJn1YCOVfyA1eA/c1QksGf0uQySuFH5a+UU DihYXLm0OmrrtzSYp7nCDAyFMdWia/OoNfF7A4jZoD2VvtNJQwGCtAJuWYt7npNcO/usI3x3dW 212KWDQpYTWg4pF9o8WZ9+7vxwDzXBPRwAcsCrYgWUYJ2/dE2M5IyXnRetHexLgLpy1kijXV4W 1ibOzeJfVj8lpm45Q4puv22ZQ+ZW+h6/i5pOJzB1fMvFb3lkmC8S5WvBfLqhgN0fv5enJu/lam SL0= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724294" IronPort-SDR: KEzOHV/pEAMIl7W6zYvjfgMmvBPHEFmpzzGu3CyUpL/blfqsqzcAuLPDdBifyVRkDpq3o5OnHP XaCWbC55HsbEoUUft4UeAZxyQ1zOIxSAA= IronPort-SDR: NmXVdURzOhc793feji8UHhM+LkGMc/kUhnPxH2RZRdLSE7Aqd+CVnAWlea6rYoBKNoWemfORui en/n74Y/8PJA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 11/32] riscv/opentitan: Fix the ROM size Date: Thu, 18 Jun 2020 23:24:57 -0700 Message-Id: <20200619062518.1718523-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592549608; cv=none; d=zohomail.com; s=zohoarc; b=PzYFHkkkkw/MuLx9pbDrbITz5kqFYFbgTplWm4EWw0qjjNpdGovCTC+e3du+xZhlCnxpAGQr7y7FxtGxG9FoIJtZ7Qx4RBEd2K06kYgyk9LL5pByMuGk6wvbJXezxZVP17kCOybL5ernqAEkhyg6EjGY4noWtf4jPaH7SE9Y6ZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549608; 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=N7DTmgk+bRVBNy/iNjq0JOBYLJd7IGtGWDW1faU69/QUj0gH/mA2E5oAdPDgzYHMwKB/ymQUgZqxhteRcfYRpgS2UydWqOpt/INnRtzFJWqwXQS1ymftJjSS2mIQFvMadXqIeA9mUC96y/ClzAe2SA/RIMYUA3+GolD9lyIFYUM= 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 1592549608010745.222674190507; Thu, 18 Jun 2020 23:53:28 -0700 (PDT) Received: from localhost ([::1]:46642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAty-0003mV-Dm for importer@patchew.org; Fri, 19 Jun 2020 02:53:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcB-0006C7-4W for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:03 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:61617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc7-00028J-NC for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:02 -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; 19 Jun 2020 14:34:29 +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; 18 Jun 2020 23:23:40 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548500; x=1624084500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CHr5IFEEHjwwhDrA+gfB1EUHeRDcWu0fMlPUFNj3b2M=; b=EFIXix6H0wDdiry3XedRzuXfB812O1a+s0ueFDhoKnpxHuqV9Up/JF01 Pb135RysChy6FTyhfQX2FTVgYiSqSYEq1ecdqqL1StrEgFtfYLcTbfqXN gMDvxp/rKlS7U7Qlh/x0C0XEUwzW0CES/Lii0y4Ihg/fL+0UCEMnbD1j9 jk0ItVBBbWdaGjHv2/b9r9YplwsNHH8TaQXjdd6U5O4OUcbAmEEAsTipt ga0apF2n+5bOFZEZleG9zcnUBr5FEEhB+zv0gqcj+1IkWSRAeqHDiP3ly qpngB80IK8BjvNA3znUtOtkqvf70WiDNdm9MWghJJT3U11rAtxrW7Pxmw Q==; IronPort-SDR: 7O0Y4rTdIwKH4RnpvT8Sfkex5iEQK3PlrkT1RskIUYbu/BZMKvrHnXG6xnixc8RpdHZC3Xy28B 3QAPzU0btaM70GWPV/yjBypG6dxIsIF9tPIkXLEFUv/o+PMmDrH5AgfXDLLQ8q4p7KL2SoLIga lcEY36cZH94xJy4YZHSk0F3bu5qSujm5pgkBNlXuXz7yJoGo3EDWoCjfZXgaKUdH9Zg7e78jNY I2nwm/oio6xcFhvl3zo42Vf/nLpMhkSPAleC8r6acx8iAchIqpnRWzZr3Sdwj/QxHJpczydxkp d2k= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="144724296" IronPort-SDR: SIwuoOH46PXkOIe9xTdmHKxF3Z++7oNq+VZ392laXCGE5OvV+JlRM1v3r1XLYeAw+YEw/HGLHZ m+FteWnq+3D87VidTzTsSXDtRSYeY9t6M= IronPort-SDR: h82bMpzqesla6Oc48DqQexENAuIAITg6rOSA0wiTcMoWf5wt6MphYJ299Pswpfrpvb0TG2C9y9 tkZDUcHBXnYg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 12/32] hw/char: Initial commit of Ibex UART Date: Thu, 18 Jun 2020 23:24:58 -0700 Message-Id: <20200619062518.1718523-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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 02:34:26 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 Mon Feb 9 21:27:02 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=1592548713; cv=none; d=zohomail.com; s=zohoarc; b=OFs0ja5Xy6H+L9tWLw3Q/xEYQW0vF9XUqxCLDezNkUws9qqWSXpJZBf0Q5U+QdoDH+gAhRzaXe/2lIy2vwpgSI6EcPOg65rUTB922S5xIDSdvB+a23pfFeT5fwWTMCZSnburdN5nlRPxsHYmp5h1SRybrN9MdD4VMdgtYLElP5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548713; 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=AeWgXfCWEeQa8blt64JaIlUnVsXzqN1eYucpVAY3k6wRAAp0TMpjspx+t1QAVeYqhevn9tR5D9uiw2U3u/GlHM783kpJZPVC5q5Sh/0+RZ6/71RU+5c+T/72Z1O9AXM0hp6KIurakOP3UfaMxkAJkAF8J5udY59FzGWspjtw6wI= 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 1592548713164480.4056755169836; Thu, 18 Jun 2020 23:38:33 -0700 (PDT) Received: from localhost ([::1]:50554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAfX-0002q2-SE for importer@patchew.org; Fri, 19 Jun 2020 02:38:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-0005UT-2N for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbe-00028T-MI for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:34 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:29 +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; 18 Jun 2020 23:23:40 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548471; x=1624084471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q84SoZ/VTr/fgQthZQkif3oxb/7JuSt4f4aIvRC20gI=; b=CNHOTU0/egTnu3e9jdPl+F6ea8PYZcqVTOE4h2Pz56AqiQE3R6bPYPs3 Tr6wTEyqrUFpRvPYSjyBnsDfMsEHpcPyZx3kwdiKA2iFtu+I6ue+XAQDx NdmeAlt3Jvaj3Iq8Opwxo3Zn4CbYxzCIFEAynwemwxwTGY2gKHmpXk5oQ FNLuu4/zlqpYsFIxe4gFH0LIOXXrGAz2C0LMcpQWMqJCcSLdZP9bRxSY3 mGuHOlpjvxuTxB0vVGLFNd1SbQCnkc2+FRxZPDtxlaBqMafV15uhJG9mS wVtwPMpXsUL7eFWWejZsmFFRq3bnBtVNzLBjhEM7OpCVO0BTgBy9CojlX w==; IronPort-SDR: nEAjM6hyf+CNH7Dp8mmVkqrzH6tgueNgktSqsoChuxt0a5haUGxQ86vSJBJYsShlDhL6CtC9hX Rv1+LsAUypL68o8bvh6WFKZq1Bnw5M4q+gAj/f4pWVPM7A+4jdA4s6Ee2sjzkKO9ySBXPM4C5/ rIWhQ7CtCrnWl9c/K7zx0CSoQnNyD2WJLTPBoCZo8RdVFz8rkkQGug2Zahjkhhycn2+FZZ/Xsw N0S/s4rFFSB+g68cKWA51BFdw2Xutbr20odM9aj68E0T4/RcoGir6RT4eR43VHfTRGDiUa/S4z PPs= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781916" IronPort-SDR: gm/E0ZMHnC3/xpsRCyXlbpEYc+Fae25HmI6LcybgxkKYfz6s2DC0O52PEgAEIuwjWa3q9sU5up ZHNyIAadbfQ55hTvDnL5oQi6sQm0LZsAE= IronPort-SDR: SucpHE73Gq9XYpKhLxQ/RwLfgyDhHqeNaIp504xmXOHKRizly1YDRryTD8c12byXP9LHOokoCH qMrClDkhTs8A== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 13/32] hw/intc: Initial commit of lowRISC Ibex PLIC Date: Thu, 18 Jun 2020 23:24:59 -0700 Message-Id: <20200619062518.1718523-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592548892; cv=none; d=zohomail.com; s=zohoarc; b=beRDvWnsBeyLehv0Pdisc94VvA01X4WUwEsaPxnrGBB0PBVrKPPPT0XcDgTOFXqiCTjp/51OhJT9LzjqRkYkhKzjlxuwEW9O5nHD3j/XcToklLEi0gbFioYkG0tlF3becPowh63mSsaF0mShDbB4QqNmm4y2NeAyeBhGb+ND86A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548892; 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=AeSSWuYeb419/mCv+iAQ5TFEhnrM6Fe1EGOIbcjGtC8cA8mEaHKOuOqWKGb50sUMzB6nFY3abbZJGKgblZ1W/LT8t1EQ+UgWh4pkSs9vtvhQns8JBH856+6V88O14pWYmGUNF0EXuzHWZktkG+5S/qDAxZCgPBfMzuE+j1snE94= 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 1592548892914443.7659433932065; Thu, 18 Jun 2020 23:41:32 -0700 (PDT) Received: from localhost ([::1]:58828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAiR-00077i-Jf for importer@patchew.org; Fri, 19 Jun 2020 02:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-0005V9-JI for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbf-00028a-Jt for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:35 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:29 +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; 18 Jun 2020 23:23:40 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548472; x=1624084472; 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=moJ41rSj4F2AavHRcfwG1ry7s2zbG6UtgPVTpWAHM/ju5lxah+Qb3kCQ sisCrZkVQejvY77NLPjqgwt+tx5+OgCfvgP6Q3woeTR00BDoWJCZX+RuC UQiMHuYos8IHtWOpoMIxc79JGMp27CNGxu/lzzIB3Z6Y1ADVQDEOrR/+b Nr51+hSbSjRaL+0hUGALLtFeknNUzLDsXVWfl0AOziK8DQ5OmwdQkRE5T FDJioK6TluWbK+wg6CtXgtuoSoy/BMM7yACdvwRFwU9Q0ElZEqKX7un2g 24XIa67P4bcsfU7M6Na1OUjBHgfo3T6++oklwAExEQucYYKevMOuNHRwR A==; IronPort-SDR: OvNG3cmyKU/0Ikc1sy5fIqqphJHQeBGTgF82t07ko8S8HDsIUhJvrGS1SCO/7xD+2FS12/mrkT TtfhpJ6CEbK8J8jJzHnsZNEY9Uhd0OCSB8YnWwkSgmApWoJDhg40n3UnfILZ60foHRAgIdg82R 2rkTDTn9Nbwwylrt3U4f4yTmrJHlZBOa78vXppNFRT3uHSLDo5quBy9ifRfytAgNE4IW1N00Mc XQr7Di4/2uziai8sYG04SuDFxD2QR/vv9iqlhLBIq2+QkvSurj4HN3EGRobCWnmBCKj/sxXxHb 2js= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781918" IronPort-SDR: wWfMvIvRaxFwtfoNihxJaWe6ntWRnAK64qRTnpUELl3uAJG6xcrEqp0oR+mPoKpKqkZAAujb6W v0QYqGF842Yadk7/90LM3+drwpZ+wOHf0= IronPort-SDR: Ozl0bhm2srlwFF5IV+VWSnzy3ypADeIA7ZHQG38tgopUsupjTC0KHyi1v1YgReTu43adbBDr1V kreWRa+hG24g== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 14/32] riscv/opentitan: Connect the PLIC device Date: Thu, 18 Jun 2020 23:25:00 -0700 Message-Id: <20200619062518.1718523-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592548709; cv=none; d=zohomail.com; s=zohoarc; b=F6kL+U2PEVFVXidrKUemZWzFJQdzTW5RpgZoKXxnG0eUWS64Id2+OnFv4ezFAe5RT4i2p5E0R4TAbAhbRhNgcfhGr8GhdYxfSpsMmupyKVCVDfzsVRC8rri8nVUct4AgKhUE3hqhxX8WqHf5AGhufpY7H8BT+EnDlrEKBbU46N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548709; 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=fwXrWJ2/FoSWfx1ZdGAsTNVcO4JuoWEX2iOkKh51E3wE7atR112pL2xqZmD38sDcXFyB/aisev3U3tnLCfqMUAmdw2GKGrbIGsYZBe3QlYKyYtW3N82bkt0CesN4pb0cvdC/Y4e+QMnlpbYeJI0ayzcOraf3wpJMFL9oyfTqTl0= 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 1592548709560331.2794020493229; Thu, 18 Jun 2020 23:38:29 -0700 (PDT) Received: from localhost ([::1]:50252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAfU-0002hz-At for importer@patchew.org; Fri, 19 Jun 2020 02:38:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbi-0005Tz-Lo for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:34 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbg-00028f-Gt for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:34 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:30 +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; 18 Jun 2020 23:23:40 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548473; x=1624084473; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wj2tmgrLszFAAngO5h43Czzs+HrNQaJZBg5sgRJ6o9o=; b=S52Ge1op17Z+jOW++zF92+2FBjlLmkxUhUWVsl0U200549m1WLoGL5m9 Z/xw4rJXub5xgbEWY4tN1/3V0R+YgwhhO8eodWjSsRFrOWnPzDHggFNDx xHEe4sjpPoPu94rKA118OlvUkRwchFY9ibPa+0Vl+ADGF5D56A3+pGFj9 e3lN2Uf8u7apKdKVzvgv7J6xXgp6nGPOydaKN4TWP1GizFvUHJ8KMcftd MOR9MtQ+tIpeVTqM9U67GfWtrXX7CmAjjPCxy0FyavhHyyvXcMQfBvSBu P6wOVhEXqe8DBwqNU/EtPMqqGJawRJFhsZ7WGCG6afx9fVQlzpB4pIiGv Q==; IronPort-SDR: 7GFrai3RbGF1kWPy0aGDqhsLxISswOpe4Py3pWnQSqapN72azZFmVfDAoQQgslf1PuB2ChceRl 5gheyu6UyT+9X1WM5FmJ8rsAc8sotMjzVWHjFM4dyHd2PbrrXObezKHwY81hZokqqFQBc8q8HI 4haNgNTm31fZ0CM13H+uCI8FRAUx4wK4FN16SiiQbiGZ3boxCG/WD5AUA0uOqulkMAhjCQ0BHi /gOsF4EPXjkZQcPebfqXgjwSbj4zQ3ujPg4wzCrSr611DhUAQerMGZXBUR3y5W82UDH6wVOVz9 fYE= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781920" IronPort-SDR: 9+Ox1jYGBaef3cynlznllRre/envWCwKlr7FryYqiTu7M7jTCGwto0vPaEOF0AgJv3SdwikaVP HlRF0MuB4e/EYvrqo7Kz/+IdZ/AyniQWA= IronPort-SDR: YLyn/k8TQWXPJgUbZrIflakEmmmeoVcHMAYu2TZBvMe/K/LqImIoEqu7PTElE8d6u/ZdK3ETvN FQTo8Ulf9JOQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 15/32] riscv/opentitan: Connect the UART device Date: Thu, 18 Jun 2020 23:25:01 -0700 Message-Id: <20200619062518.1718523-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592548906; cv=none; d=zohomail.com; s=zohoarc; b=iKoAGLK3fVfF8wpSf7ims/70ROf8BH57dYlUKz0530nHbeV1CY/aedmAcK3k29A0K1yK2SkuNS/CNawV2bP1Ogx5CWPcRNGCff6odPzz6YDLoEYUhiRDHC9GJ8QVJyzdusYcbzy+vM8d+K/CdSonL4tKKf5qwuaeIzffgbkPUnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548906; 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=dy3AupUbrsDO/QZxp+2ESCKQHJtXqk2KmxXSt0fT0yxbzAv3AC0KuzkyzrHncd8DhaNO3oDS2vUovQ1+IUhWVSxSZoYK5r3dVebNKXRH42oKCVFJwWZVVudvwVOipOGb9MV1FT8uDC7tYLf8Vqr51zgFE20VVCQqdM0nOI9/sQg= 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 1592548906488629.7090508988865; Thu, 18 Jun 2020 23:41:46 -0700 (PDT) Received: from localhost ([::1]:59066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAie-0007OU-Cf for importer@patchew.org; Fri, 19 Jun 2020 02:41:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbk-0005XJ-R4 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:36 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-00028f-20 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:36 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:30 +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; 18 Jun 2020 23:23:41 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548475; x=1624084475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=81HMh1gHLXQkIcSglIbxP90s73UN4Lp7ZsuwWeLGYlk=; b=AIWnozUifxHyphXIPw36HMQDmu0I8qx15V+/jcI4bR0aBqNGcmXBZ2zS Ma6ncXSU7Rh26PYAyoWIMTTVjG5M7lu9NvoQpjhzWTHpzGHqM7urPQ7os 2sBc3Lun1PDm09BRKqpy9wldeV2fpNUXUfmJACXNicoGJy3FzdV3hfztt PcXnnCkLxJuJuA5yU9Bwd+8Mt2tRVzfgVrwZgfX8JfOY+5v/qRxRCRyQj RkkwzoFP47mIM81aNX/pmZB6XNbfbr8cjbfHIPikNGPUgveQxwjetO6ZW magMKFz6Rl/xXnrOC4RJuorwTVbDjZyN9pj2N1yqD9IVOIyziR6KyqZTL g==; IronPort-SDR: 6YU/xc7pB7HBxSGyrZ/oXG4aSSDqu9kWKbjWMT3pAEdUwwGqHbTqt5O2C1Zi0yTcmr+jsnHqne 32bUHXofdaq+Shdm1DwuayKeUYwyBGO8/fdgFk/KP2szxEVUhdn9+iGO9fSxoH+/PSuJJbkqDR yJ3OWlmwYe9NYtIwqcotPUEg+b8frcr/LBKIQcMIpe1SRcZ4TycZ6nafuSHsbmMaEWG3006qom 455ZFMa4L0eyBFlPnxo3YWnT/VlvuuyW7rjppCvNdMmW+4R5Cntj3oqrVNHvAKyDB5STDfipPt KBo= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781921" IronPort-SDR: sV0i2k15rjEQxay+ane3BjlfzHC7j3/nQm+D8/MffmnneQhpep7QiWtUA3g8kiBOzY7/aosnsn D9rKobpukEv9y5PHzELbCj8UCBL/BKDK0= IronPort-SDR: gQ4e8hMrQWV1EPk/fMwc84GL7zT9K2XPLcT/hx0mElAlkpKmuhDTNnw9zqHuRdS2rQjJKikqiX Gt3mzh2pccrg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 16/32] target/riscv: Use a smaller guess size for no-MMU PMP Date: Thu, 18 Jun 2020 23:25:02 -0700 Message-Id: <20200619062518.1718523-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592548789; cv=none; d=zohomail.com; s=zohoarc; b=Q+BTw2eTEHaS7dKGw4lOOooGSsp+suL3iuZmiHlC9sTEflXp8p10XMq2yT/96ffEKykRFDqMMLjMaR6JcEXmTkkyC7yqprDCW4Almhs7/yGg9D5PXbv465f0vpNPWAAeFARTsbPaC6fN39UNIdtgPGBv1OGUacK6BDVAWBa0PlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548789; 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=fKg4Tlaq5+7cqiUb+zDj4VMXWusXQQiS5auZCyhvQChI873b1yIXeoczv+CCb0C9ex1g4iUnvk3W8KD1KIdRpr++xJ9XtYQnryTmZA9Z/z4WYTEMfVRM2C2WQX7gjhN76e0ENK5V51gFs8BrEEs0lA9zyFdtRZDFUna5hjq9088= 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 1592548789482223.34685953729524; Thu, 18 Jun 2020 23:39:49 -0700 (PDT) Received: from localhost ([::1]:53414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAgm-0003yC-8Q for importer@patchew.org; Fri, 19 Jun 2020 02:39:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-0005YA-B2 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:37 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-00028T-CL for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:37 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:30 +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; 18 Jun 2020 23:23:41 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34: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=1592548476; x=1624084476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MwmhX+QruCR5bliKSXbiubjgtbRSUKmWFEdzq1sWRbI=; b=cvBOCySs9CrTLqib2jLtfpVw5LQeMiJApl5pXJM8KCM+k7rS1pugYIsA jYHDHhyoMor6k43HYTT5dn0dBzyzhTrcZKLgJ40x1AVPE0mTeOWwvQN8C vpL28CY7rXz6IuLmvofLZJHsXS6sG85ezqwnW+NtkRkp+TPpK2EpvfW80 kUxqw4pLZjE4jBknrxrkhXkOg+iY2KqK+yQPqRu/BR3UwaxbnaalvWd3Y vNJx0HzCOi8jtv2v34O7VtyMRUH7v3RecqEEQxtJcuze8GU8I1UjMyANP hwTw+HCVHOy5inMyO4lffNRIJJHSB6wPUcgswDeG4ktQNoGSia9FSoTsf A==; IronPort-SDR: HF/kHYVWWVzod2YD/EMTlF6xgq/x39y7VPOOIXHhcSiI6dFAPU8kszYkTTQFpKxtreFa9dGGm1 jg8ootnXSALlCHKU7Dk4giTR5DspqBMwLGHJJozmiNc55+1GhVM0aJ7FTaK9clG/ts1pJ2VAPa x+Npl3yG3u6h/rKmMwN897qAAOvRMJWNw8iQ4QwQ59ELYEvSmKSZfcxU6C1SlRrvfC+qqG+q3x 5U9+dcc5wAr7MmCxOJbdIJat0BPmrFznm29ZcUJ2xUL8Mbeli/371MjIBoc96l8IAIfaN8fJvD OTA= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781925" IronPort-SDR: 4XhqIBdQeCsRN0wyCZ6dZkdqy6xU6ps8rcjsV/+HcqDVfZxUFpP5QiXVJY5Cg6jPfv3IkfyaBb WpDKkwq/0kamdN2CuldWoNVTNQfj+SemM= IronPort-SDR: rGQBAxLQyNRAPq17qo3c6erff7OjbN+bi9z2YoQqmQW265Brqj9xJ35pSilsguhnwPbpW0ws/W ARDGnH5YOzEQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 17/32] hw/riscv: sifive_e: Remove the riscv_ prefix of the machine* and soc* functions Date: Thu, 18 Jun 2020 23:25:03 -0700 Message-Id: <20200619062518.1718523-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592548893; cv=none; d=zohomail.com; s=zohoarc; b=ITcoZFcosowVl1AXPh7kdmxecF6rrmaROHFFMlCPum0wWQlFARh36Xd32OTxTX3om9QJUAZx8uirRYvX21NTwASBreEw+T79vayNu//jCrQs9tDtT8orTbxD6TKTBlEo+xfe3pKnjL3KL5eL4YZVH8igTV2Hef+C6MY21s0c2Wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592548893; 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=ZEoC8sr8SyCgEqW8xL+EhNFG5Dj6Ip+1Ljb8sM1YcFyOMvgk35SOqnrw2cLH0lZ7xZuZQW9GBDGSTYN5xcaaEzJZNCSgwDAOoUqMtNdzlnErJAdAEXrJC3MzpRoAyDp+htDaEVoep9WukeeqarJ6qDesZAEQxvPIj5BFIVt7UQo= 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 1592548893069201.87044504633798; Thu, 18 Jun 2020 23:41:33 -0700 (PDT) Received: from localhost ([::1]:58790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAiR-00076H-LD for importer@patchew.org; Fri, 19 Jun 2020 02:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-0005Yv-P1 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:37 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbj-00028a-QS for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:37 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:30 +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; 18 Jun 2020 23:23:41 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:30 -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=1592548476; x=1624084476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRyEFMliFOazvxi0uiuNB7H49JK+CbFims83EBUndek=; b=PqT8Ju23w8FEdilHkc6O9k0f2NywYAk6pvCvruYPUBSMOWiq4DDZ2pgo 95shq9nBHc0aRu28aZtBulVd5Y7OcGdL9Bxvv51zAYI0RfzQo5sdrQcME tDNWyTyDzQ4vP13U2PmZYhYV2REDGxJE/62OLSpNC5JNiNz93TQapCo2C cotANKMMhSEzrWzXAvNPc2JjPjdlHmZrg5nSyGRwMw01rqcVFBfufDL55 F4d74o485YibZctwqPYUFbcN0RM9JeSO1M3zcS7yyrVB/+XO0i+r6ns9p oF3+wQUWKVGTNmO0D4yUd+XvOSKMLxjhIMTsw/DWqd4kNpG8mo5HZhZUa g==; IronPort-SDR: ml059JHQV89tWHLK/7jLyDZTNP9zfXFVGml5zzCFXZZ9IUZwiOF+DbCXkJGQeEihspz52WBooN J9OP+xDOpgwCHySwblIRhvIS6Bao3EBryUrdzM5Q7izxTMVG9RprWW/4QdYy4QBncnYlIfNwi/ VMJ3PnSt+f2uZQMDyzpIYqDSS59mDc0XYKWiKNEM7JaSrPXTiHjdM7/RmcglYhLl/DrGhuXROc oq/qzoMSTEjpo59DJHHBWWtW+KgZjY9IaQlr3KJXz+w98Ufl886wB5gOVIQOfpYoECB//tzEo9 7Ow= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781927" IronPort-SDR: Ar5NPiGdEylPFjIK04um8DRuA9mg5aajXbDjnIKMwINI4ywpx7Lw0Cug5kgudUHT7AAanNlwOq qnB6xCYztYqzipOSjz5B7+B9LVFR+FJPQ= IronPort-SDR: ykj/lQesEaB1q5SnDaWZ6LwrxjrrF7kflizWMIe3DwRZEuhdeu0HUqR91gQsXzWAN0T3iQcXie wBb9Ydi5FcSg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 18/32] hw/riscv: opentitan: Remove the riscv_ prefix of the machine* and soc* functions Date: Thu, 18 Jun 2020 23:25:04 -0700 Message-Id: <20200619062518.1718523-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549304; cv=none; d=zohomail.com; s=zohoarc; b=X3MQTvLi9okkiwBZpD/bTyFBuLHlzWPRdJb31mI9YUDyY7D9jX34IVTdFCTZaNobdZVhFhc7so54ukjV5vW7ZwEVSBEZBROdKUnf1KA8/3a5FLJaEDrAywBnL5U5vC23OEYCQ1tse8ilhQCSgNceWcjWO3dxJRnYSXEMmuKnHnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549304; 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=BSyILtxrCibHGZFGjQAUiMowoSJx3p9ZM30zYI+EH7FDN13KhPd3X+Q2R4ueSnBXshcjoyzu0RLmeDwNmJqkwdvcgGNs5Xpqi1op0nGT2gUOtw2TFVsUpvkNyW1STcc4FIGsTA8opTMddvSG4UDJA7klhp6E7ErqpekCrMhrMCA= 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 15925493042561017.3581420034863; Thu, 18 Jun 2020 23:48:24 -0700 (PDT) Received: from localhost ([::1]:56162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAp4-0003Cf-K3 for importer@patchew.org; Fri, 19 Jun 2020 02:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbp-0005br-Jk for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:42 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-00028f-4X for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:41 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:31 +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; 18 Jun 2020 23:23:41 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:30 -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=1592548477; x=1624084477; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HF1JxGXWDSpTRfYKaMM0wJ4es08kDgUw2iC6UdUH7F8=; b=oYcbfj7pA+o2LMtfbSZRDWM0Ey3Nh8bgnQHUNoQEglzJQNkgW8yvU+Aq r+7dVr1uwfZrkXTHqex9XbyclJ8XGufJZYMsHTCLVnOMxHZaNPW89WFbL 1Yc5G1kmhzXJWzqnuWSaoZm5QhSon4BmT6pyl9ltSCazF3TxURJ2BFgaE 5Kld1p+u5FoAsWySpEikaRa9byeuuZHlAp5xy3l5zyBcjUzSWg8wA/FMJ EviSr+xNCWpapkdF3BgnX11im3AME8gwKo1t5vAjQYLIRlrp7u7KEo3nt ob+sSMpjNekIqTUFEJ2KZL6xmE+bprVxeXFIuHPVThUIxnpX/AAw7QqjD g==; IronPort-SDR: 4yMVrBeNVTS7ka6p0qs4zhwxtQ1Q37IuRW+5GbxoD9o+3UEYdYdWVOOO+wif1gZhaQvN+IJDgw TMdGG2bEm9MPuiJPxbyCrJBgEv8Sc0n1TJcTuCLExGwgq5Xq/vGmkQJWGuxUwME8jg4yobkeaJ GL2RRu9GBTLA8gl34z063cVlAjCU7/W5L/wmcUT+lcxbGcnI7cvI9+O+Ykk8Iy7NW0RNdvjeiQ D7or0S17mMY9ok4w+BzOG2qr8KKkjKHntj2PLRZjhLlmnuCIunIk9KlnnCCSdkTIFcIT4KMFdE UJM= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781929" IronPort-SDR: 5XnfBk+JFbh97wQrIrIgIFZJNmN6tpEny2zjUL71zseVbYdE/aa7FViP4qOlqL/WFJwNk62t3l mKjhiixIMancXNmJ5k5jbSKzcvD+235mE= IronPort-SDR: e47mLNcURc6qJyA3J6M2zAz5yom56ZfBOzq9LKu81bSop3pgTU6nr/ibm7MU63PPwBHOWmRm6Q /2BUlazKZ7yw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 19/32] hw/riscv: sifive_u: Simplify the GEM IRQ connect code a little bit Date: Thu, 18 Jun 2020 23:25:05 -0700 Message-Id: <20200619062518.1718523-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549419; cv=none; d=zohomail.com; s=zohoarc; b=SmmIdexxZ9goA2p6tbHzgJqoM9IJDjNODwl4GPMUwCzAbw9OXTTOVZ0PvKeDGlM9FyTK9WZN+H09VaFQpKQTMIEoOAOu4SvCxICYO0RXZNeZONCjWzrF61x2zXvlRroGuNAZuPZRExyBxwzHiSN3wH3Iyc6vB5P7Vdfn7nFZCI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549419; 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=aTEV7rpZhRTdp0uYEvFoMJvt0a2wgF+c4v17kr1CEqcosms/pts0XgIhNgz7nkQ89pluSUrLVPmqVMxoilno1YrpuY0ZgVL5clepDwJX0nH+FuMTi2lkJFvkMy827KOPaWXYmTn+nTuY0eWl2E0oYuUjCg/1bYlSjr6JOFa4Iws= 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 1592549419878340.886195905784; Thu, 18 Jun 2020 23:50:19 -0700 (PDT) Received: from localhost ([::1]:36180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAqw-0006YP-IM for importer@patchew.org; Fri, 19 Jun 2020 02:50:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbt-0005cQ-35 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:46 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbl-00028T-L0 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:42 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:31 +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; 18 Jun 2020 23:23:42 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:30 -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=1592548478; x=1624084478; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dMdIIDoCv7W8aOLzjHKqNqNnPV7covUPMRH4EMqR6ec=; b=URcdkar9hTM/JiEpFqmaEur5f1xO5h9nra8joRGTdeeL8rcljq3l0/j+ hWqtcFwPOAbHvmsCFFZPTxdMPceWdgEWnpy0hJ9J2fYIucFGCeaHNETGn +UBhCQBYLpskZLsjaGyjxjTanx5UG1c+84H3pPiRm4z2T1XzULA04iaiy 7gNOzrZ+ICPtaypF+k1nk7fG3P7nReamV1HVI3R6lVh6sBaUbXekp7ElC 3Ioa4BG4CnF/5GzeDNC5bY9qpl9N+IfViWVzdF78hRadMs98/fGQPRStw tS3T4T/cwT/TDesHvwEWte95w09XB9ZNXLVl7BGm9NctaBlFEq/k/1cuF g==; IronPort-SDR: GPo1ORM+6DD6UrGp5iGX1qzWfh81LiF5++NKx3wH/IFviNqb/uIuVY9YEfvFDSNRo/l6hM/TDe OZqNmtgevVr4sXA2rlBQLa0QH+RJF5Ho3ghmDM0Xth+rRVOICWCRnQ3QmGrCefKNDVIWQ5LtJn oCM6B4SQ5dQmXy9Qs14zUVlkJKoDdheaKmbocHwAAM7lwzI7AEIFP24afJ0jmKz5qUOdzfJuil oOvIbgvYh3xb0brYhMHoy6++ZeqDyd+sIxDWJ7233uWKsbObIU+WhMHEQnwZWyRusAMvYb5qPS DPM= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781931" IronPort-SDR: dN9CfW0tLmdBjjdAlYy65J/0Kpvo+iREE8FrYrQb791BPzvcyq1XWapY0DqMtR+D+105Szya6j CSHnwM0SXf2TdGfXs4Ow/N5ZMt2q4K5iI= IronPort-SDR: pLrRqrD4IK9zsAvZNTw5NB57TKcOqiyYVv6duzfUXGVMQceD1Pg7vyUz0FBeskxv4+LbDSQ6xx 6HSgNldwaWWQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 20/32] hw/riscv: sifive_u: Generate device tree node for OTP Date: Thu, 18 Jun 2020 23:25:06 -0700 Message-Id: <20200619062518.1718523-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549520; cv=none; d=zohomail.com; s=zohoarc; b=lgR4I9mhipTAEdtO2OG+kqubfaX3nvp7GaRkkxmQfR+Uzp5HK8vgGpfz0z48GqgBz9Q34fjwlbLAomd0ctolMje4PWZtvaxbrU+5LpYjm59opKoJeOzEvajD2ma+vjYhUMraOnbkwGbE48AUza16GPt85wOTVErKXuu1cYdd4cA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549520; 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=deTRnC8eNJzbe25c+94E7LjveSpIGtnhQXQILco8P52uwS/U/j8s1ibzvKuJlYGqj5i734Ev8CAaHs6ImnsVLHrShoGUESCbrb90Ys2g0WKJ8B9HNnnshlr7LTw745X+tVvTgrH/9+j44uhui2atk6LfdpvB18Km/F/uN6agrzY= 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 1592549520111545.3035548321402; Thu, 18 Jun 2020 23:52:00 -0700 (PDT) Received: from localhost ([::1]:42352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAsY-0001qG-2f for importer@patchew.org; Fri, 19 Jun 2020 02:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbu-0005cf-Ab for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:48 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbn-00028a-JQ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:46 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:31 +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; 18 Jun 2020 23:23:42 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:30 -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=1592548480; x=1624084480; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4Ag3dG3gO5iJShtsvDkPTUJzzzPAJlVfRVRDsoWCqx0=; b=pxI3fjIf+loRcenK+AExuQeCANCg16y4CVKblf/BYpCN42/XmrQxUTf1 L7qgzwAG63YiBJqRYC3Xs5SJBxGKkJpJ4569i/XrPUSZplB411PQs573G W0UYjO11/vu1zkVQyeXY3Yi5Ao9SpoPYNqFrozg1qdFxkBCBUS8+l7XlI 3J4xtlV8+Zvv5RzKFUlEsakHV/uyVWD74nrQmjGgej3jkMxtkbxwDOcwV JU2SGbwYA4L6eGkrcbwA1UQc5vTWo4AtiXyp0fELvNslfpqQV35GK9k4B 8Ga7lUK+mclkQ4wvQuqXH3b8HfxqfD2VVzPPnkjKXs1uNI6bKuYzhPa25 w==; IronPort-SDR: VWfqnC7A1lBLneAMe1dHluURCWQX8J4R/2DnuqCubZYwEU71vlzsUfBAAuVt4HoMnp8DrAx7o+ tNHmsUgQMHgJUt26rsD1ayQ/nTlCGJ3Bmw+x5aUnafhz45T29ShZgXT4lR7Ygu/7ABVzNcbrLQ iZl2pZWWuLsUyETqEfpnXW6ZmXsbk73dFfecA1oWYb/MsDPwyRfYq+I3iJW0BHCV4nWGEpLtO7 X19akSUSXQf62o04iUP7eR1eyqE/Oai08nuyuj27TQMKOxIY8AkoZbYAbUHJB2x1+B2Gpt1URa 7YU= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781933" IronPort-SDR: 9JAxhJKX81uYbkYkx/dd3xaut0z04TDTpJG9+34Q1m3Gq4z/mCcz9aNxbOUsyUgHWuH3R0ans+ q04HtxL92zXNb68SApxUw2sKIDMuzn8lI= IronPort-SDR: +R53pKQkPLpYQTgFYCIfRuN1EbPJhE3ZLZmB9Ey0h5oeQz4gLg6tnAV7ALukWKhwbDlvBUILXi CpbqirZwdBOA== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 21/32] hw/riscv: sifive_gpio: Clean up the codes Date: Thu, 18 Jun 2020 23:25:07 -0700 Message-Id: <20200619062518.1718523-22-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549037; cv=none; d=zohomail.com; s=zohoarc; b=Axq2LRHFDrzGmLtDJBvEMprbaq7Hg6Bav16eiWdFQG1UB8DppcasyKNmGhmmgJwTP/cp2RJjSn+oeKqGrztuzr9fOz4W3CfdlwJ1l75LWbKJ682q8lLhWH9qjDTb/Zja0aS0oWZ73g1M1NJBKSOJZQ+tTkp8CUkAU8g9jTDzko8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549037; 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=QcI89zhSh+cv4IIQ03HKCUOfHQLB1rtdT2/bHt0vxMmR7Z8EoydlohRcK1YrMCsDBVCZjok9ZwUNClNA6MdAsVjMDUdTMx/fX0LRwi+5y0YX9DQT3aqY1Oksy/QCMqyZPg+p+9S3H70CGbFG3QecGgHij0DEW7eEJ8WFT/WE0lI= 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 1592549037046863.868282364838; Thu, 18 Jun 2020 23:43:57 -0700 (PDT) Received: from localhost ([::1]:39122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAkl-0003Si-KX for importer@patchew.org; Fri, 19 Jun 2020 02:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbv-0005cp-FA for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:48 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbq-00028f-Iq for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:47 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:31 +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; 18 Jun 2020 23:23:42 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:31 -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=1592548483; x=1624084483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oPLJE6KNzWJHMq3vdNFTZOYl4tq3PNDGEUzIW+NYt6w=; b=b8ULGc3Uq01g1kAH1/8mEKOBa/N3YsDYX412DIdjXSRlsBiejrCCiAWG 9oW7Buzb7zKWbUjkZrHvNwL8mlRHdon3RyfYnft1t98mH4pEeNgeONr8e s7adLY5XRofvFduLCKq2vPzLTlE+Eoiue9jytjoWGUOBJqjl/dFlJ0WQD D3vo09EI6O+j6Z+l4i4BJk+Fbkit1c3PEm4IJ5tsDYkT0r/T2XAT6FMvJ PP3UUNCdFAJ8nHtKHZj+SjbHaMvTVQFO+SPYtctDFYioEGbBrIauSkghr g78R0xSIxv4aOucn5KGV+jl2pmks3dgfD4A2iiRmlIyaR+pfyiomE9T+s w==; IronPort-SDR: YVTtCrYyJlXBjBLi1I3avfS3B8sbQVJHQkFXgGEBnmC/fNzhjQyxqg7aA/gSVGVVkNyt/t7LoB fGMXrc+qE4vfkwA9Ynsw7Mqi5UIG/wjWHeetosj/AKRo19aB9+sHPJ7m0Lq4EkhNBD6Yqwi9RN xdM+I4DQKtG64fAWvMKoQZoOoFs63Uy9CwKg2MH9sCcRBQlPwU3jRWSKwhijwRd7nr7CfZBJsE 6N2qKSJfCCpePX9VuoJ1yNHbXmMwfJZpRrb5/Zm5m+kAdLlSRDH5AZjBUoJSoPEzeqEvKR9LZ4 fnc= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781936" IronPort-SDR: +53KOE6p6hHdrKWVU1whqlKjD2I78pFhxp2GoUrLmfPlT03nSOwRPts8A8JXn9B2Jbmp/MKb/E UMicw774vuykiO1bEFQjn0IAZ0DL8bNCY= IronPort-SDR: weCH9vv4smYwHooxXELutz+MRv0mZRh50a4SzUEqSFvT4QX4VI/451XsGJoLnWHnBXucxX2qpN CagHKeqX8b1g== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 22/32] hw/riscv: sifive_gpio: Add a new 'ngpio' property Date: Thu, 18 Jun 2020 23:25:08 -0700 Message-Id: <20200619062518.1718523-23-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549189; cv=none; d=zohomail.com; s=zohoarc; b=hap0Sx1U4+EnErsZkEJtxI+hQrci4c1qwR3quVfy6pGHJe3cSXiA0qAJhT7TSsauN7TeLvWLROADZuvTNgHWWkWIUezu9Bo1mSfj6aHu0Y6PjktZ19udPeNPy+pRDgh/KaNPkZmA0P4QQzPbJusMgLnx/slops99C6/ZmIVey2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549189; 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=e1g0dQ4TnTWb5c/BzRv8ooObvCKW5jxaKyTFGH6f8QE=; b=Ku/INOAYE3rIi7dmoxVlVUkdQjTmx6bkbk+TSYL7pS6rC9tH1wIr2nHSUjmdbCWfXPy8UOrdIvNnkDvUE1GPicVzgmxdfh2tuhg5lp7juaDwNaJI/KPALof2m6REfh7n3i8HiAPmgJFDODZksJm6fMOI8Jb4I2xkfkRGS4QIhqg= 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 1592549189507261.61536635086395; Thu, 18 Jun 2020 23:46:29 -0700 (PDT) Received: from localhost ([::1]:47652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAnE-00070v-3l for importer@patchew.org; Fri, 19 Jun 2020 02:46:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbx-0005dr-BK for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:49 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAbu-00028T-3A for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:48 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:32 +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; 18 Jun 2020 23:23:42 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:31 -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=1592548486; x=1624084486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EPGrTxEiomZhKmRrX1ABRMGrOys7ouL5EmMT2s9t4Wc=; b=baDb7q5YlXlwbhpMdYiiO0aGDqs07jCwODIuYJiFD1XAs1JqlI3nyJ/D 6oDb790I1e9TtsxQMjrftnz7IGkP/Wbj0Qtl3cUD9YFPi7oAefD3HInZP ZF63Q+8qRsjuIy6ZPdPqH8r422o1qD9YKTny6ORJqbkLRx1XXGlnICega RdqopIf02Zyuwxc9or9WLDZ99Pc21+LDhxvTIv/sDgk54pKfrIf4POGLB j9eJR/4+VOU+e6D1girNEm1OByrtfpZDkKqt9oZDbTq1YJ/kPIoJN8JsR NP4KEJxWWqcGEdMmzfqhTN4RWLMKxS0pn8+AVsYAonHPp7IgGR2UUOdet w==; IronPort-SDR: o6KUEmWXADsSm3+MtNb0AFDBoIEepZOSMDZgadSX0fqUszsiU/FxGddoEcHjL0eOY3OexZgdB6 tlofXqqw23v7bs9/7U0CEUVqlmGyumZQg5oybG6JkjEOs/GVZe2bvSGLaSC7JGgi6BeuFu1v1v 0DUoVtcvWym2PZ+7Xu8nEXpq2MmuZ/+rH3L6/NXHYxWfbc/GGFjFvtX9ww5cd0epEn+Pi1SX21 1a/zdVIsrVxhdRWG3mLsnMTM+kXNI4hkQo7nPguPczttyszu0FZTDCXMNsyVdd0D4eXkUHRC6+ mPo= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781938" IronPort-SDR: Pp6mIbCK5TUOT48v9Bf5O9f66tTgNXeYi8Ye1G0kFe2uWnLhab/H5sIvRd55jwr8QijXBlpVHb POAoSS6I7fCRHBRxR6/npdlR5yoeXEdHY= IronPort-SDR: /AcNV2KNjpneYqIpyxODNRxWIafWbpDQM067sCqwb/eELOMJxciOcCSr69qJP94lsnu4gjaOBB F2KEqCRGdlNw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 23/32] hw/riscv: sifive_u: Hook a GPIO controller Date: Thu, 18 Jun 2020 23:25:09 -0700 Message-Id: <20200619062518.1718523-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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..c9ef59c482 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); + object_property_set_bool(OBJECT(&s->gpio), true, "realized", &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 Mon Feb 9 21:27:02 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=1592549227; cv=none; d=zohomail.com; s=zohoarc; b=ebcY4MxLx6NDDdpnuUtpUBbkrHUc8BcewsW/M/AbBvnx55wXNWtSiRJ+VHTnPrTyRevCxC6i8tkkeYjft+fxvQmKbRENR7oQ3xOCW5YmTgQpB+fN2bNNAF63625lkR944K1c6TLJ19f4g2s3bfWgjncf6lZLw0aXwTgkUu2qDBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549227; 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=I8aDAnvPpOO0gU2AteCHzf/qY3gwyZlkLq8gEB7PKg9VTAjk9sAdA7wPH1zppUvsWNUND8pFpvaOQqtRgEgzJ3ysezZvjv0hkHGpmtLnTwnebGdqW9k9wkIP4MqUj61N9cT1AeJa6+g0mzJs4aMSJDt0UAdsIMi9DDveKlnn9WE= 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 1592549227608735.0977844075336; Thu, 18 Jun 2020 23:47:07 -0700 (PDT) Received: from localhost ([::1]:50914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAnq-0000Mf-33 for importer@patchew.org; Fri, 19 Jun 2020 02:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc6-00061y-Re for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:58 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc5-00028a-3h for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:34:58 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:32 +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; 18 Jun 2020 23:23:43 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:31 -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=1592548497; x=1624084497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=awiPom2MLm4GSUph2K8Os6CU9vKiSvuIpuRuIMNfHzs=; b=nvDFWPIqfhR6Y4fRZfwXJhLLSd30vABerHO2XYqOJj/kPdwzE3gP+3sA FquaSSZFxyi8olhgpCbnUjZfHV74gv4IGWvt6alGfr23yiGdXC8iylnDy 6TNuuyUO+aGOG5nN2nbS5LS9esbJDDPi4sPok98NF9NPbiY8rzN7E7qf0 5AiwrYQYooW/ZSgfdTariEteN6vgtVQXRdxNfj5Y8GIrnXjVLDG8QK8Cq zBZgzPwsU2vc8UYltRqd3+vj8RHzRCStuvlht9eSmvJKDuagmyT03KcJ2 1g+yxb3A7XLrLVKYNolREFKqw0/TtQPW78ZCQocuyDtSqxY2jFeQxJTVk Q==; IronPort-SDR: aMqcBLmNcfHLUzDmDA4rwaY+LiaIwWucmMO1NZ2G2Q15rZcd41RH/DR62stxMz76gcNi281wX9 OjG/Ifp4MMnNWNsOCF6Tl4V49kPTAa/Ll4FEvcixXQGP3//0X2clmPxfUg/mnOy5yJvP8Jtjnt 3u8SZlQUaAjj6OlSt3P8PoSwcpeqnpjsq8XttUkByuSoPwE6feGszUb/pD36UQFS2PvLuRjuh/ 5PA+PsCHVt6XC2ZeE9T4Cm1G8oN4n7alSQw3CuLZyYYLKN23jSjZoTL7hVdBYX6GB311l0rvnx gRs= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781939" IronPort-SDR: SxleG3n1ZDyK1JCD7A9MpBVwQsLzJ4IooGLWlpcJ2MJgQcFpSzsmXjje9MLPk1VkRTpf5hBi1b YCujzTbaRq8RZTSA3PTKIjOFQuI/N7KDU= IronPort-SDR: TQ66xgxGtWN4tUaYkVr1TQ2LDZih2j683rQzrWUJmCL8Kg8qGsUvEmwIZz7G+JB+9DHrLNp1F+ t84+NRq++rUw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 24/32] hw/riscv: sifive_gpio: Do not blindly trigger output IRQs Date: Thu, 18 Jun 2020 23:25:10 -0700 Message-Id: <20200619062518.1718523-25-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549307; cv=none; d=zohomail.com; s=zohoarc; b=SR9fMuTwStPSN4wCbndAXg+gRdZWdITQ+KrmTxmXBTWwdo/0LmNejh7dvQUB0QuTDTfLhFKPVNc/FjBJBDgJ4MwNgl87FVlSisJgsT0SwaupaxXkmnBlWUNcd4CRqEJHmqUifnJ5gXHs7C2PUhx2/92V1r//p3I64VkA5cZqr6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549307; 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=WWU+AHChI6l1MbGrl//tmP6qttXgFDVBNe4Hkyz3fDo=; b=WVRidDX+kiopfuVvcLTk7t8XumQaGcLHjgcF9+rZUMThOAFmZYrFaoqKBWxpRThA4ulru5mwal0mn4xiwntj6g7l0E1AX+Lj5I1qXcNZ7h+jxahHntFZObf1fdU0QY7HYAiMtRz5yY4C2Tq6QLLOSRrmIYWt2fmtBISseGxE3Yw= 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 1592549307921461.0151502705771; Thu, 18 Jun 2020 23:48:27 -0700 (PDT) Received: from localhost ([::1]:56454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAp7-0003Ji-1N for importer@patchew.org; Fri, 19 Jun 2020 02:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc8-00067B-SA for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:00 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc6-00028f-U5 for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:00 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:32 +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; 18 Jun 2020 23:23:43 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:31 -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=1592548499; x=1624084499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/VFbNCBNHJmJE++nCPIO8b5lhNMmW1HmNeApASFycK4=; b=PUXK6nVr5ZXDU00QdXQ0Mf19lvtvN5d8lrv1PBljrcm0ybzh674dTp75 TZB0aN7DPqguyJOk+2jxy0JVJBijmlbmPTOb2/7lGklURlaIt5Khaijzp pnjYCT1qH7BG7z6TNMr5/EMtE1EbTTsHLR919UFqWcZn7P7AEl1CZwiKG N1fT+TvThoj5MJWQxtr3groI6jEr+ieBM0cNgVy1PlpCxarMrLnmGo5sE veU+2xvNIS98bCdZfi8zP1HS9ob5X/1Y6zhHFx2OtTHVsfo0ps4Q4eLkm QfUxkYzVcZ1aaWw5ESZlydjONH6NcakZLWACTV+fXrwAs4eLOBMzoqUaR A==; IronPort-SDR: IciwrAbBBbbPmGaT6H4mjpzoMM2+lcuYlsTWlfOJoJxigQXvzAfQRDAGKj5nGCC+AMMXNXd0xq +0X2l6Cp51z1VFEI2/Jl6Pgp1ArGpFajijtVWNEnNJSFa5fqCwBxZBchmjU0nA3DPTGJhSjU3g 4Z7szKYZmV7hDGBwCV+L6dt4H2UjBnLjboDCmgDP+/dWi96SBwz9+QqrqBqrml1KKlNOAVZ10f hCJcIwShHIc9f8SiPxCYaNkd+bmQXXVk1ECBD2ivAzqWDNkMD3q+8Ff1KfvD8O2j8JnvOwIp6P Z0k= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781942" IronPort-SDR: wvfWnnBeQp7KDvRwCG6PWLK6ZsAqfTikXWQRCoA3Wq69GwtdPIk6yJXah/9PTKVQxZGoe5vPOp 5pswTEVj++j1rKNR3HePps6Hes/obx6qU= IronPort-SDR: 7O2+4ep1smA0zosWCThqAbAIKyn0cBKqYiNks5rYBYFm/B29J9S1MUYAikMFUddiUgyn7akjEa DBXfuW8XjOFQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 25/32] hw/riscv: sifive_u: Add reset functionality Date: Thu, 18 Jun 2020 23:25:11 -0700 Message-Id: <20200619062518.1718523-26-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 c9ef59c482..a0fcef63b1 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 Mon Feb 9 21:27:02 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=1592549423; cv=none; d=zohomail.com; s=zohoarc; b=Q5hvjEx1t2gj7XraEvsh307E6j0AuOoK5aMfvRl26d0aUjBMAvy776gbDYVR0x/Umh6ZBA44k6lIbnZIKi23oO045saxbaW4PxcoqmvzwZWxzZRR9tEuSiAM70cFteucXkJwrCHgXgjimo4wJcr4Yh6uLaePuREQhhCFMuEWm2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549423; 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=LJ0UWCRJ6IBvOzPYWgKQO9DtC7gcsX0taw1T6IvYFGc=; b=E1ydxYEMiVuPGNg4i1NCBcUpufAe8IGo/ugGDnFsxMBHywigDFNpxHhqQq+SESlUsjlL+3RCUVm4CX6RBLakDKga8VF4n1CzzY6ZjzXs7Gt//MbO5ZJxaQWKi1fU/N/gAWcKAeAvJPiTqqbqghhIvkqLT749SNi+Ge+lU4xYgaI= 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 1592549422997709.8294790617801; Thu, 18 Jun 2020 23:50:22 -0700 (PDT) Received: from localhost ([::1]:36412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAqz-0006fj-PG for importer@patchew.org; Fri, 19 Jun 2020 02:50:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc9-00069J-Pb for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:01 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAc7-00028T-Fr for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:01 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:32 +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; 18 Jun 2020 23:23:43 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:32 -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=1592548500; x=1624084500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b4Z+vQvmCMOduIrVuJtKpoSIfdG4beuofvjhUpPTYWo=; b=qF3eBBkumd51qnEsLdca0F5tfN8HgHVtC6b3GdfBuyE9fsz8sVcHAYvl 66USwAbJeqynQDfrDx2rlgOerVoCkhzoIkLGzNChQ3m9yUwjVYJb39WEp FQT4rXwjSXKuhCt699yokF0DlEM3FWSZ+z0leb3j9jBP9d4xiefmMMTci egGan4GdlboVwV86Fp7A+vghfl8wd/SzROqKjlxA9LfpmgJkDzjD147DW +/rA1lg5Sma8H0/0iieknXaBq/rrMO2zR2JO8IeLtALb4hyNXEkF1xal8 Y1L192DNywLBvf7/yI/E3jc47Es94zwWrQNzto5hMR3MoJVdWsZc2l4mo w==; IronPort-SDR: 3D6px6bw88F9ZAFSv8hb6kU7NXWTocg/jEH2avwKr2J7OJsI0LmRPKuCIkKzV2tntM5jx+/08M 2TrsfXa2SwEIby0+8GqBLTT7NWN9DESsSDUAWQgDYGfmwRgza5MnxHuQLyBIX+zwrLR8N5/Awk +16vAfm0n1dWHLFca7uDqJm21kXm1Zj8oJR8hx8a2CIrZVD3WdsC6L/8b3s1hVFLI37ZdBAwbA CtIHqsy07WzfZhxfWYzYDTgn/0STpoAZ7Ebl17oqCdm0I0lZoZpiUX890jzg14xR2YQoWfvLF/ Z9w= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781944" IronPort-SDR: aOiIhykLcuFroqHICShc2Km3nWnljqYSygXvjHr8lbXVhfDdlxxb2jKhymh9ooJl3Tv6udRpco SncSgaQz3oUag01BeT49nkX8qcz9HEJVo= IronPort-SDR: j+sowAk0THHDags/35SRnJ0fnnQcLnoh8R35D0SW4H0Ll6qirraznd9wgoZrBU1uvCcsC8m6Z6 b99UBNhIf9MQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 26/32] hw/riscv: sifive_u: Rename serial property get/set functions to a generic name Date: Thu, 18 Jun 2020 23:25:12 -0700 Message-Id: <20200619062518.1718523-27-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 a0fcef63b1..2f9fbb6aa7 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 Mon Feb 9 21:27:02 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=1592549522; cv=none; d=zohomail.com; s=zohoarc; b=Pvd90W8CLj8nOyRQTvHlanPwfHAZYLKz4OirssUr1wWGAmYLFqo+mmqHcMb41mKSMuFP81BSwqiFsG9PHDapjGVuTU1z489w0FTlphdcnQ4VGmZYsBYl+O9+z1uRx2aihwA2OYTTnRrecdeUD92RuQNp7gBMzZKXT/0nBi5CBoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549522; 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=kVpgjTL8Q5gDXOJBhbkMIlNVDSmDs3PH8ZkY6kwnmlk=; b=JEk5lRbuoXOoKEydqFMWastBl7bjbnjws6DJ3k5kYyq4L2fu2E22R5lIuj0zOx+lhUoak6Y5+K2iVfd190ndV2hEjI7uKqXL0TSWo+3VXPhlGB9ttwxuRLaRw+7VtdgBW1FY/wFbeM/TYnSIt8JoSWenfz36wdZB2vbEoYIJNgU= 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 1592549522444119.54590921672104; Thu, 18 Jun 2020 23:52:02 -0700 (PDT) Received: from localhost ([::1]:42542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAsb-0001xT-0P for importer@patchew.org; Fri, 19 Jun 2020 02:52:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcI-0006JE-OT for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:11 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcH-00028a-3o for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:10 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:33 +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; 18 Jun 2020 23:23:43 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:32 -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=1592548509; x=1624084509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8hSwtxjUfxldsdMd7WDTe487tEnsxgJ6ThhQBiT5NEM=; b=fKkRzlkWQ4a7tJrVbuD+45zrRbIzvHfaavrIYP7CGUn3gAlUPjCiS0GO 3bS7LTrljI2gyfu1aNqmfSobtOj+yyDn1WySWGes1V4RO0v2gUliQENXG s7lhEZIn1sI+DotwrvRgspzQtGAqSEDWEUW6aaVuh2dSgW4mkywhQrWE8 tRBIfiygaxnqn1CbHrx85NyoagJ11L4LnbcbpnZt3MitYSLtv/tDNQh94 b0Wyy1jxujWJQogzPsDyG/MFyyFbtWG1DEAjmDYnWFD2NNUe/KCIpgpCG MGs5yK6A0XnkZOy/ngf0cAIDjOELdVxf163cVvpCFcSC5Cjl9dAc1vTQe g==; IronPort-SDR: Qv5yt+Q5bds9KyDrWMR5ioe4BiN1KfXqWZYu7dXNgEOdjogwWKCpnM9BTcF6a/wqyTUb4aoh/n PrucKjkxEK6brP5LR88rMIj5xOJLwwo2bJVc9/3j+/HygIgCE1JCyG4Ma5Bx1ztqkGRV+jsjz3 pkYmFumIpM8qY/ua9slxSuc8s1WZ0VbkU5TlBlTwqO30U/RMkdpj/pYq6jwzrEYjEfZq9xa1XH fuN0+NX30R+uxFd9HU9cldhGSzLUz2ZhN8XvEEO7dQFVCjBPFShLShbGAmqraELuyIqRYqwEAr BIs= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781946" IronPort-SDR: rVCf9MVokfUGowOKi88mFvCktwx+A0k42Y7GZQe0NAacAM7sjoZ2prE0HkX2r4SDEly2S4I4JB Se9GtyHjazuGSziP9J5p4CvvoLOuwBYYI= IronPort-SDR: gkalnGBE5xJSh3ybs1tdFHBA79PFaNPEyCJbnZz+1zRHQ27iGTxM4yUubeIotLdxE8JAd/aw+T Oo6LvkTw6zOw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 27/32] hw/riscv: sifive_u: Add a new property msel for MSEL pin state Date: Thu, 18 Jun 2020 23:25:13 -0700 Message-Id: <20200619062518.1718523-28-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 2f9fbb6aa7..ec5cfdae62 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 Mon Feb 9 21:27:02 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=1592549608; cv=none; d=zohomail.com; s=zohoarc; b=BT/VU8o4JeRAdQxsDYMg3Pljdi8Kx/iiC3v9YobohALlblhXmW/cI4du5DLcMc8Tl7qkwJNpTNsGiUWZVQA7hoNqN36E0NTtwSe5iRsBhOrlouRPgJdVoLHcscgMSep1IP6jmWrh4ehn57YObkPmRNXfVdRS32v6G0M4Rm0MZwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549608; 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=L1INYfysF7q3hQskHJhwM7bXUCW53LehPVlZT1LG4APEpeaiz8+GYPO9dsWPUhXRbDcWRZsleOLtqBUn48EszpJ6PhRwCosXgGwR+8Qp8aO4l+QFbwEqBydWgirhvJFMCPGpukFpwTNi7FJv+okOZUxmsP9Mgy5at//9WKHzN/g= 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 1592549608699193.1131439812931; Thu, 18 Jun 2020 23:53:28 -0700 (PDT) Received: from localhost ([::1]:46718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAtz-0003oP-4P for importer@patchew.org; Fri, 19 Jun 2020 02:53:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcM-0006Ku-Am for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:14 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcJ-00028f-5I for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:14 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:33 +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; 18 Jun 2020 23:23:44 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:32 -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=1592548511; x=1624084511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mNUxJaBqscecrc5iYSnB5gf7mz+p8sMw9gNqAnpXd2M=; b=MGEwSx9TQfGrl4xm5mANYwhYGYAHlnNjBYCTo1sL6ihrDphernIGSef4 GpDhmWTdlUmMjj+IvTGklKWlDWmueHHpoh8LB3eqMvL8AhrcsreLfrEIK DFkfH90hPMpBMdahpFOU8csUyas53SHCGKgtlwKhsjDl1BHpNUe+cA0+2 QiWTgIf09b/5UQlzk2rVB7toe03xSiSLzZajFxCf6IX5ib6m+6V/kNd+Q opR8Q4VudZcVdgUKZ3mc37RFuNlTaHyNSmcOoZQoDi9BT8BeSQ6jt7/UW oyNkBXJVmRJftHPyeLUMVhiDB/btDARHU+Wr4XDK1/q6vnBSv2ousd9I1 g==; IronPort-SDR: Sp98swjj5eVLYTENTT25pN71LwXI40ohEIDDrSn4MNDq8E3qT8iiFFlUfXzn4IkO0tbzbk+9we 2iYi/tz4JekykiX9DfpISLbAQSVap1ncC+9V7d1JMMjVk1qUHqUjheUNtyqbljezgLxZffCvTe im1SunYKBQmOPez295mSQeS3I0VIt5rTbetYIqzee5WDDp8K/pql9R06jsAlNNPicHmm3hZzEc tF12KmA9J4MlBuZINx9YzCx7hkF9j9s2NZczK4WNh4dQ+TqrMgnWVCUsHf6hZnsMFdDUqP+7+o Xp4= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781947" IronPort-SDR: YKySp1aCmFJIDYRhxKLlWgEqAsK+TMnxRgLvdWzwMF1OYqGN3zRUaLtceAnS5yy9qcgih4i8UZ FgtMQJ6ccGW9cN8FawpN779Z3GhD6HaUM= IronPort-SDR: 4v06iKN630AJ502nj13OniQbGUEzpjS5Ngip1egPRoZuOwLrSpslIhb/d8z954AoOOjxEBg3Q6 Ix0C5mnGEDsw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 28/32] target/riscv: Rename IBEX CPU init routine Date: Thu, 18 Jun 2020 23:25:14 -0700 Message-Id: <20200619062518.1718523-29-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 Mon Feb 9 21:27:02 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=1592549730; cv=none; d=zohomail.com; s=zohoarc; b=iAb6+PoaDOJDKDi9w+xKHegSsItOii71Zwcrx6Awz1g5d+1Sk3jL4Nw7oCSSi0Cw4HQSvMcgL4yLYALFJ3/pLT/7B99uivpz0TLeHoe8a9nYPkrd+8NAaaCPfyUxuc4yR4ox761CKEnXPPi+T2KvPxVF6fSmulNOKuaO0vEf8rE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549730; 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=0/4jy9/tQBs243g8Zm4j8oT1yQZrQCtLMiu4UnoR6RU=; b=R/HPrtcnTGbc39gZXPNcosiy6aTZrnxiCFuHwQ2AtjGdbKUFuryI0h00DUu1+4TYYdoHwPFE1YjaSeTzR5yDzldHYhfxSdKyddcLFn/2BHWUwShPEaYvEnJQ9NcAlazIj878ukcY8+Zn8p4aN3/a/dmQrj1wk/3v4Ts0CJE1U3Q= 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 1592549730919669.662533404302; Thu, 18 Jun 2020 23:55:30 -0700 (PDT) Received: from localhost ([::1]:50898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAvx-0006Sq-Ne for importer@patchew.org; Fri, 19 Jun 2020 02:55:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcN-0006NM-8r for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:15 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcK-00028T-7o for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:14 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:33 +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; 18 Jun 2020 23:23:44 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:32 -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=1592548512; x=1624084512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XFycwSO9qzdy5CvQYiFPd6ixTzOZwZsHnYky1OeqsuU=; b=mx9n/9ZeM4JvadlK0qmTPgUjKIfx14msDCavp8o5JwaUJ4ToOOgNmF50 TCmE/MRRnCrI0iWmbEforSAtVmtARDSXCya1WpNFqScXqPkcEYTdhn34g /NpVqoOsjBNiHJwEPQr74sIWzq1jhXqGMcEPtA+aQpXHfGlYalzHX6ntn DZb4hNgOlrimvbo8ivaJZ1LcdQmckxOqWrddigFnLYARbJ64Rte+tkOin KrV0tGJ7OgxWMEksoUvmcfqUnsydiQon+7uay2Mq+Dma1VU2VZylNGGFA ZFJUHKHsih/zGIO7zuvM9OyofekhASHt20yL6OdajwHL8GyjlH1tj3ziG A==; IronPort-SDR: cq++klMS24lOd0kBeGOS4P6z9C8AVRqTF6fXrV2hQOHaLW3wljUdm5cSfP/8b60D/EoaJHYMTe ATUYUJIcJaBHEyfVz7B3YWTwn4vGHa7Hr8iylDq3Lm38gZhuwc5O5orxjl+lblOzHHoSujbQG1 3wmzktnb1biVMhIRQVXh8DjoU6VOp8TOOauxiQCKF4tv3hqeSfQ2y0ozyR2fdX5Hy+rkj4zSPo EYPFqijWg/MW6A4M0HVzkCREEGsEtrzoxMvdIFXDAWH9d+PUhNyoMaGkcS5XNVcYLNyX4oTYbT bgc= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781950" IronPort-SDR: AmDR975wHZib/8N4+n7qppfIxWjVahb33K+gL6cGG/Iu5ryK6Y0nUd9L2i2MFHgMu8/Zl7x7Im VE+Xh0APMdq3lEzTb4rEO+WdLYfZHXm0c= IronPort-SDR: /styWUObYYGBEG0aV49seFhGrbaMg7WcYUI1KQkOLRLsh17nRd+0aVppxa5V3zNPqGyC+J1mhH 4cfkUrH8S9qw== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 29/32] hw/riscv: sifive: Change SiFive E/U CPU reset vector to 0x1004 Date: Thu, 18 Jun 2020 23:25:15 -0700 Message-Id: <20200619062518.1718523-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 ec5cfdae62..2a8c8c8829 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 Mon Feb 9 21:27:02 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=1592549731; cv=none; d=zohomail.com; s=zohoarc; b=YyE9AbNl70v1kihaaz/BNghtWC/MTox9lRg6MYsCUASE64WY4rdqH4P41eGckr4cyOU66L6tgalgWv9r5kkncFmkfSNkdTK86rXV2hbCMxyGi5yRcFuVgLO1dJCpcA+UP0J0ij7qUvzokHYowFwhXNcMWxxUgyKDGojfeBf820I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549731; 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=yFDs57BaPLFevIV2L39/AZbwhBcW14u9QLBEyJy/ZVc=; b=lmnJVfcVpfUTvdGx5FkD5sihNkmYpTYqdUzNsWd236QnOz4E3NUG+OoZraPFXoqVZOyysOHYbLih9kpA4WMiKrzxISmpbnRC58JGrewqIXN9NsX1/862bxnrcCu6swYcgFMgKlp4E+KL3yaN/FpvvDO0zOPkTnx0vXmZp7AkDHA= 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 1592549731393265.64147574400897; Thu, 18 Jun 2020 23:55:31 -0700 (PDT) Received: from localhost ([::1]:50916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmAvy-0006TI-3v for importer@patchew.org; Fri, 19 Jun 2020 02:55:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcY-0006fE-TT for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:28 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcT-00028a-1c for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:25 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:33 +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; 18 Jun 2020 23:23:44 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:32 -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=1592548521; x=1624084521; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=40P3DW1BoMOW1mFaEB7dGJKmFgq1glT568GPf37xRf8=; b=AS2N96V4lidLp/NWomAJqCeLfHnK7aka8wdd7GlWPGehW7inypY3RLfu 4E3soUI9oLgGcPq8EiIuDPdaKyOHR6C1mfFJCvHS3LFBlViMa8j75/6pG fATLC/zsgpdxLHzB/qnEP0kONHu32T3JJ11sBry5/zKjRQExFAu4yyq6+ RbuhVLn8NZAx+fWydwQUBqACsWEjcrrLElCZj+qDvQkBnn1SZczpsm5M7 lt+i/4XaqURwHOWWJaYBAv831VPDTHpLQRA0hw/ZZPOb8YZe/W4+/6Gtb 8iU10vZOCqp93BeE7ZGUQ5WWqx8gSsra3/Y5StCFOmAQ+OFbXmk4cg51K w==; IronPort-SDR: SFXnUOETJCnsAHwZNpt6OwHcOYXHYaK4Z8tEp5UJBoRJszsFx0kX+UtGuALIOVk9WRw5tvAW7n /38vWCpFFsdf8cutpEeYlVD0RQQWMqB2Q2KVvDETIFmrB5sOMX44OaojhB4YV53QeFwkAAAyXR 55191tEKcdRODuRqP0fcsDGGgLW4nrAvH6r243KMR52mG8Hbx0znqDpQsGkyxRzg3YMbCBBiXj A469iY8GzuZtdtytgurxT54EKeiR7UHoRoqXY+tFnLV7LvTIhfFZKbzaWyG4dKwKbD2j8HxuSI 4WE= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781954" IronPort-SDR: Z7frXQL2b7esHXEyeBQLLRf3XtEDgHHGBeCkNY98VOvs4s7U1s0cWouzRliweeYzXrMz9n02g9 lPIr6r1zzwA1GZJHytyXqFyKvp8FrNink= IronPort-SDR: SJnI9BVAQ99QVYzP4vWYC8rpyTRlreg73sPXVuTc46xjGZE56UtwIa6JueGBz8ota5cn+PjtQ5 hycnHpc4eFhQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 30/32] hw/riscv: sifive_u: Support different boot source per MSEL pin state Date: Thu, 18 Jun 2020 23:25:16 -0700 Message-Id: <20200619062518.1718523-31-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 2a8c8c8829..2560c1ce4e 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 Mon Feb 9 21:27:02 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=1592549344; cv=none; d=zohomail.com; s=zohoarc; b=N8Ux1WPy0uGdpBBdablLGnEMG7IOUOq0T4Ps2aClrzlXk0TqbmQtjH1aeKybmQAVTTj6+7rHCnKsQ3kujWtTFGH927dO/EiqInHKrqxhhPSKP9+9jW0nW3YLMqxI86bb38cjfI23Z5qq+dt89qqYBBOBsjtaiUz/BBRKtoc5PdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549344; 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=LcZf07OkDcu+pDFd/Z2u7MBgywbLK+twD6E26tQqPH0=; b=jBwJ+NN34pxz+IOwN9bKiB5itjjI537qzwmhCDPIcDah3ReYJdQ/zXqP3o1JbRHz0syw9ZWN2gsZ3wfj3Pcr4mS+m+FwLhnu1WMPlIJv8sskusAL/OXfmOTQRhacqul+vEmOjJ27zlVLzXGKbtMj3nSo1opq2t5UMmwzNmhuA8Q= 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 1592549344033585.2233784275999; Thu, 18 Jun 2020 23:49:04 -0700 (PDT) Received: from localhost ([::1]:59422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmApi-0004Wv-Jw for importer@patchew.org; Fri, 19 Jun 2020 02:49:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcd-0006gk-6K for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:33 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:13005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcX-00028f-4l for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:29 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:34 +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; 18 Jun 2020 23:23:44 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:33 -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=1592548525; x=1624084525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cG+lTw6NJcZGe01NywzuI6sjGafJO+wx2fJIsdjfiaU=; b=jnQdFOcDnSQaPggnTdNKXQBpQ7yL8xuT/URciPj6OtIMRCcC7LogTu0M AdTsG646YsP6VdYFwcWwh++qjpqlW86J/TVTwrD60cUlNO53fQqFzVK9I +/+ZsuXhrEI1DUnuw+taqHm0jL9JZWlq0WM5M7VyYpZ2t51+mS3wDQRi3 n+op9An/MQAJOwYBOngzbVPq5NROB2RzCqpUVyqUwez7sa7wGpKV3rM3C U2ea58jidW8LNt1rUsFZHSF8rnLBDSFFwcBYoFGpLWobsTGDtPCjIOWqH w73FV0f26b4s7Zk74AQmVCFU/tHnuDyRa3fkiAv/HP/Z4PjIZZzsjwVgf g==; IronPort-SDR: RxjNH9xH0jXssNWImpUxJiTs4At39b8BnEfPAtlvNs1yOLRC46kh9Mu0mk9L26m20bgtgihMY5 j1rVn9oT1n4fVY8qSQ7KdRFDUbVm3hPNKGP0sLUsU2Z2kLKaTXX9/NBqCplOvPVyMRQT45IC38 F3UpFsyYnWFgv1k24Pr8VpbOK6ODqG9BC6rmANlaSMPftI7hwcSwZmAQOXdu6S27OXhdNP6+Us 4UpydT4Z+cRGEtSiCyL8G1tJs9Uy2tSCCWxUYKBYJ4/AGIwh+F08ZSGHJiVr+Bgat/yO7XI5Sy h9I= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781956" IronPort-SDR: UOdZS9PodPaTdqLoE+yrHqDb678ttt6LCc+A02G7yHRhHvzdYnu0vNGwmerEpSZ6cEdziyKShQ BhLPCyxSwmP/NwUMv/pWjZDHz309XILh8= IronPort-SDR: LArEO/wAtyqt1uOq0jkhPXJN7xRS0afRdySAt3QiOhm/kTRGtbw5jhxHNgPWOgWfppluGKBfC7 ffG5UrWEV8fg== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 31/32] hw/riscv: sifive_u: Sort the SoC memmap table entries Date: Thu, 18 Jun 2020 23:25:17 -0700 Message-Id: <20200619062518.1718523-32-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 2560c1ce4e..052ba85ec7 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 Mon Feb 9 21:27:02 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=1592549453; cv=none; d=zohomail.com; s=zohoarc; b=L1x/u0MMDMHsMLAQJm89ysObAY/nkPrqBuLNSlQtsjvdI0K4V1hmTnF//oxFcFTPkQgoikwLc5nE68REzUMENCsCDuFnKvjxQlxfsttXjcCiVDWF41qgKvUqMcWwE+FKeMPSJ2ttmfvrFIQn6aLn1Y3rWts293TDtVdZlTyhaZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592549453; 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=Zw0n5uP0HABE/FuL6uDAlYi+HfnrghJ87wiMdboby/E=; b=Y8LSip0h15CfxcfcgbuMT1BZnhnPB79uXU5JiOCgT8S+5biG+xErggPxAhwCLNQ8DydsE30V4IJbe/SmGU8OkVNRmnX0d5HxzADDpmhWmwrJllVNQqPWjA/fx2bxaUgFUuMSsw3DoQicEZwgiQ0joBrPkGTyjwR2ir/cb5oKdbE= 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 1592549453011272.5388985227553; Thu, 18 Jun 2020 23:50:53 -0700 (PDT) Received: from localhost ([::1]:38432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmArT-0007tb-KI for importer@patchew.org; Fri, 19 Jun 2020 02:50:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcf-0006ic-BZ for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:33 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmAcY-00028T-Ro for qemu-devel@nongnu.org; Fri, 19 Jun 2020 02:35:31 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Jun 2020 14:34:34 +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; 18 Jun 2020 23:23:45 -0700 Received: from unknown (HELO risc6-mainframe.hgst.com) ([10.86.58.142]) by uls-op-cesaip02.wdc.com with ESMTP; 18 Jun 2020 23:34:33 -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=1592548527; x=1624084527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KrLdk4zQ6MVNPPBqI4ML/epsof6zu66Zr/sSiWljDzo=; b=WPtebm8fiWhO44HlyxilMmUZedC6v4dcLQU8cu/RUnA3cwq34taHToRV t0LUa+tFMRiBVesUoNiaGIw9kJCCLUjksCXqH6F44YQRM4CdDA59MUSVE mnkwqGIlca9JjIF8fTPYFwHnTqZpkSMNynN+e4vp1sY8blmBr8AxWiPdu XqX3NL8fnXTOqu1WPYTjFUwzf9r2YHg9AA7FdoA0k5+xFUoeNt+u5R3tF rwtR/Uw68eMq89GG6EMPOCo94aD0xbeFW6Wj1hOV4EqUYDiAl+cQLB+Ol nAJ0wb9T7z7CsEvkv47JInPzcuCeMDrb/rQbGUp/6bJ2dUvzo8NvSqVrn Q==; IronPort-SDR: aoVhdreP2+qImZDd4lll1GK85YGPjk9jsbRipBiN8mvy2h7oQsnWmTbqMsl6hiwKxoL32T8MHl C8o/sy6HboUN37+CrVMnTGCTDcVSvUHPKOu4bssv5ln2on7jJJVays8mE9hGxLGiwAIAW+yUVl lbq3cLA4gDNzl/QG2t1oU6taZDejBRCRDxUHKvqmJALHyKKwzLwawKdcLl0F0bveagMXQlN0my JLF3a/NRdzEHUEmWZFG448IdBxlZYd6jwOElVdY7w02h5HYmMh2lLJGrhglonQx/DPe5F+bMFB kY8= X-IronPort-AV: E=Sophos;i="5.75,253,1589212800"; d="scan'208";a="141781957" IronPort-SDR: zPT+NeNE+uUr7BbjJQQpzoYgOai+67TKtw0ELZjrqT3D5GOLSNDnK+b9LvXHhKQgbWklo6v5gD rse8IobRYGWMN2vPUWV3Bi3BdaKIX6EFo= IronPort-SDR: PPhigWBa168wlRBR9ojg4KbQ9F+PfWM7PofgmKz8mRdg7+9Aw5HxdMeEjy7gw3V/wFcktVg7r7 TSFNEui8Y4zQ== WDCIronportException: Internal From: Alistair Francis To: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 32/32] hw/riscv: sifive_u: Add a dummy DDR memory controller device Date: Thu, 18 Jun 2020 23:25:18 -0700 Message-Id: <20200619062518.1718523-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619062518.1718523-1-alistair.francis@wdc.com> References: <20200619062518.1718523-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.154.45; envelope-from=prvs=4324eb4de=alistair.francis@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 02:34:29 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 052ba85ec7..60f1cf990d 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