[RFC PATCH v2 093/137] hw/riscv: Give memory regions an explicit owner

Alexander Graf <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel,org.nongnu.qemu-riscv
Message-ID <[email protected]>
Convert memory_region_init*() calls that pass NULL owner to pass
the enclosing machine or SoC device instead. All sites are inside
board init (MachineState *machine) or SoC realize (DeviceState *dev)
functions.

No functional change intended.

RAMBlock idstrs are unchanged: the owners added here are Machine
or SysBus devices, and memory_region_register_ram() maps both to
dev=NULL for qemu_ram_set_idstr().

AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 hw/riscv/boston-aia.c           |  8 ++++----
 hw/riscv/microblaze-v-generic.c |  4 ++--
 hw/riscv/microchip_pfsoc.c      | 14 +++++++-------
 hw/riscv/sifive_u.c             |  4 ++--
 hw/riscv/spike.c                |  2 +-
 hw/riscv/tt_atlantis.c          |  2 +-
 hw/riscv/virt.c                 |  2 +-
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/hw/riscv/boston-aia.c b/hw/riscv/boston-aia.c
index 5a9ec28068..ef41f53aac 100644
--- a/hw/riscv/boston-aia.c
+++ b/hw/riscv/boston-aia.c
@@ -374,7 +374,7 @@ static void boston_mach_init(MachineState *machine)
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
 
     flash =  g_new(MemoryRegion, 1);
-    memory_region_init_rom(flash, NULL, "boston.flash",
+    memory_region_init_rom(flash, OBJECT(machine), "boston.flash",
                            boston_memmap[BOSTON_FLASH].size, &error_fatal);
     memory_region_add_subregion_overlap(sys_mem,
                                         boston_memmap[BOSTON_FLASH].base,
@@ -385,7 +385,7 @@ static void boston_mach_init(MachineState *machine)
                                         machine->ram, 0);
 
     ddr_low_alias = g_new(MemoryRegion, 1);
-    memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr",
+    memory_region_init_alias(ddr_low_alias, OBJECT(machine), "boston_low.ddr",
                              machine->ram, 0,
                              MIN(machine->ram_size, (256 * MiB)));
     memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0);
@@ -398,7 +398,7 @@ static void boston_mach_init(MachineState *machine)
                              qdev_get_gpio_in(s->cps.aplic, PCIE2_INT));
 
     platreg = g_new(MemoryRegion, 1);
