[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 4/7] hw/riscv: simplify riscv_compute_fdt_addr()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v3 4/7] hw/riscv: simplify riscv_compute_fdt_addr() |
Date: |
Thu, 19 Jan 2023 16:17:25 -0300 |
All callers are using attributes from the MachineState object. Use a
pointer to it instead of passing dram_size (which is always
machine->ram_size) and fdt (always machine->fdt).
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
hw/riscv/boot.c | 6 +++---
hw/riscv/sifive_u.c | 4 ++--
hw/riscv/spike.c | 4 ++--
hw/riscv/virt.c | 3 +--
include/hw/riscv/boot.h | 2 +-
5 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 13b5ce2d49..3027457042 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -260,11 +260,11 @@ void riscv_load_initrd(MachineState *machine, uint64_t
kernel_entry)
*
* The FDT is fdt_packed() during the calculation.
*/
-uint32_t riscv_compute_fdt_addr(hwaddr dram_base, uint64_t mem_size,
- void *fdt)
+uint32_t riscv_compute_fdt_addr(MachineState *machine, hwaddr dram_base)
{
+ void *fdt = machine->fdt;
uint64_t temp;
- hwaddr dram_end = dram_base + mem_size;
+ hwaddr dram_end = dram_base + machine->ram_size;
int ret = fdt_pack(fdt);
int fdtsize;
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 626d4dc2f3..ebfddf161d 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -616,8 +616,8 @@ static void sifive_u_machine_init(MachineState *machine)
kernel_entry = 0;
}
- fdt_load_addr = riscv_compute_fdt_addr(memmap[SIFIVE_U_DEV_DRAM].base,
- machine->ram_size, machine->fdt);
+ fdt_load_addr = riscv_compute_fdt_addr(machine,
+ memmap[SIFIVE_U_DEV_DRAM].base);
riscv_load_fdt(fdt_load_addr, machine->fdt);
if (!riscv_is_32bit(&s->soc.u_cpus)) {
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index 88b9fdfc36..afd581436b 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -324,8 +324,8 @@ static void spike_board_init(MachineState *machine)
kernel_entry = 0;
}
- fdt_load_addr = riscv_compute_fdt_addr(memmap[SPIKE_DRAM].base,
- machine->ram_size, machine->fdt);
+ fdt_load_addr = riscv_compute_fdt_addr(machine,
+ memmap[SPIKE_DRAM].base);
riscv_load_fdt(fdt_load_addr, machine->fdt);
/* load the reset vector */
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 67c8a01e1d..2688410fc5 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1300,8 +1300,7 @@ static void virt_machine_done(Notifier *notifier, void
*data)
start_addr = virt_memmap[VIRT_FLASH].base;
}
- fdt_load_addr = riscv_compute_fdt_addr(memmap[VIRT_DRAM].base,
- machine->ram_size, machine->fdt);
+ fdt_load_addr = riscv_compute_fdt_addr(machine, memmap[VIRT_DRAM].base);
riscv_load_fdt(fdt_load_addr, machine->fdt);
/* load the reset vector */
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
index c529ed2129..79d3bf268b 100644
--- a/include/hw/riscv/boot.h
+++ b/include/hw/riscv/boot.h
@@ -47,7 +47,7 @@ target_ulong riscv_load_kernel(MachineState *machine,
target_ulong firmware_end_addr,
symbol_fn_t sym_cb);
void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry);
-uint32_t riscv_compute_fdt_addr(hwaddr dram_start, uint64_t dram_size, void
*fdt);
+uint32_t riscv_compute_fdt_addr(MachineState *machine, hwaddr dram_start);
void riscv_load_fdt(hwaddr fdt_addr, void *fdt);
void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState
*harts,
hwaddr saddr,
--
2.39.0
- [PATCH v3 0/7] riscv: fdt related cleanups, Daniel Henrique Barboza, 2023/01/19
- [PATCH v3 1/7] hw/riscv/boot.c: calculate fdt size after fdt_pack(), Daniel Henrique Barboza, 2023/01/19
- [PATCH v3 2/7] hw/riscv: split fdt address calculation from fdt load, Daniel Henrique Barboza, 2023/01/19
- [PATCH v3 5/7] hw/riscv/virt.c: calculate socket count once in create_fdt_imsic(), Daniel Henrique Barboza, 2023/01/19
- [PATCH v3 4/7] hw/riscv: simplify riscv_compute_fdt_addr(),
Daniel Henrique Barboza <=
- [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Daniel Henrique Barboza, 2023/01/19
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Conor Dooley, 2023/01/19
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Conor Dooley, 2023/01/19
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Daniel Henrique Barboza, 2023/01/21
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Conor Dooley, 2023/01/21
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Alistair Francis, 2023/01/22
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Daniel Henrique Barboza, 2023/01/23
- Re: [PATCH v3 3/7] hw/riscv/microchip_pfsoc.c: add an Icicle Kit fdt address function, Alistair Francis, 2023/01/23