[PATCH v2 4/9] hw/riscv/virt.c: add 'base' arg in create_fw_cfg()

Daniel Henrique Barboza posted 9 patches 6 months, 2 weeks ago
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
[PATCH v2 4/9] hw/riscv/virt.c: add 'base' arg in create_fw_cfg()
Posted by Daniel Henrique Barboza 6 months, 2 weeks ago
The function can receive the value via s->memmap[VIRT_FW_CFG].base from
the caller, avoiding the use of virt_memmap.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/riscv/virt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index f324777161..37f8abdd1c 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1261,9 +1261,8 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,
     return dev;
 }
 
-static FWCfgState *create_fw_cfg(const MachineState *ms)
+static FWCfgState *create_fw_cfg(const MachineState *ms, hwaddr base)
 {
-    hwaddr base = virt_memmap[VIRT_FW_CFG].base;
     FWCfgState *fw_cfg;
 
     fw_cfg = fw_cfg_init_mem_wide(base + 8, base, 8, base + 16,
@@ -1681,7 +1680,7 @@ static void virt_machine_init(MachineState *machine)
      * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the
      * device tree cannot be altered and we get FDT_ERR_NOSPACE.
      */
-    s->fw_cfg = create_fw_cfg(machine);
+    s->fw_cfg = create_fw_cfg(machine, s->memmap[VIRT_FW_CFG].base);
     rom_set_fw(s->fw_cfg);
 
     /* SiFive Test MMIO device */
-- 
2.49.0


Re: [PATCH v2 4/9] hw/riscv/virt.c: add 'base' arg in create_fw_cfg()
Posted by Alistair Francis 6 months, 2 weeks ago
On Tue, Apr 29, 2025 at 11:00 PM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> The function can receive the value via s->memmap[VIRT_FW_CFG].base from
> the caller, avoiding the use of virt_memmap.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/virt.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index f324777161..37f8abdd1c 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -1261,9 +1261,8 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,
>      return dev;
>  }
>
> -static FWCfgState *create_fw_cfg(const MachineState *ms)
> +static FWCfgState *create_fw_cfg(const MachineState *ms, hwaddr base)
>  {
> -    hwaddr base = virt_memmap[VIRT_FW_CFG].base;
>      FWCfgState *fw_cfg;
>
>      fw_cfg = fw_cfg_init_mem_wide(base + 8, base, 8, base + 16,
> @@ -1681,7 +1680,7 @@ static void virt_machine_init(MachineState *machine)
>       * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the
>       * device tree cannot be altered and we get FDT_ERR_NOSPACE.
>       */
> -    s->fw_cfg = create_fw_cfg(machine);
> +    s->fw_cfg = create_fw_cfg(machine, s->memmap[VIRT_FW_CFG].base);
>      rom_set_fw(s->fw_cfg);
>
>      /* SiFive Test MMIO device */
> --
> 2.49.0
>
>