-    memory_region_init_io(platreg, NULL, &boston_platreg_ops, s,
+    memory_region_init_io(platreg, OBJECT(machine), &boston_platreg_ops, s,
                           "boston-platregs",
                           boston_memmap[BOSTON_PLATREG].size);
     memory_region_add_subregion_overlap(sys_mem,
@@ -410,7 +410,7 @@ static void boston_mach_init(MachineState *machine)
                              serial_hd(0), DEVICE_LITTLE_ENDIAN);
 
     lcd = g_new(MemoryRegion, 1);
-    memory_region_init_io(lcd, NULL, &boston_lcd_ops, s, "boston-lcd", 0x8);
+    memory_region_init_io(lcd, OBJECT(machine), &boston_lcd_ops, s, "boston-lcd", 0x8);
     memory_region_add_subregion_overlap(sys_mem,
                                         boston_memmap[BOSTON_LCD].base, lcd, 0);
 
diff --git a/hw/riscv/microblaze-v-generic.c b/hw/riscv/microblaze-v-generic.c
index 7253ae7822..0a83932405 100644
--- a/hw/riscv/microblaze-v-generic.c
+++ b/hw/riscv/microblaze-v-generic.c
@@ -70,12 +70,12 @@ static void mb_v_generic_init(MachineState *machine)
     object_property_set_bool(OBJECT(cpu), "d", false, NULL);
     qdev_realize(DEVICE(cpu), NULL, &error_abort);
     /* Attach emulated BRAM through the LMB.  */
-    memory_region_init_ram(phys_lmb_bram, NULL,
+    memory_region_init_ram(phys_lmb_bram, OBJECT(machine),
                            "mb_v.lmb_bram", LMB_BRAM_SIZE,
                            &error_fatal);
     memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
 
-    memory_region_init_ram(phys_ram, NULL, "mb_v.ram",
+    memory_region_init_ram(phys_ram, OBJECT(machine), "mb_v.ram",
                            ram_size, &error_fatal);
     memory_region_add_subregion(sysmem, ddr_base, phys_ram);
 
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
index 0a98ac1c5e..f1ee64ef86 100644
--- a/hw/riscv/microchip_pfsoc.c
+++ b/hw/riscv/microchip_pfsoc.c
@@ -219,14 +219,14 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
     qdev_realize(DEVICE(&s->u_cluster), NULL, &error_abort);
 
     /* Reserved Memory at address 0 */
-    memory_region_init_ram(rsvd0_mem, NULL, "microchip.pfsoc.rsvd0_mem",
+    memory_region_init_ram(rsvd0_mem, OBJECT(dev), "microchip.pfsoc.rsvd0_mem",
                            memmap[MICROCHIP_PFSOC_RSVD0].size, &error_fatal);
     memory_region_add_subregion(system_memory,
                                 memmap[MICROCHIP_PFSOC_RSVD0].base,
                                 rsvd0_mem);
 
     /* E51 DTIM */
-    memory_region_init_ram(e51_dtim_mem, NULL, "microchip.pfsoc.e51_dtim_mem",
+    memory_region_init_ram(e51_dtim_mem, OBJECT(dev), "microchip.pfsoc.e51_dtim_mem",
                            memmap[MICROCHIP_PFSOC_E51_DTIM].size, &error_fatal);
     memory_region_add_subregion(system_memory,
                                 memmap[MICROCHIP_PFSOC_E51_DTIM].base,
@@ -271,7 +271,7 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
      * leave it enabled all the time. This won't break anything, but will be
      * too generous to misbehaving guests.
      */
-    memory_region_init_ram(l2lim_mem, NULL, "microchip.pfsoc.l2lim",
+    memory_region_init_ram(l2lim_mem, OBJECT(dev), "microchip.pfsoc.l2lim",
                            memmap[MICROCHIP_PFSOC_L2LIM].size, &error_fatal);
     memory_region_add_subregion(system_memory,
                                 memmap[MICROCHIP_PFSOC_L2LIM].base,
@@ -549,10 +549,10 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
     /* Split RAM into low and high regions using aliases to machine->ram */
     mem_low_size = memmap[MICROCHIP_PFSOC_DRAM_LO].size;
     mem_high_size = machine->ram_size - mem_low_size;
-    memory_region_init_alias(mem_low, NULL,
+    memory_region_init_alias(mem_low, OBJECT(machine),
                              "microchip.icicle.kit.ram_low", machine->ram,
                              0, mem_low_size);
-    memory_region_init_alias(mem_high, NULL,
+    memory_region_init_alias(mem_high, OBJECT(machine),
                              "microchip.icicle.kit.ram_high", machine->ram,
                              mem_low_size, mem_high_size);
 
@@ -565,13 +565,13 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
                                 mem_high);
 
     /* Create aliases for the low and high RAM regions */
-    memory_region_init_alias(mem_low_alias, NULL,
+    memory_region_init_alias(mem_low_alias, OBJECT(machine),
                              "microchip.icicle.kit.ram_low.alias",
                              mem_low, 0, mem_low_size);
     memory_region_add_subregion(system_memory,
                                 memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].base,
                                 mem_low_alias);
-    memory_region_init_alias(mem_high_alias, NULL,
+    memory_region_init_alias(mem_high_alias, OBJECT(machine),
                              "microchip.icicle.kit.ram_high.alias",
                              mem_high, 0, mem_high_size);
     memory_region_add_subregion(system_memory,
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index aba6716b73..9d3f5c8f59 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -477,7 +477,7 @@ static void sifive_u_machine_init(MachineState *machine)
                                 machine->ram);
 
     /* register QSPI0 Flash */
-    memory_region_init_ram(flash0, NULL, "riscv.sifive.u.flash0",
+    memory_region_init_ram(flash0, OBJECT(machine), "riscv.sifive.u.flash0",
                            memmap[SIFIVE_U_DEV_FLASH0].size, &error_fatal);
     memory_region_add_subregion(system_memory, memmap[SIFIVE_U_DEV_FLASH0].base,
                                 flash0);
@@ -763,7 +763,7 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
      * leave it enabled all the time. This won't break anything, but will be
      * too generous to misbehaving guests.
      */
-    memory_region_init_ram(l2lim_mem, NULL, "riscv.sifive.u.l2lim",
+    memory_region_init_ram(l2lim_mem, OBJECT(dev), "riscv.sifive.u.l2lim",
                            memmap[SIFIVE_U_DEV_L2LIM].size, &error_fatal);
     memory_region_add_subregion(system_memory, memmap[SIFIVE_U_DEV_L2LIM].base,
                                 l2lim_mem);
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index c53409e4f1..9f1a1b5898 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -179,7 +179,7 @@ static void spike_board_init(MachineState *machine)
         machine->ram);
 
     /* boot rom */
-    memory_region_init_rom(mask_rom, NULL, "riscv.spike.mrom",
+    memory_region_init_rom(mask_rom, OBJECT(machine), "riscv.spike.mrom",
                            memmap[SPIKE_MROM].size, &error_fatal);
     memory_region_add_subregion(system_memory, memmap[SPIKE_MROM].base,
                                 mask_rom);
diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c
index 068a0bc542..e378f6e856 100644
--- a/hw/riscv/tt_atlantis.c
+++ b/hw/riscv/tt_atlantis.c
@@ -538,7 +538,7 @@ static void tt_atlantis_machine_init(MachineState *machine)
                                 s->memmap[TT_ATL_DDR_LO].base, ram_lo);
 
     /* Boot ROM */
-    memory_region_init_rom(bootrom, NULL, "tt-atlantis.bootrom",
+    memory_region_init_rom(bootrom, OBJECT(machine), "tt-atlantis.bootrom",
                            s->memmap[TT_ATL_BOOTROM].size, &error_fatal);
     memory_region_add_subregion(system_memory, s->memmap[TT_ATL_BOOTROM].base,
                                 bootrom);
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 718b730a4d..3442edb87a 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1462,7 +1462,7 @@ static void virt_machine_init(MachineState *machine)
                                 machine->ram);
 
     /* boot rom */
-    memory_region_init_rom(mask_rom, NULL, "riscv_virt_board.mrom",
+    memory_region_init_rom(mask_rom, OBJECT(machine), "riscv_virt_board.mrom",
                            s->memmap[VIRT_MROM].size, &error_fatal);
     memory_region_add_subregion(system_memory, s->memmap[VIRT_MROM].base,
                                 mask_rom);
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.