[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 44/51] hw/arm/msf2_soc: Don't allocate separate MemoryRegions
From: |
Peter Maydell |
Subject: |
[PULL 44/51] hw/arm/msf2_soc: Don't allocate separate MemoryRegions |
Date: |
Wed, 1 Sep 2021 11:36:46 +0100 |
In the realize method of the msf2-soc SoC object, we call g_new() to
create new MemoryRegion objects for the nvm, nvm_alias, and sram.
This is unnecessary; make these MemoryRegions member fields of the
device state struct instead.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alexandre Iooss <erdnaxe@crans.org>
Message-id: 20210812093356.1946-19-peter.maydell@linaro.org
---
include/hw/arm/msf2-soc.h | 4 ++++
hw/arm/msf2-soc.c | 17 +++++++----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
index d4061846855..38e10ce20aa 100644
--- a/include/hw/arm/msf2-soc.h
+++ b/include/hw/arm/msf2-soc.h
@@ -65,6 +65,10 @@ struct MSF2State {
MSSTimerState timer;
MSSSpiState spi[MSF2_NUM_SPIS];
MSF2EmacState emac;
+
+ MemoryRegion nvm;
+ MemoryRegion nvm_alias;
+ MemoryRegion sram;
};
#endif
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 5cfe7caf834..f36788054b3 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -83,11 +83,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error
**errp)
int i;
MemoryRegion *system_memory = get_system_memory();
- MemoryRegion *nvm = g_new(MemoryRegion, 1);
- MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);
- MemoryRegion *sram = g_new(MemoryRegion, 1);
- memory_region_init_rom(nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
+ memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
&error_fatal);
/*
* On power-on, the eNVM region 0x60000000 is automatically
@@ -95,15 +92,15 @@ 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, OBJECT(dev_soc), "MSF2.eNVM", nvm, 0,
- s->envm_size);
+ memory_region_init_alias(&s->nvm_alias, OBJECT(dev_soc), "MSF2.eNVM",
+ &s->nvm, 0, s->envm_size);
- memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);
- memory_region_add_subregion(system_memory, 0, nvm_alias);
+ memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, &s->nvm);
+ memory_region_add_subregion(system_memory, 0, &s->nvm_alias);
- memory_region_init_ram(sram, NULL, "MSF2.eSRAM", s->esram_size,
+ memory_region_init_ram(&s->sram, NULL, "MSF2.eSRAM", s->esram_size,
&error_fatal);
- memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
+ memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram);
armv7m = DEVICE(&s->armv7m);
qdev_prop_set_uint32(armv7m, "num-irq", 81);
--
2.20.1
- [PULL 41/51] hw/arm/nrf51: Wire up sysclk, (continued)
- [PULL 41/51] hw/arm/nrf51: Wire up sysclk, Peter Maydell, 2021/09/01
- [PULL 48/51] hw/arm/stellaris: Fix code style issues in GPTM code, Peter Maydell, 2021/09/01
- [PULL 46/51] hw/arm/msf2-soc: Wire up refclk, Peter Maydell, 2021/09/01
- [PULL 23/51] target/arm: Enable MVE in Cortex-M55, Peter Maydell, 2021/09/01
- [PULL 25/51] hw/arm/virt: target-arm: Add A64FX processor support to virt machine, Peter Maydell, 2021/09/01
- [PULL 28/51] arm: Move systick device creation from NVIC to ARMv7M object, Peter Maydell, 2021/09/01
- [PULL 29/51] arm: Move system PPB container handling to armv7m, Peter Maydell, 2021/09/01
- [PULL 40/51] hw/arm/stm32vldiscovery: Delete trailing blank line, Peter Maydell, 2021/09/01
- [PULL 47/51] hw/timer/armv7m_systick: Use clock inputs instead of system_clock_scale, Peter Maydell, 2021/09/01
- [PULL 38/51] hw/arm/stm32f205: Wire up sysclk and refclk, Peter Maydell, 2021/09/01
- [PULL 44/51] hw/arm/msf2_soc: Don't allocate separate MemoryRegions,
Peter Maydell <=
- [PULL 51/51] arm: Remove system_clock_scale global, Peter Maydell, 2021/09/01
- [PULL 26/51] tests/arm-cpu-features: Add A64FX processor related tests, Peter Maydell, 2021/09/01
- [PULL 32/51] hw/arm/armv7m: Create input clocks, Peter Maydell, 2021/09/01
- [PULL 42/51] hw/arm/stellaris: split stellaris_sys_init(), Peter Maydell, 2021/09/01
- [PULL 49/51] hw/arm/stellaris: Split stellaris-gptm into its own file, Peter Maydell, 2021/09/01
- [PULL 50/51] hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scale, Peter Maydell, 2021/09/01
- Re: [PULL 00/51] target-arm queue, Peter Maydell, 2021/09/02