From patchwork Wed Mar 10 15:59:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 396767 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp514045jai; Wed, 10 Mar 2021 08:26:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyg9YXw2TG24MyDniBR01UArPe9KJmmezm0b07IGDVKwr1L7zxYojNFe/aOq+uQaC2HFrTZ X-Received: by 2002:a9f:3f4a:: with SMTP id i10mr1638409uaj.125.1615393592413; Wed, 10 Mar 2021 08:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615393592; cv=none; d=google.com; s=arc-20160816; b=C2GnJsSNWYfUtMHC7B0Da1ZkkYOP/wDO7VU5rL2VcAmoYHOWsIDJM5oLSBe9NKUD2w TP8X9vWajBViYy8uueIdfjTbZ5kn6nE5b4QGNQ5tt6sFCd9dWIJxjsTTFV2/K+0gGN43 1iCEFKwKrFRm4V2R5UCTWvJKhgRyoOaPRc4qGAiGasHaG2o435Xa5gOA051DRREZFuq8 uWDJZGvhwqZwM9BRwWhCJzdFmlqV/FVoE/4Fqs+c4cXvrEGMk5K2yeDJt2V/AqJr72Id l23KwoWDv135teLDjuCpAql8JIYY5mVhYbtINRWH6zDtH7oke/z/Nga4WN86vVpXRxI/ gXTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5ViVWtZ3No3EwiuLvapp181B6jvA1Zl37fC61JHK5PU=; b=J9GDTCuC00hZS73t9Uk0wW2kTnRUzoHrwRJ0x6ZdaSMeG6m1be41WylV8w98Iyg+Gg 354ILIy0oYFRniCvgeQgcwUs2QpmD9mnsj290pVTxo+kcQxkiIONZ2dJC3ZanZxYK2Bl Bj1oKLfLlXi1UqnIVIOZUlrWnfsIS9W/uJvQVUiks6SZCWwt03Pa/RXpTlDNHU/6kxH+ V84Z71ka468MukFKO28wXIrYSt4Wne9CFxIGKSUCdC5hXINvZBE6rz4JAQhVNlEelrMT akglYhtuNxgmAevShJ/NUYUObTSKhMFKCmpBG7sN8dBTUj9h4843oNbj4kerIqwC4ATC HpVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JBdEbffk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f6si1543038vsj.50.2021.03.10.08.26.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Mar 2021 08:26:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JBdEbffk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK1fL-00058x-Ni for patch@linaro.org; Wed, 10 Mar 2021 11:26:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK1GH-0004j1-Oj for qemu-devel@nongnu.org; Wed, 10 Mar 2021 11:00:39 -0500 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:42216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lK1G5-0002ms-U8 for qemu-devel@nongnu.org; Wed, 10 Mar 2021 11:00:32 -0500 Received: by mail-lf1-x129.google.com with SMTP id v2so21309584lft.9 for ; Wed, 10 Mar 2021 08:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5ViVWtZ3No3EwiuLvapp181B6jvA1Zl37fC61JHK5PU=; b=JBdEbffkez64Mc7m3WjWfI/it9TsTKd999OZ9tSVY383s8EVAMYZnKMIPHj9xsgKgl AJFaVZKdfIIC6E3SFvuMVG4ldIaalAm/U5Kb1Ia7PWnGWync9DPAQ7aEwfU07YSAuF8n L7TMkrKMbM+uNFtnr42uNAWbA0EXSLC7uhGi72NhH4M6Uqvt7z3NL3j9mO++woWJfKRS oMC4GKNn/nXZH7PS8sPjir68p6KF8PH5chZT5K3nGMVaMuZNglmePzZ2hx6/h0d6YQFk s5eYmv59mOpoCgPlOQ51NcYaP3p9t6ybc80YlpI0t9dSu2FAUQ2kytPnakEFV4ZaTbSj 8Xag== 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:mime-version:content-transfer-encoding; bh=5ViVWtZ3No3EwiuLvapp181B6jvA1Zl37fC61JHK5PU=; b=iL3I7Kc7qxT5GpQghr2WkWSdVn5g4Jaxyz8rkidQASCvBeLyHSpHl9OCmptOabmOn/ lL+kANitR9p7SW9ld51ARro+Phc6q13y9dpxKEKzayUDXwjbSDbryVnRVUza7cw1dJzM t6Rqc7AyLHxuiR88fAb+3WMdztkaQF50QPMHP9XA1VXF+Oy+RYOV1UR9Uwn0gsuA2Jxt TOZKbcivW1s/g307Z+TpXuRgrJVJgbz4yxZ0Ms3OcQa2tt3IoFluXc1LD0N5gIvog5Fv yUNMFGpTLseFXhWhHdxzkjbXMr11bZJpkpZLFo9w2mU9RcFSnRtcPnUFUsem/QI7uCpx e7sg== X-Gm-Message-State: AOAM530o7fta4F9dC8mYuPM2P9F/Zqn9LQwNxVjN6DzYNaIrF4Bs8r3x aZACHLAfHvP2w0rdcrJousWH9QRTNsw9XQ== X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr4105497edd.134.1615392013718; Wed, 10 Mar 2021 08:00:13 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id qo25sm2825463ejb.93.2021.03.10.08.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 08:00:10 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 54F021FF96; Wed, 10 Mar 2021 16:00:03 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL v2 08/15] hw/riscv: migrate fdt field to generic MachineState Date: Wed, 10 Mar 2021 15:59:55 +0000 Message-Id: <20210310160002.11659-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210310160002.11659-1-alex.bennee@linaro.org> References: <20210310160002.11659-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x129.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:RISC-V TCG CPUs" , Sagar Karandikar , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , Bastian Koppelmann , Palmer Dabbelt , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a mechanical change to make the fdt available through MachineState. Signed-off-by: Alex Bennée Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210303173642.3805-3-alex.bennee@linaro.org> -- 2.20.1 diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 84b7a3848f..632da52018 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -41,7 +41,6 @@ struct RISCVVirtState { DeviceState *plic[VIRT_SOCKETS_MAX]; PFlashCFI01 *flash[2]; - void *fdt; int fdt_size; }; diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 4f0c2fbca0..0b39101a5e 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -195,14 +195,14 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap, hwaddr flashbase = virt_memmap[VIRT_FLASH].base; if (mc->dtb) { - fdt = s->fdt = load_device_tree(mc->dtb, &s->fdt_size); + fdt = mc->fdt = load_device_tree(mc->dtb, &s->fdt_size); if (!fdt) { error_report("load_device_tree() failed"); exit(1); } goto update_bootargs; } else { - fdt = s->fdt = create_device_tree(&s->fdt_size); + fdt = mc->fdt = create_device_tree(&s->fdt_size); if (!fdt) { error_report("create_device_tree() failed"); exit(1); @@ -444,12 +444,12 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap, g_free(name); name = g_strdup_printf("/soc/flash@%" PRIx64, flashbase); - qemu_fdt_add_subnode(s->fdt, name); - qemu_fdt_setprop_string(s->fdt, name, "compatible", "cfi-flash"); - qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", + qemu_fdt_add_subnode(mc->fdt, name); + qemu_fdt_setprop_string(mc->fdt, name, "compatible", "cfi-flash"); + qemu_fdt_setprop_sized_cells(mc->fdt, name, "reg", 2, flashbase, 2, flashsize, 2, flashbase + flashsize, 2, flashsize); - qemu_fdt_setprop_cell(s->fdt, name, "bank-width", 4); + qemu_fdt_setprop_cell(mc->fdt, name, "bank-width", 4); g_free(name); update_bootargs: @@ -667,9 +667,9 @@ static void virt_machine_init(MachineState *machine) hwaddr end = riscv_load_initrd(machine->initrd_filename, machine->ram_size, kernel_entry, &start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-start", start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-end", end); } } else { @@ -690,12 +690,12 @@ static void virt_machine_init(MachineState *machine) /* Compute the fdt load address in dram */ fdt_load_addr = riscv_load_fdt(memmap[VIRT_DRAM].base, - machine->ram_size, s->fdt); + machine->ram_size, machine->fdt); /* load the reset vector */ riscv_setup_rom_reset_vec(machine, &s->soc[0], start_addr, virt_memmap[VIRT_MROM].base, virt_memmap[VIRT_MROM].size, kernel_entry, - fdt_load_addr, s->fdt); + fdt_load_addr, machine->fdt); /* SiFive Test MMIO device */ sifive_test_create(memmap[VIRT_TEST].base);