mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
hw/riscv/virt.c: use s->memmap in create_fdt_virtio()
create_fdt_virtio() can use s->memmap instead of having an extra argument for it. While we're at it rewrite it a little bit to avoid the clunky line in 'name' and code repetition: - declare 'virtio_base' out of the loop since it never changes; - declare a 'size' variable. Use it to calculate the address of the virtio device in an 'addr' variable; - use 'addr' in the 'name' g_strdup_printf(); - use 'addr' and 'size' when creating the 'reg' property. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20250429125811.224803-8-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
04c4f8d1ee
commit
a51a88fd5d
1 changed files with 10 additions and 7 deletions
|
@ -842,21 +842,24 @@ static void create_fdt_sockets(RISCVVirtState *s,
|
|||
riscv_socket_fdt_write_distance_matrix(ms);
|
||||
}
|
||||
|
||||
static void create_fdt_virtio(RISCVVirtState *s, const MemMapEntry *memmap,
|
||||
uint32_t irq_virtio_phandle)
|
||||
static void create_fdt_virtio(RISCVVirtState *s, uint32_t irq_virtio_phandle)
|
||||
{
|
||||
int i;
|
||||
MachineState *ms = MACHINE(s);
|
||||
hwaddr virtio_base = s->memmap[VIRT_VIRTIO].base;
|
||||
|
||||
for (i = 0; i < VIRTIO_COUNT; i++) {
|
||||
g_autofree char *name = g_strdup_printf("/soc/virtio_mmio@%lx",
|
||||
(long)(memmap[VIRT_VIRTIO].base + i * memmap[VIRT_VIRTIO].size));
|
||||
g_autofree char *name = NULL;
|
||||
uint64_t size = s->memmap[VIRT_VIRTIO].size;
|
||||
hwaddr addr = virtio_base + i * size;
|
||||
|
||||
name = g_strdup_printf("/soc/virtio_mmio@%"HWADDR_PRIx, addr);
|
||||
|
||||
qemu_fdt_add_subnode(ms->fdt, name);
|
||||
qemu_fdt_setprop_string(ms->fdt, name, "compatible", "virtio,mmio");
|
||||
qemu_fdt_setprop_cells(ms->fdt, name, "reg",
|
||||
0x0, memmap[VIRT_VIRTIO].base + i * memmap[VIRT_VIRTIO].size,
|
||||
0x0, memmap[VIRT_VIRTIO].size);
|
||||
0x0, addr,
|
||||
0x0, size);
|
||||
qemu_fdt_setprop_cell(ms->fdt, name, "interrupt-parent",
|
||||
irq_virtio_phandle);
|
||||
if (s->aia_type == VIRT_AIA_TYPE_NONE) {
|
||||
|
@ -1135,7 +1138,7 @@ static void finalize_fdt(RISCVVirtState *s)
|
|||
&irq_pcie_phandle, &irq_virtio_phandle,
|
||||
&msi_pcie_phandle);
|
||||
|
||||
create_fdt_virtio(s, s->memmap, irq_virtio_phandle);
|
||||
create_fdt_virtio(s, irq_virtio_phandle);
|
||||
|
||||
if (virt_is_iommu_sys_enabled(s)) {
|
||||
create_fdt_iommu_sys(s, irq_mmio_phandle, msi_pcie_phandle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue