On Tue, Apr 29, 2025 at 11:01 PM Daniel Henrique Barboza <dbarb...@ventanamicro.com> wrote: > > create_fdt(), create_fdt_flash() and create_fdt_fw_cfg() can access the > memmap via their RISCVVirtState pointers. > > Signed-off-by: Daniel Henrique Barboza <dbarb...@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.fran...@wdc.com> Alistair > --- > hw/riscv/virt.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c > index 37f8abdd1c..5f31c95955 100644 > --- a/hw/riscv/virt.c > +++ b/hw/riscv/virt.c > @@ -995,7 +995,7 @@ static void create_fdt_rtc(RISCVVirtState *s, const > MemMapEntry *memmap, > } > } > > -static void create_fdt_flash(RISCVVirtState *s, const MemMapEntry *memmap) > +static void create_fdt_flash(RISCVVirtState *s) > { > MachineState *ms = MACHINE(s); > hwaddr flashsize = s->memmap[VIRT_FLASH].size / 2; > @@ -1010,11 +1010,11 @@ static void create_fdt_flash(RISCVVirtState *s, const > MemMapEntry *memmap) > qemu_fdt_setprop_cell(ms->fdt, name, "bank-width", 4); > } > > -static void create_fdt_fw_cfg(RISCVVirtState *s, const MemMapEntry *memmap) > +static void create_fdt_fw_cfg(RISCVVirtState *s) > { > MachineState *ms = MACHINE(s); > - hwaddr base = memmap[VIRT_FW_CFG].base; > - hwaddr size = memmap[VIRT_FW_CFG].size; > + hwaddr base = s->memmap[VIRT_FW_CFG].base; > + hwaddr size = s->memmap[VIRT_FW_CFG].size; > g_autofree char *nodename = g_strdup_printf("/fw-cfg@%" PRIx64, base); > > qemu_fdt_add_subnode(ms->fdt, nodename); > @@ -1145,7 +1145,7 @@ static void finalize_fdt(RISCVVirtState *s) > create_fdt_rtc(s, s->memmap, irq_mmio_phandle); > } > > -static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap) > +static void create_fdt(RISCVVirtState *s) > { > MachineState *ms = MACHINE(s); > uint8_t rng_seed[32]; > @@ -1172,7 +1172,8 @@ static void create_fdt(RISCVVirtState *s, const > MemMapEntry *memmap) > * The "/soc/pci@..." node is needed for PCIE hotplugs > * that might happen before finalize_fdt(). > */ > - name = g_strdup_printf("/soc/pci@%lx", (long) > memmap[VIRT_PCIE_ECAM].base); > + name = g_strdup_printf("/soc/pci@%lx", > + (long) s->memmap[VIRT_PCIE_ECAM].base); > qemu_fdt_add_subnode(ms->fdt, name); > > qemu_fdt_add_subnode(ms->fdt, "/chosen"); > @@ -1184,8 +1185,8 @@ static void create_fdt(RISCVVirtState *s, const > MemMapEntry *memmap) > > qemu_fdt_add_subnode(ms->fdt, "/aliases"); > > - create_fdt_flash(s, memmap); > - create_fdt_fw_cfg(s, memmap); > + create_fdt_flash(s); > + create_fdt_fw_cfg(s); > create_fdt_pmu(s); > } > > @@ -1719,7 +1720,7 @@ static void virt_machine_init(MachineState *machine) > exit(1); > } > } else { > - create_fdt(s, s->memmap); > + create_fdt(s); > } > > if (virt_is_iommu_sys_enabled(s)) { > -- > 2.49.0 > >