From patchwork Wed Dec 28 12:42:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13082899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 54C8DC46467 for ; Wed, 28 Dec 2022 12:43:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAVmF-0005L5-Kj; Wed, 28 Dec 2022 07:43:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAVlz-00058k-7c for qemu-devel@nongnu.org; Wed, 28 Dec 2022 07:43:11 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAVlr-0007mW-Ta for qemu-devel@nongnu.org; Wed, 28 Dec 2022 07:43:01 -0500 Received: by mail-ot1-x32c.google.com with SMTP id k7-20020a056830168700b0067832816190so9809490otr.1 for ; Wed, 28 Dec 2022 04:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=14j0rjtt0NAYgU5LJ1kqKbCWT8XXgNf4j+2giaEVxKo=; b=IaFGSW5AJBCxp9XP2P1vg8pPKwv988B7Op6QmI5W6mmZ94DDORZ3dJo62xMBMPwM8o Axb4SpCWDPdiDSeAYK0nngFOkjXzEJPnx0kL02eTf+8z2bHm/V4+EJoBKXYSdMZEvvWZ 4fmDlduqtCHAiD2M81t/LsBFuG53+p3iYVi2N4gctdHQXhMRdb9obQ/FwAofv9ljdyTP o67LXB7QgVUNDef5i5FqybbwZFtvvJ3kIwni8yciXLsdUtoufafjr21lU5B1DmX7lsa8 pGe8h8WZg2uVSNuqc1iwKjtTYDxb/qC+5kwI/2vVwYZy+utieHVW4ADbqFs8V8ofQRKW n0rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=14j0rjtt0NAYgU5LJ1kqKbCWT8XXgNf4j+2giaEVxKo=; b=I7NbmdAzxyg++r3VQDiTCrNWlBtG166gSZqaFGpx9DN9tB2ZT+5dow4aeBivYMZmga nop5Gm4VxlIE7tW8W1SAZMTyw+uYxuKfzAj2KKQXtgBTcJo83aMstZZBb0uJw2344AEO sbwSGOwqblG1fjsUIxfMth68f+3WmlX1I7jOxWDB+Yp6+3x9Qd0oN9Gh07ZcsbNrhza6 zaXxHoFsPvh5EQdCSfLo2H0PKllVy4s9dfjnlWe4TYmWw8BqMQCXcXhZtuvNhIPIA+mS gMlqEU61QEvVTdIQ/0IDk7+hOBMWFgC2N+BSCM3RVW6J5PbMgFmbWelC463FxRrA/lMo 2Hrg== X-Gm-Message-State: AFqh2kqevV5YpkpyHXTHnnRulxruc57RyirsIJVneFZb0dhxLlbKwmV5 V8R8u+yc7dGkfhgtnjsHqvGWv67Yqdk1DBZd X-Google-Smtp-Source: AMrXdXthyZ0z0zX7qYj7gRmuq0Rlwtp3V6Pmg6inZXqFM/tUJoU/1NoPYUkvhWS+kkrkq92pFSBmqg== X-Received: by 2002:a05:6830:1110:b0:675:2e8a:8263 with SMTP id w16-20020a056830111000b006752e8a8263mr13473111otq.14.1672231377577; Wed, 28 Dec 2022 04:42:57 -0800 (PST) Received: from fedora.. ([191.17.222.139]) by smtp.gmail.com with ESMTPSA id cj5-20020a056830640500b0066f09567827sm7689333otb.78.2022.12.28.04.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:42:57 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, Daniel Henrique Barboza , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH v2 02/10] hw/riscv/spike: use 'fdt' from MachineState Date: Wed, 28 Dec 2022 09:42:34 -0300 Message-Id: <20221228124242.184784-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221228124242.184784-1-dbarboza@ventanamicro.com> References: <20221228124242.184784-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32c; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32c.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The MachineState object provides a 'fdt' pointer that is already being used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP command. Remove the 'fdt' pointer from SpikeState and use MachineState::fdt instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Bin Meng --- hw/riscv/spike.c | 12 +++++------- include/hw/riscv/spike.h | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 1b747d8f7c..426c383cef 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -53,6 +53,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap, bool is_32_bit, bool htif_custom_base) { void *fdt; + int fdt_size; uint64_t addr, size; unsigned long clint_addr; int cpu, socket; @@ -65,7 +66,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap, "sifive,clint0", "riscv,clint0" }; - fdt = s->fdt = create_device_tree(&s->fdt_size); + fdt = mc->fdt = create_device_tree(&fdt_size); if (!fdt) { error_report("create_device_tree() failed"); exit(1); @@ -322,18 +323,15 @@ static void spike_board_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); } /* Compute the fdt load address in dram */ fdt_load_addr = riscv_load_fdt(memmap[SPIKE_DRAM].base, - machine->ram_size, s->fdt); - - /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ - machine->fdt = s->fdt; + machine->ram_size, machine->fdt); /* load the reset vector */ riscv_setup_rom_reset_vec(machine, &s->soc[0], memmap[SPIKE_DRAM].base, diff --git a/include/hw/riscv/spike.h b/include/hw/riscv/spike.h index 73d69234de..d13a147942 100644 --- a/include/hw/riscv/spike.h +++ b/include/hw/riscv/spike.h @@ -37,8 +37,6 @@ struct SpikeState { /*< public >*/ RISCVHartArrayState soc[SPIKE_SOCKETS_MAX]; - void *fdt; - int fdt_size; }; enum {