From patchwork Tue Jun 16 00:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1309903 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=npRk3Kbs; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m8lj2SlQz9sSF for ; Tue, 16 Jun 2020 10:51:27 +1000 (AEST) Received: from localhost ([::1]:53798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkzoy-00073X-43 for incoming@patchwork.ozlabs.org; Mon, 15 Jun 2020 20:51:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkzoU-00072W-8a; Mon, 15 Jun 2020 20:50:54 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:54924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkzoS-0006Hz-Pi; Mon, 15 Jun 2020 20:50:53 -0400 Received: by mail-pj1-x1042.google.com with SMTP id u8so649765pje.4; Mon, 15 Jun 2020 17:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vtcx4S1GPP8c1wwhPLcdjKruiDpr1sKpV2nOfuK2xVs=; b=npRk3Kbs0FMB1jK1aqAaobO2/yWJx488tYBy3NY6SeSka0UbXt3TDtsscG3ol8F0Pk +7jtnyZnqWfnTL18VF6ttDdc78QLuhQptawn7W4CtRgZmxxa0pjXvMGEaNk6q+4N9GgU iiDoUd2PNDTbVS+Niz3LvIwCLM8HlNZT8LA1ThgQ4HE1MjIhTAnBp3xmfB1LuC3S7Ex6 qB2Bk1TnRTt61/6nADBxEo6FAvmaw1zKa2yBaIeZS7uH7V62XkW27FrOce6BCpMmvziz kizl8n17IleXf0S86APvRd5JCS342t91qH9BFl9zuWglaHOneP8F7eyjEK6Ps8VbG7w2 ztYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vtcx4S1GPP8c1wwhPLcdjKruiDpr1sKpV2nOfuK2xVs=; b=Np0teNmsPzP2O9yB3P/DYB7u5t+ODb5lxLMtw/cf4u4BEui0O6HwBm7cJ27DKJ1V1A vV03uL2L5OmFMiJXk/RMUqDZpOptaY5OwpY63jebzQe0DvJqntx5sT7wh0OVHWmpkdUy 5i035k5zr/O3vMwLbF7g0r5eQbnJYo50dCQ0Yx6oRSwIqm8SYUcj1PQ62Ea54Dgb3w5G y66gIcHISQcjLNsbk0hOPMdTXkm1Gv2FAavjXXNxEl4Nks7j/Es98ruCkgTP9jIYXtzA GAccT1lZyRSWcWRDLz4TUc485nwxVB0XnlOrOrYt3PLIHn2XWXsgc7z+u7ja6UNyjP4g pvRQ== X-Gm-Message-State: AOAM5314eI+HXtuqiEG5Na6skHW/292zktk0REYz8Y8tNpQoSgD1Vdol a0WWJpgh2Oh7uhbiUh8n2eg= X-Google-Smtp-Source: ABdhPJz3caIVl/52v0C0mUIa8L83ghSlVgcl44RUSjnS9F2TvL9f4hCI0tQCylPLht9OuhT6UoEWmw== X-Received: by 2002:a17:90a:2683:: with SMTP id m3mr305335pje.196.1592268651224; Mon, 15 Jun 2020 17:50:51 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id i20sm15210539pfd.81.2020.06.15.17.50.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 15 Jun 2020 17:50:50 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 1/5] target/riscv: Rename IBEX CPU init routine Date: Mon, 15 Jun 2020 17:50:37 -0700 Message-Id: <1592268641-7478-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> References: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- Changes in v2: - new patch: Rename IBEX CPU init routine 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 e867766..5f03458 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -153,7 +153,7 @@ static void rvxx_imacu_nommu_cpu_init(Object *obj) #if defined(TARGET_RISCV32) -static void rv32_imcu_nommu_cpu_init(Object *obj) +static void rv32_ibex_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; set_misa(env, RV32 | RVI | RVM | RVC | RVU); @@ -577,7 +577,7 @@ static const TypeInfo riscv_cpu_type_infos[] = { 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_init), From patchwork Tue Jun 16 00:50:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1309904 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=blHCDv4W; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m8lj2P8Nz9sRW for ; Tue, 16 Jun 2020 10:51:29 +1000 (AEST) Received: from localhost ([::1]:53928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkzp0-00078B-52 for incoming@patchwork.ozlabs.org; Mon, 15 Jun 2020 20:51:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkzoV-00073U-Mt; Mon, 15 Jun 2020 20:50:55 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:39326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkzoT-0006JS-Nw; Mon, 15 Jun 2020 20:50:55 -0400 Received: by mail-pj1-x1029.google.com with SMTP id h95so725683pje.4; Mon, 15 Jun 2020 17:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uw1r8epZoEetYZu7MSacVagmc0CVPicKiM+zkpvkEbQ=; b=blHCDv4WlH9qOfnHL3zeToaevnFVWeu//PM+Ebp/hUkefY9H41k2AKeLpvAwVv6x2x FW6o01rd2HCrtuEnLjCnSn19crNHPX/4ZMd8qIqXg7cWiF9YIMR4yHj8T7FsjE63ISi+ PcCj18aixvcTsD8w0agG+fGSlaSSqFrcmUZzKQXzA1jkiMTFvxys8PlzSHt9vqa6eJWS DonT0UCRQmpOThIASCc3NQdoAyhBZB2Wo7HkOMR984v70T/X6h7fs2pAaYZQg4MZ2tRP xkiyaFYpPTAnL2UdA3+4Y9WGSrXNcyB0uaDrs1rVyFiIbQAmslfynU1rHg+vPtFRO76d WgGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uw1r8epZoEetYZu7MSacVagmc0CVPicKiM+zkpvkEbQ=; b=rZo8sAxh9/FFNDpMPptZLadeey49nuqGBfUQJz9F5VwYUWVr5sXwJ+XtaHru2uIEOq yJ/qoSmBjRSKuN7QWHhqxg+bVvl/QzN3k9gwMcdnZos9b7dXNG8u2OraOHy6wohotQF4 eheUn5ITCASloZg1uWMY9+HyYw1OFNi0DcDF7MFDAXU+a4JCV+W2t9lDpGDgilLbwkfK bfM2oJ5ckI2gf/lD5KDrju5TN1Tn1sM9hDk+9sb1lH/rCK6yB7TG1HDb3eIPhItN6Xof GoEkzQhyheCEYEb2WEr46i3gPz6cNtWT0x4QQCfBZaMeoaVUn+Nh029/lypvMKcwLoWG 5AIQ== X-Gm-Message-State: AOAM5330RU5jgniHy7rLsMgVIGmXNtTbKwicyhTVzHF1so/AJUx9vneu 5UoLvaKyWjfIoxqlwjGzHM8= X-Google-Smtp-Source: ABdhPJy0xij/8bkE+QyhiE0zYs0lKbmfdiyGYyVjpGJi/1JZlRgRjwFzKNJ2D1R8m5Twg95cbyLwqw== X-Received: by 2002:a17:90b:3685:: with SMTP id mj5mr320716pjb.162.1592268652181; Mon, 15 Jun 2020 17:50:52 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id i20sm15210539pfd.81.2020.06.15.17.50.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 15 Jun 2020 17:50:51 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 2/5] hw/riscv: sifive: Change SiFive E/U CPU reset vector to 0x1004 Date: Mon, 15 Jun 2020 17:50:38 -0700 Message-Id: <1592268641-7478-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> References: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1029.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- Changes in v2: - rebase on https://github.com/alistair23/qemu riscv-to-apply.next branch - rename SiFive E/U CPU init routine names 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 d9a5c7b..d1d3bf1 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -98,14 +98,16 @@ static void sifive_e_machine_init(MachineState *machine) memmap[SIFIVE_E_DTIM].base, main_mem); /* Mask ROM reset vector */ - uint32_t reset_vec[2]; + uint32_t reset_vec[4]; if (s->revb) { - reset_vec[0] = 0x200102b7; /* 0x1000: lui t0,0x20010 */ + reset_vec[1] = 0x200102b7; /* 0x1004: lui t0,0x20010 */ } else { - reset_vec[0] = 0x204002b7; /* 0x1000: lui t0,0x20400 */ + reset_vec[1] = 0x204002b7; /* 0x1004: lui t0,0x20400 */ } - reset_vec[1] = 0x00028067; /* 0x1004: jr t0 */ + reset_vec[2] = 0x00028067; /* 0x1008: jr t0 */ + + reset_vec[0] = reset_vec[3] = 0; /* copy in the reset vector in little_endian byte order */ for (i = 0; i < sizeof(reset_vec) >> 2; i++) { diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index aaa5adb..0a86ffc 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -433,18 +433,18 @@ static void sifive_u_machine_init(MachineState *machine) /* reset vector */ uint32_t reset_vec[8] = { + 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: */ }; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5f03458..391a0b9 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); } -static void rvxx_gcsu_priv1_10_0_cpu_init(Object *obj) +static void rvxx_sifive_u_cpu_init(Object *obj) { CPURISCVState *env = &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); } -static void rvxx_imacu_nommu_cpu_init(Object *obj) +static void rvxx_sifive_e_cpu_init(Object *obj) { CPURISCVState *env = &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); } @@ -578,13 +578,13 @@ static const TypeInfo riscv_cpu_type_infos[] = { #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_init), + 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_init), + 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 }; From patchwork Tue Jun 16 00:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1309907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lsk+Ex30; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m8nN27Fdz9sRW for ; Tue, 16 Jun 2020 10:52:56 +1000 (AEST) Received: from localhost ([::1]:60632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkzqP-0001TV-Vh for incoming@patchwork.ozlabs.org; Mon, 15 Jun 2020 20:52:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkzoW-00075L-PY; Mon, 15 Jun 2020 20:50:56 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:34256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkzoU-0006K1-Ts; Mon, 15 Jun 2020 20:50:56 -0400 Received: by mail-pl1-x641.google.com with SMTP id n9so7615099plk.1; Mon, 15 Jun 2020 17:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lByZzsvrmeZSUi8soJNprK8GTj2Qp1TxmnGIOqa+YTY=; b=lsk+Ex30HBF1gyQ8Pb+VYTeLypsJixZpwGz9w89664cysRlyYDk0YEtwD45eCeXcjG On2mS+NT/AJ6GtexbrMWIlcxS8uzdd8HJObvWFSAYI1sygBVWRJ+4X2NO6Tgn+zvQLwt UbZvTPtRLppm/elPJbyk1ljWQjMwEUZQs4Wcwdon4LnkaMZ5QriDOWwEB+TWP+pdbCCH vpq34wVi1N0LG9uOrCJ6vaQ+x82e6NcKJ77J/XfxLm3q1Z/8oTzLQlFwN5fMMJlNkZ0o BYd2c1JwG7yxUgVi5o/2hgUoIbNPACffQxWgwJxLsUIKIGU2T8+crVHYkOgV/3RQabcK h6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lByZzsvrmeZSUi8soJNprK8GTj2Qp1TxmnGIOqa+YTY=; b=Dtxakmnd6Y6v2DA9IcM8Y+Y6o5ttBtdCbqWiloHYUOEe9BhKG4CS5eT3akJAwAAg9P 1vmUgucDdPsj/mJ1H1giKqnIax//6qe958GwWvFlpPauyxrIvw6hnkFn9Arp/Nr0FV/q h2l2cI0T+/IG3ccWIoEHXtPOnAjcJyZQh5SD4zHaZ8bZV2dlioGOOoYlKalB5Ir+tVL/ JNirG1MxuA+XRqt6rcsBaZub0AWImPJH32svfXsXkAKfAfmr7ou4GloOqzM+PO6ZMqPs mmqh5zieFbnkAWHpt8o1pOUNlYBj9F00Sk7GPpRQqp6XOBMif0OJrHE+rX4TibyO11Sf n9xw== X-Gm-Message-State: AOAM530KEfHYpBOeK+EA+EfnDlZtLzodTC8eVD7+YfVsS5oUaHkLDqGA s4Zoj0P40EMVkHn/pl6uPbQ= X-Google-Smtp-Source: ABdhPJxQ0PEYmoD4Ao/mU1LnEDceHf6XnWmwe7M5yHdeepmV9rcpn+0d9Zpc5ur9jCp0VSShLQRkRw== X-Received: by 2002:a17:90a:7446:: with SMTP id o6mr303490pjk.217.1592268653119; Mon, 15 Jun 2020 17:50:53 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id i20sm15210539pfd.81.2020.06.15.17.50.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 15 Jun 2020 17:50:52 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 3/5] hw/riscv: sifive_u: Support different boot source per MSEL pin state Date: Mon, 15 Jun 2020 17:50:39 -0700 Message-Id: <1592268641-7478-4-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> References: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 = 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 --- (no changes since v1) hw/riscv/sifive_u.c | 39 +++++++++++++++++++++++++++++++-------- include/hw/riscv/sifive_u.h | 6 ++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 0a86ffc..f64aa52 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -408,8 +408,34 @@ static void sifive_u_machine_init(MachineState *machine) /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); - 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 properties + * are given, start_in_flash takes the precedence over msel. + * + * Note this is to keep backward compatibility not to break existing + * users that use start_in_flash property. + */ + s->msel = MSEL_MEMMAP_QSPI0_FLASH; + } + + switch (s->msel) { + case MSEL_MEMMAP_QSPI0_FLASH: + start_addr = memmap[SIFIVE_U_FLASH0].base; + break; + case MSEL_L2LIM_QSPI0_FLASH: + case MSEL_L2LIM_QSPI2_SD: + start_addr = memmap[SIFIVE_U_L2LIM].base; + break; + default: + start_addr = memmap[SIFIVE_U_DRAM].base; + break; + } + + riscv_find_and_load_firmware(machine, BIOS_FILENAME, start_addr, NULL); if (machine->kernel_filename) { uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename, @@ -427,13 +453,9 @@ static void sifive_u_machine_init(MachineState *machine) } } - if (s->start_in_flash) { - start_addr = memmap[SIFIVE_U_FLASH0].base; - } - /* reset vector */ uint32_t reset_vec[8] = { - 0x00000000, + s->msel, /* MSEL pin state */ 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */ 0x01c28593, /* addi a1, t0, %pcrel_lo(1b) */ 0xf1402573, /* csrr a0, mhartid */ @@ -505,7 +527,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 DRAM"); + "flash. Otherwise QEMU will jump to DRAM " + "or L2LIM depending on the msel value"); s->msel = 0; object_property_add(obj, "msel", "uint32", diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index d82cfe0..5d80f91 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -111,6 +111,12 @@ enum { SIFIVE_U_RTCCLK_FREQ = 1000000 }; +enum { + MSEL_MEMMAP_QSPI0_FLASH = 1, + MSEL_L2LIM_QSPI0_FLASH = 6, + MSEL_L2LIM_QSPI2_SD = 11 +}; + #define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 #define SIFIVE_U_COMPUTE_CPU_COUNT 4 From patchwork Tue Jun 16 00:50:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1309906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dnATSJax; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m8nN4XV5z9sSF for ; Tue, 16 Jun 2020 10:52:56 +1000 (AEST) Received: from localhost ([::1]:60600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkzqP-0001Sf-PR for incoming@patchwork.ozlabs.org; Mon, 15 Jun 2020 20:52:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkzoX-00076z-F9; Mon, 15 Jun 2020 20:50:57 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:36190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkzoV-0006Kd-Sm; Mon, 15 Jun 2020 20:50:57 -0400 Received: by mail-pg1-x542.google.com with SMTP id t7so8428659pgt.3; Mon, 15 Jun 2020 17:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QY9pGdBoodyuLWvgAtPYSQUKGC728WHZnKf/IZEpuTo=; b=dnATSJaxAOjAG4IrUAiAXRRRrIELq610DGPctm7kU1hIlr0BfYI8rjL05bKP7Kgpkp 2ogu3Jk3trbxebfjfoL8wUVL1mrPdsLSp7BMdF0Gm+K5w9uOtIWWLfbHpR3Obi5CP8rv RbXPk7aRCn/lI8pXb3LU90lkADbAfI0aXPU62R+Hpo16+POeRQ3af5XpMTUhCKpjPC75 SrG8+bLBbXTcb8fpEVWkVemU25E7gHOrvO8eD38hWW/Xxc6i7G9uDKZJq2JjEkDh2M1F p7Di3zRjP2GvN09rvXLpmvG1J1CyI5IwC2V+AfJAgMH7cllyUU/BD4+AS2f7sCDtZGlr m0EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QY9pGdBoodyuLWvgAtPYSQUKGC728WHZnKf/IZEpuTo=; b=gouXRwxgn4V0SXrcmBpb6hH/+DnRo/tDVZ83//aEwDw8EnM4qJmrJSvsP6WRtc9rUY 5AllTDlo1B4kN3On+xWXg+/LUzPUTNCAlJO2Bu7Xt6GSgoLjgLqk6oB4ysLZBTiwUIpi +7fIiMYDEHZhGvGxiRy38DsbEw4lW9Wa01XK5Z0QctCingcepa3s+6V2HTq2Z+EWuHJ7 em/wnsnZ/bcoIq9LddNADjhzVN2HGlijuGisuGjrLtZVhADnK49hVEkCiYjkMAN3/s5e qvmOS3NSnx+oUneKdIZ/J/SMXqrOjLe62/qU6bW9azqg/276jLTADHKRCgHrv8ACmglM qQ0Q== X-Gm-Message-State: AOAM531F9fdls8cHiqoIlh5JXWhtYTHvq3DyPi0JU/QF81xuu04lzG0c YWzpsWqE5+h1ZfVBFTzG0Ag= X-Google-Smtp-Source: ABdhPJzS+RgCryDBd6ZjIW0ETfs6wsnPT5erLQwhYSm300Db8soIKyOH+EDuW6+8B2JAVcRvgeGwaQ== X-Received: by 2002:aa7:8681:: with SMTP id d1mr271973pfo.230.1592268654148; Mon, 15 Jun 2020 17:50:54 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id i20sm15210539pfd.81.2020.06.15.17.50.53 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 15 Jun 2020 17:50:53 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 4/5] hw/riscv: sifive_u: Sort the SoC memmap table entries Date: Mon, 15 Jun 2020 17:50:40 -0700 Message-Id: <1592268641-7478-5-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> References: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- (no changes since v1) 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 f64aa52..c94ff6f 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -80,10 +80,10 @@ static const struct MemmapEntry { [SIFIVE_U_UART1] = { 0x10011000, 0x1000 }, [SIFIVE_U_GPIO] = { 0x10060000, 0x1000 }, [SIFIVE_U_OTP] = { 0x10070000, 0x1000 }, - [SIFIVE_U_FLASH0] = { 0x20000000, 0x10000000 }, - [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, [SIFIVE_U_GEM] = { 0x10090000, 0x2000 }, [SIFIVE_U_GEM_MGMT] = { 0x100a0000, 0x1000 }, + [SIFIVE_U_FLASH0] = { 0x20000000, 0x10000000 }, + [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, }; #define OTP_SERIAL 1 From patchwork Tue Jun 16 00:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1309908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=haNTW4L2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49m8pw4P0jz9sRW for ; Tue, 16 Jun 2020 10:54:16 +1000 (AEST) Received: from localhost ([::1]:36652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkzri-0003E5-Ck for incoming@patchwork.ozlabs.org; Mon, 15 Jun 2020 20:54:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkzoY-00079Z-G5; Mon, 15 Jun 2020 20:51:01 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jkzoW-0006Kv-OM; Mon, 15 Jun 2020 20:50:58 -0400 Received: by mail-pl1-x643.google.com with SMTP id j4so4349473plk.3; Mon, 15 Jun 2020 17:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jmW2hH35m1L4rvDInytOtIMsYkAXmXBZIMWlBl+zHXI=; b=haNTW4L2X1E8SWY3I1kYbF3H541u7v5o6ETogFbpJhRMZ+EUQAuqylpSXoMlTlbGHv suM8Gn/xbSx8kIY6SMh+Thsn5m86ZGoXOyQ4J/frnQsf/ytT47iDHzJYeYZP/VUVDlP2 0d7juuPlMM/WEEfPKEBcU6KzI0fs7EfNpLFNpVoBbYI7wFTxVPvfCX7xVm5xN+HRWwDM NJZCsz/qjR+iT4/Cgm9ocCu04GImlbstLkgiN+/6AZtHEjayehwuQa0CEQO2g9Zdo9PQ d8ZReCBy0wGeB7ZDfyeXlkJAF3P7hukOQJ06w4zHnfRMxz4OOLsnCdVs59moHuVWeQxI 2iSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jmW2hH35m1L4rvDInytOtIMsYkAXmXBZIMWlBl+zHXI=; b=l9Rc1fmRi14W4WURKAPCRf29vNiSmcPujMxmRJx/LxkXVND5WMelar2q77UIG1bddf 8zWdV7jUYwFSmCiuAUxs+witP8G7v4GReyoKQ5Iit3LREYCylVZL+VqaVOdltR3eVOLh VEwCj3uKyrKtjn+OTDQixqp0zwMVyU3uaLcSCd1dHK/UxDYhc76egZ4GQFjUbJQK2hRl FiS5nZsA41LJsfirXpZHKUEqAlKVIdLZNN5N8ieZJ5K1lXeCwS99dTfUrWcRE7JEOV3R fsXrUdRTViawopUFbhYif0mMs7aLdztDubXq6E8XCXd8elV1Cjojocis0ttqNBoalUhd f2kg== X-Gm-Message-State: AOAM530CnABuaVNUdc/DnbS8/8j+EMVPTNcCBTjykUsKz1vWvrBw9Ver OT+vXivMDJTAqLkIaH8Ydjc= X-Google-Smtp-Source: ABdhPJzzcBiiEKVH6QGSlOKZAS56dFRq7h3QFsDP0qJSYa0p4TEJV258FMt325fRWgg/b+uoxnfhJA== X-Received: by 2002:a17:902:c3cb:: with SMTP id j11mr473566plj.171.1592268655058; Mon, 15 Jun 2020 17:50:55 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id i20sm15210539pfd.81.2020.06.15.17.50.54 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 15 Jun 2020 17:50:54 -0700 (PDT) From: Bin Meng To: Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , Sagar Karandikar , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v2 5/5] hw/riscv: sifive_u: Add a dummy DDR memory controller device Date: Mon, 15 Jun 2020 17:50:41 -0700 Message-Id: <1592268641-7478-6-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> References: <1592268641-7478-1-git-send-email-bmeng.cn@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=6 -m 8G -bios u-boot-spl.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 --- (no changes since v1) hw/riscv/sifive_u.c | 4 ++++ include/hw/riscv/sifive_u.h | 1 + 2 files changed, 5 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index c94ff6f..7923df4 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -82,6 +82,7 @@ static const struct MemmapEntry { [SIFIVE_U_OTP] = { 0x10070000, 0x1000 }, [SIFIVE_U_GEM] = { 0x10090000, 0x2000 }, [SIFIVE_U_GEM_MGMT] = { 0x100a0000, 0x1000 }, + [SIFIVE_U_DMC] = { 0x100b0000, 0x10000 }, [SIFIVE_U_FLASH0] = { 0x20000000, 0x10000000 }, [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, }; @@ -733,6 +734,9 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) 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); } static Property sifive_u_soc_props[] = { diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 5d80f91..3e33646 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,