Convert memory_region_init*() calls that pass NULL owner to pass the enclosing machine or device instead.
Thread Object *owner through xtensa_create_memory_regions(), xtensa_mx_pic_register_cpu() and the static xtfpga_fpga_init() helper. All callers are inside board init functions. No functional change intended. Assisted-by: Kiro Signed-off-by: Alexander Graf <[email protected]> --- hw/xtensa/mx_pic.c | 4 ++-- hw/xtensa/sim.c | 15 ++++++++------- hw/xtensa/xtensa_memory.c | 5 +++-- hw/xtensa/xtensa_memory.h | 3 ++- hw/xtensa/xtfpga.c | 30 ++++++++++++++++-------------- include/hw/xtensa/mx_pic.h | 2 +- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/hw/xtensa/mx_pic.c b/hw/xtensa/mx_pic.c index 8ded3bc79b..f349fb125c 100644 --- a/hw/xtensa/mx_pic.c +++ b/hw/xtensa/mx_pic.c @@ -299,7 +299,7 @@ static const MemoryRegionOps xtensa_mx_pic_ops = { }, }; -MemoryRegion *xtensa_mx_pic_register_cpu(XtensaMxPic *mx, +MemoryRegion *xtensa_mx_pic_register_cpu(Object *owner, XtensaMxPic *mx, qemu_irq *irq, qemu_irq runstall) { @@ -309,7 +309,7 @@ MemoryRegion *xtensa_mx_pic_register_cpu(XtensaMxPic *mx, mx_cpu->irq = irq; mx_cpu->runstall = runstall; - memory_region_init_io(&mx_cpu->reg, NULL, &xtensa_mx_pic_ops, mx_cpu, + memory_region_init_io(&mx_cpu->reg, owner, &xtensa_mx_pic_ops, mx_cpu, "mx_pic", 0x280); ++mx->n_cpu; diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c index ad1439a0b4..e3cd69ceca 100644 --- a/hw/xtensa/sim.c +++ b/hw/xtensa/sim.c @@ -60,10 +60,11 @@ XtensaCPU *xtensa_sim_common_init(MachineState *machine) XtensaCPU *cpu = NULL; CPUXtensaState *env = NULL; ram_addr_t ram_size = machine->ram_size; + Object *mo = OBJECT(machine); int n; for (n = 0; n < machine->smp.cpus; n++) { - cpu = XTENSA_CPU(cpu_create(OBJECT(machine), "cpu[*]", machine->cpu_type)); + cpu = XTENSA_CPU(cpu_create(mo, "cpu[*]", machine->cpu_type)); env = &cpu->env; env->sregs[PRID] = n; @@ -78,17 +79,17 @@ XtensaCPU *xtensa_sim_common_init(MachineState *machine) XtensaMemory sysram = env->config->sysram; sysram.location[0].size = ram_size; - xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom", + xtensa_create_memory_regions(mo, &env->config->instrom, "xtensa.instrom", get_system_memory()); - xtensa_create_memory_regions(&env->config->instram, "xtensa.instram", + xtensa_create_memory_regions(mo, &env->config->instram, "xtensa.instram", get_system_memory()); - xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom", + xtensa_create_memory_regions(mo, &env->config->datarom, "xtensa.datarom", get_system_memory()); - xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram", + xtensa_create_memory_regions(mo, &env->config->dataram, "xtensa.dataram", get_system_memory()); - xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom", + xtensa_create_memory_regions(mo, &env->config->sysrom, "xtensa.sysrom", get_system_memory()); - xtensa_create_memory_regions(&sysram, "xtensa.sysram", + xtensa_create_memory_regions(mo, &sysram, "xtensa.sysram", get_system_memory()); } if (serial_hd(0)) { diff --git a/hw/xtensa/xtensa_memory.c b/hw/xtensa/xtensa_memory.c index 13a6077d86..4477eea0ad 100644 --- a/hw/xtensa/xtensa_memory.c +++ b/hw/xtensa/xtensa_memory.c @@ -31,7 +31,8 @@ #include "qemu/error-report.h" #include "xtensa_memory.h" -void xtensa_create_memory_regions(const XtensaMemory *memory, +void xtensa_create_memory_regions(Object *owner, + const XtensaMemory *memory, const char *name, MemoryRegion *super) { @@ -43,7 +44,7 @@ void xtensa_create_memory_regions(const XtensaMemory *memory, g_string_printf(num_name, "%s%u", name, i); m = g_new(MemoryRegion, 1); - memory_region_init_ram(m, NULL, num_name->str, + memory_region_init_ram(m, owner, num_name->str, memory->location[i].size, &error_fatal); memory_region_add_subregion(super, memory->location[i].addr, m); } diff --git a/hw/xtensa/xtensa_memory.h b/hw/xtensa/xtensa_memory.h index c86ad06685..b8b2d4b8b4 100644 --- a/hw/xtensa/xtensa_memory.h +++ b/hw/xtensa/xtensa_memory.h @@ -30,7 +30,8 @@ #include "target/xtensa/cpu.h" -void xtensa_create_memory_regions(const XtensaMemory *memory, +void xtensa_create_memory_regions(Object *owner, + const XtensaMemory *memory, const char *name, MemoryRegion *super); diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 1c48283f5d..f0c21180a2 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -125,12 +125,13 @@ static const MemoryRegionOps xtfpga_fpga_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space, +static XtfpgaFpgaState *xtfpga_fpga_init(Object *owner, + MemoryRegion *address_space, hwaddr base, uint32_t freq) { XtfpgaFpgaState *s = g_new(XtfpgaFpgaState, 1); - memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s, + memory_region_init_io(&s->iomem, owner, &xtfpga_fpga_ops, s, "xtfpga.fpga", 0x10000); memory_region_add_subregion(address_space, base, &s->iomem); s->freq = freq; @@ -243,6 +244,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) uint32_t freq = 10000000; int n; unsigned int smp_cpus = machine->smp.cpus; + Object *mo = OBJECT(machine); if (smp_cpus > 1) { mx_pic = xtensa_mx_pic_init(31); @@ -262,7 +264,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) if (mx_pic) { MemoryRegion *mx_eri; - mx_eri = xtensa_mx_pic_register_cpu(mx_pic, + mx_eri = xtensa_mx_pic_register_cpu(OBJECT(machine), mx_pic, xtensa_get_extints(cenv), xtensa_get_runstall(cenv)); memory_region_add_subregion(xtensa_get_er_region(cenv), @@ -286,30 +288,30 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) XtensaMemory sysram = env->config->sysram; sysram.location[0].size = machine->ram_size; - xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom", + xtensa_create_memory_regions(mo, &env->config->instrom, "xtensa.instrom", system_memory); - xtensa_create_memory_regions(&env->config->instram, "xtensa.instram", + xtensa_create_memory_regions(mo, &env->config->instram, "xtensa.instram", system_memory); - xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom", + xtensa_create_memory_regions(mo, &env->config->datarom, "xtensa.datarom", system_memory); - xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram", + xtensa_create_memory_regions(mo, &env->config->dataram, "xtensa.dataram", system_memory); - xtensa_create_memory_regions(&sysram, "xtensa.sysram", + xtensa_create_memory_regions(mo, &sysram, "xtensa.sysram", system_memory); } system_io = g_malloc(sizeof(*system_io)); - memory_region_init_io(system_io, NULL, &xtfpga_io_ops, NULL, "xtfpga.io", + memory_region_init_io(system_io, OBJECT(machine), &xtfpga_io_ops, NULL, "xtfpga.io", system_io_size); memory_region_add_subregion(system_memory, board->io[0], system_io); if (board->io[1]) { MemoryRegion *io = g_malloc(sizeof(*io)); - memory_region_init_alias(io, NULL, "xtfpga.io.cached", + memory_region_init_alias(io, OBJECT(machine), "xtfpga.io.cached", system_io, 0, system_io_size); memory_region_add_subregion(system_memory, board->io[1], io); } - xtfpga_fpga_init(system_io, 0x0d020000, freq); + xtfpga_fpga_init(OBJECT(machine), system_io, 0x0d020000, freq); xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, extints[1]); serial_mm_init(OBJECT(machine), system_io, 0x0d050020, 2, extints[0], @@ -341,7 +343,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) lowmem_end += env->config->sysram.location[0].addr; cur_lowmem += env->config->sysram.location[0].addr; - xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom", + xtensa_create_memory_regions(mo, &env->config->sysrom, "xtensa.sysrom", system_memory); if (kernel_cmdline) { @@ -465,13 +467,13 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) size = board->flash->size - board->flash->boot_base; } - memory_region_init_alias(flash_io, NULL, "xtfpga.flash", + memory_region_init_alias(flash_io, OBJECT(machine), "xtfpga.flash", flash_mr, board->flash->boot_base, size); memory_region_add_subregion(system_memory, env->config->sysrom.location[0].addr, flash_io); } else { - xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom", + xtensa_create_memory_regions(mo, &env->config->sysrom, "xtensa.sysrom", system_memory); } } diff --git a/include/hw/xtensa/mx_pic.h b/include/hw/xtensa/mx_pic.h index cd316d86eb..01d5ea884e 100644 --- a/include/hw/xtensa/mx_pic.h +++ b/include/hw/xtensa/mx_pic.h @@ -35,7 +35,7 @@ typedef struct XtensaMxPic XtensaMxPic; XtensaMxPic *xtensa_mx_pic_init(unsigned n_extint); void xtensa_mx_pic_reset(void *opaque); -MemoryRegion *xtensa_mx_pic_register_cpu(XtensaMxPic *mx, +MemoryRegion *xtensa_mx_pic_register_cpu(Object *owner, XtensaMxPic *mx, qemu_irq *irq, qemu_irq runstall); qemu_irq *xtensa_mx_pic_get_extints(XtensaMxPic *mx); -- 2.47.1
