hw/arm: Let devices own the MemoryRegion they create
Avoid orphan memory regions being added in the /unattached QOM container. This commit was produced with the Coccinelle script scripts/coccinelle/memory-region-housekeeping.cocci. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
5b871c1b62
commit
32b9523ad5
@ -305,20 +305,20 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
|
||||
/*** Memory ***/
|
||||
|
||||
/* Chip-ID and OMR */
|
||||
memory_region_init_io(&s->chipid_mem, NULL, &exynos4210_chipid_and_omr_ops,
|
||||
NULL, "exynos4210.chipid", sizeof(chipid_and_omr));
|
||||
memory_region_init_io(&s->chipid_mem, OBJECT(socdev),
|
||||
&exynos4210_chipid_and_omr_ops, NULL,
|
||||
"exynos4210.chipid", sizeof(chipid_and_omr));
|
||||
memory_region_add_subregion(system_mem, EXYNOS4210_CHIPID_ADDR,
|
||||
&s->chipid_mem);
|
||||
|
||||
/* Internal ROM */
|
||||
memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
|
||||
memory_region_init_rom(&s->irom_mem, OBJECT(socdev), "exynos4210.irom",
|
||||
EXYNOS4210_IROM_SIZE, &error_fatal);
|
||||
memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
|
||||
&s->irom_mem);
|
||||
/* mirror of iROM */
|
||||
memory_region_init_alias(&s->irom_alias_mem, NULL, "exynos4210.irom_alias",
|
||||
&s->irom_mem,
|
||||
0,
|
||||
memory_region_init_alias(&s->irom_alias_mem, OBJECT(socdev),
|
||||
"exynos4210.irom_alias", &s->irom_mem, 0,
|
||||
EXYNOS4210_IROM_SIZE);
|
||||
memory_region_add_subregion(system_mem, EXYNOS4210_IROM_MIRROR_BASE_ADDR,
|
||||
&s->irom_alias_mem);
|
||||
|
@ -303,16 +303,16 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
/* initialize 2 x 16 KB ROM */
|
||||
memory_region_init_rom(&s->rom[0], NULL,
|
||||
"imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
|
||||
memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
|
||||
FSL_IMX25_ROM0_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
|
||||
&s->rom[0]);
|
||||
memory_region_init_rom(&s->rom[1], NULL,
|
||||
"imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
|
||||
memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1",
|
||||
FSL_IMX25_ROM1_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
@ -331,7 +331,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
|
||||
&s->iram);
|
||||
|
||||
/* internal RAM (128 KB) is aliased over 128 MB - 128 KB */
|
||||
memory_region_init_alias(&s->iram_alias, NULL, "imx25.iram_alias",
|
||||
memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx25.iram_alias",
|
||||
&s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
|
||||
&s->iram_alias);
|
||||
|
@ -206,7 +206,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
/* On a real system, the first 16k is a `secure boot rom' */
|
||||
memory_region_init_rom(&s->secure_rom, NULL, "imx31.secure_rom",
|
||||
memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom",
|
||||
FSL_IMX31_SECURE_ROM_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
@ -216,7 +216,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
|
||||
&s->secure_rom);
|
||||
|
||||
/* There is also a 16k ROM */
|
||||
memory_region_init_rom(&s->rom, NULL, "imx31.rom",
|
||||
memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom",
|
||||
FSL_IMX31_ROM_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
@ -236,7 +236,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
|
||||
&s->iram);
|
||||
|
||||
/* internal RAM (16 KB) is aliased over 256 MB - 16 KB */
|
||||
memory_region_init_alias(&s->iram_alias, NULL, "imx31.iram_alias",
|
||||
memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx31.iram_alias",
|
||||
&s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE);
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR,
|
||||
&s->iram_alias);
|
||||
|
@ -405,7 +405,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
/* ROM memory */
|
||||
memory_region_init_rom(&s->rom, NULL, "imx6.rom",
|
||||
memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom",
|
||||
FSL_IMX6_ROM_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
@ -415,7 +415,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
|
||||
&s->rom);
|
||||
|
||||
/* CAAM memory */
|
||||
memory_region_init_rom(&s->caam, NULL, "imx6.caam",
|
||||
memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam",
|
||||
FSL_IMX6_CAAM_MEM_SIZE, &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
@ -435,7 +435,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
|
||||
&s->ocram);
|
||||
|
||||
/* internal OCRAM (256 KB) is aliased over 1 MB */
|
||||
memory_region_init_alias(&s->ocram_alias, NULL, "imx6.ocram_alias",
|
||||
memory_region_init_alias(&s->ocram_alias, OBJECT(dev), "imx6.ocram_alias",
|
||||
&s->ocram, 0, FSL_IMX6_OCRAM_ALIAS_SIZE);
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ALIAS_ADDR,
|
||||
&s->ocram_alias);
|
||||
|
@ -543,7 +543,7 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
|
||||
/*
|
||||
* ROM memory
|
||||
*/
|
||||
memory_region_init_rom(&s->rom, NULL, "imx6ul.rom",
|
||||
memory_region_init_rom(&s->rom, OBJECT(dev), "imx6ul.rom",
|
||||
FSL_IMX6UL_ROM_SIZE, &error_abort);
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_ROM_ADDR,
|
||||
&s->rom);
|
||||
@ -551,7 +551,7 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
|
||||
/*
|
||||
* CAAM memory
|
||||
*/
|
||||
memory_region_init_rom(&s->caam, NULL, "imx6ul.caam",
|
||||
memory_region_init_rom(&s->caam, OBJECT(dev), "imx6ul.caam",
|
||||
FSL_IMX6UL_CAAM_MEM_SIZE, &error_abort);
|
||||
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_CAAM_MEM_ADDR,
|
||||
&s->caam);
|
||||
@ -568,8 +568,9 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
|
||||
/*
|
||||
* internal OCRAM (128 KB) is aliased over 512 KB
|
||||
*/
|
||||
memory_region_init_alias(&s->ocram_alias, NULL, "imx6ul.ocram_alias",
|
||||
&s->ocram, 0, FSL_IMX6UL_OCRAM_ALIAS_SIZE);
|
||||
memory_region_init_alias(&s->ocram_alias, OBJECT(dev),
|
||||
"imx6ul.ocram_alias", &s->ocram, 0,
|
||||
FSL_IMX6UL_OCRAM_ALIAS_SIZE);
|
||||
memory_region_add_subregion(get_system_memory(),
|
||||
FSL_IMX6UL_OCRAM_ALIAS_ADDR, &s->ocram_alias);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
||||
|
||||
memory_region_init_rom(nvm, NULL, "MSF2.eNVM", s->envm_size,
|
||||
memory_region_init_rom(nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
|
||||
&error_fatal);
|
||||
/*
|
||||
* On power-on, the eNVM region 0x60000000 is automatically
|
||||
@ -104,8 +104,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
* start address (0x0). We do not support remapping other eNVM,
|
||||
* eSRAM and DDR regions by guest(via Sysreg) currently.
|
||||
*/
|
||||
memory_region_init_alias(nvm_alias, NULL, "MSF2.eNVM",
|
||||
nvm, 0, s->envm_size);
|
||||
memory_region_init_alias(nvm_alias, OBJECT(dev_soc), "MSF2.eNVM", nvm, 0,
|
||||
s->envm_size);
|
||||
|
||||
memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);
|
||||
memory_region_add_subregion(system_memory, 0, nvm_alias);
|
||||
|
@ -165,7 +165,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
}
|
||||
|
||||
/* STUB Peripherals */
|
||||
memory_region_init_io(&s->clock, NULL, &clock_ops, NULL,
|
||||
memory_region_init_io(&s->clock, OBJECT(dev_soc), &clock_ops, NULL,
|
||||
"nrf51_soc.clock", 0x1000);
|
||||
memory_region_add_subregion_overlap(&s->container,
|
||||
NRF51_IOMEM_BASE, &s->clock, -1);
|
||||
|
@ -93,10 +93,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
MemoryRegion *flash = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
|
||||
|
||||
memory_region_init_rom(flash, NULL, "STM32F205.flash", FLASH_SIZE,
|
||||
&error_fatal);
|
||||
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
|
||||
flash, 0, FLASH_SIZE);
|
||||
memory_region_init_rom(flash, OBJECT(dev_soc), "STM32F205.flash",
|
||||
FLASH_SIZE, &error_fatal);
|
||||
memory_region_init_alias(flash_alias, OBJECT(dev_soc),
|
||||
"STM32F205.flash.alias", flash, 0, FLASH_SIZE);
|
||||
|
||||
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
|
||||
memory_region_add_subregion(system_memory, 0, flash_alias);
|
||||
|
@ -95,14 +95,15 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
Error *err = NULL;
|
||||
int i;
|
||||
|
||||
memory_region_init_rom(&s->flash, NULL, "STM32F405.flash", FLASH_SIZE,
|
||||
&err);
|
||||
memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F405.flash",
|
||||
FLASH_SIZE, &err);
|
||||
if (err != NULL) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
memory_region_init_alias(&s->flash_alias, NULL, "STM32F405.flash.alias",
|
||||
&s->flash, 0, FLASH_SIZE);
|
||||
memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc),
|
||||
"STM32F405.flash.alias", &s->flash, 0,
|
||||
FLASH_SIZE);
|
||||
|
||||
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
|
||||
memory_region_add_subregion(system_memory, 0, &s->flash_alias);
|
||||
|
@ -318,9 +318,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
|
||||
ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
|
||||
ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
|
||||
|
||||
memory_region_init_alias(&s->ddr_ram_high, NULL,
|
||||
"ddr-ram-high", s->ddr_ram,
|
||||
ddr_low_size, ddr_high_size);
|
||||
memory_region_init_alias(&s->ddr_ram_high, OBJECT(dev),
|
||||
"ddr-ram-high", s->ddr_ram, ddr_low_size,
|
||||
ddr_high_size);
|
||||
memory_region_add_subregion(get_system_memory(),
|
||||
XLNX_ZYNQMP_HIGH_RAM_START,
|
||||
&s->ddr_ram_high);
|
||||
@ -330,9 +330,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
|
||||
ddr_low_size = ram_size;
|
||||
}
|
||||
|
||||
memory_region_init_alias(&s->ddr_ram_low, NULL,
|
||||
"ddr-ram-low", s->ddr_ram,
|
||||
0, ddr_low_size);
|
||||
memory_region_init_alias(&s->ddr_ram_low, OBJECT(dev), "ddr-ram-low",
|
||||
s->ddr_ram, 0, ddr_low_size);
|
||||
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
|
||||
|
||||
/* Create the four OCM banks */
|
||||
|
Loading…
Reference in New Issue
Block a user