hw/arm: Create the RAM in the board
Subsystems (2)
v2 cover hw/arm: Create the RAM in the board
Hi Peter,
This series contains the ARM patches extracted from the "Let the machine be the owner of the system memory" series [1] reviewed by Richard.
These are cleanups moving the creation of the system ram at the board level. The other series will enforce memory_region_allocate_system_memory() get called with a MachineState argument, this preliminary cleanup is required.
Regard,
Phil.
[1] https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg05085.html
Philippe Mathieu-Daudé (6):
hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board hw/arm/omap2: Create the RAM in the board hw/arm/omap1: Create the RAM in the board hw/arm/digic4: Inline digic4_board_setup_ram() function
hw/arm/collie.c | 8 ++++++-- hw/arm/digic_boards.c | 9 ++------- hw/arm/mps2-tz.c | 3 ++- hw/arm/mps2.c | 3 ++- hw/arm/nseries.c | 10 +++++++--- hw/arm/omap1.c | 12 +++++------- hw/arm/omap2.c | 13 +++++-------- hw/arm/omap_sx1.c | 8 ++++++-- hw/arm/palm.c | 8 ++++++-- hw/arm/strongarm.c | 7 +------ hw/arm/strongarm.h | 4 +--- hw/arm/xilinx_zynq.c | 3 ++- include/hw/arm/omap.h | 10 +++------- 13 files changed, 48 insertions(+), 50 deletions(-)
Signature · 1 line
2.21.0
PATCH v2 1/6 hw/arm/xilinx_zynq: Use the IEC binary prefix definitions
IEC binary prefixes ease code review: the unit is explicit.
--- hw/arm/xilinx_zynq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/xilinx_zynq.c +2 -1
@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" #include "hw/sysbus.h"
@@ -194,7 +195,7 @@ static void zynq_init(MachineState *machine)memory_region_add_subregion (address_space_mem,0 , ext_ram);/* 256K of on-chip memory */ -memory_region_init_ram (ocm_ram,NULL ,"zynq.ocm_ram" ,256 <<10 , +memory_region_init_ram (ocm_ram,NULL ,"zynq.ocm_ram" ,256 * KiB, &error_fatal);memory_region_add_subregion (address_space_mem,0xFFFC0000 , ocm_ram);
Signature · 1 line
2.21.0
PATCH v2 2/6 hw/arm/mps2: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
--- hw/arm/mps2-tz.c | 3 ++- hw/arm/mps2.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
hw/arm/mps2-tz.c +2 -1
@@ -38,6 +38,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h"
@@ -458,7 +459,7 @@ static void mps2tz_common_init(MachineState *machine)* call the 16MB our "system memory", as it's the largest lump. */ memory_region_allocate_system_memory (&mms->psram, -NULL ,"mps.ram" ,0x01000000 ); +NULL ,"mps.ram" ,16 * MiB);memory_region_add_subregion (system_memory,0x80000000 , &mms->psram);/* The overflow IRQs for all UARTs are ORed together.
hw/arm/mps2.c +2 -1
@@ -23,6 +23,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h"
@@ -146,7 +147,7 @@ static void mps2_common_init(MachineState *machine)* zbt_boot_ctrl is always zero). */ memory_region_allocate_system_memory (&mms->psram, -NULL ,"mps.ram" ,0x1000000 ); +NULL ,"mps.ram" ,16 * MiB);memory_region_add_subregion (system_memory,0x21000000 , &mms->psram);switch (mmc->fpga_type) {
Signature · 1 line
2.21.0
PATCH v2 3/6 hw/arm/collie: Create the RAM in the board
In reply to Philippe Mathieu-DaudéThe SDRAM is incorrectly created in the SA1110 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.
--- hw/arm/collie.c | 8 ++++++-- hw/arm/strongarm.c | 7 +------ hw/arm/strongarm.h | 4 +--- 3 files changed, 8 insertions(+), 11 deletions(-)
hw/arm/collie.c +6 -2
@@ -27,9 +27,13 @@ static void collie_init(MachineState *machine) {StrongARMState *s;DriveInfo *dinfo; -MemoryRegion *sysmem =get_system_memory (); +MemoryRegion *sdram =g_new (MemoryRegion,1 ); - s =sa1110_init (sysmem, collie_binfo.ram_size, machine->cpu_type); + s =sa1110_init (machine->cpu_type); + +memory_region_allocate_system_memory (sdram,NULL ,"strongarm.sdram" , + collie_binfo.ram_size); +memory_region_add_subregion (get_system_memory (),SA_SDCS0 , sdram); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
hw/arm/strongarm.c +1 -6
@@ -1586,8 +1586,7 @@ static const TypeInfo strongarm_ssp_info = { };/* Main CPU functions */ -StrongARMState *sa1110_init (MemoryRegion *sysmem, -unsigned int sdram_size,const char *cpu_type) +StrongARMState *sa1110_init (const char *cpu_type) {StrongARMState *s;int i;
@@ -1601,10 +1600,6 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem, s->cpu =ARM_CPU (cpu_create (cpu_type)); -memory_region_allocate_system_memory (&s->sdram,NULL ,"strongarm.sdram" , - sdram_size); -memory_region_add_subregion (sysmem,SA_SDCS0 , &s->sdram); - s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000, qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ), qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
hw/arm/strongarm.h +1 -3
@@ -55,7 +55,6 @@ enum { typedef struct { ARMCPU *cpu; - MemoryRegion sdram; DeviceState *pic; DeviceState *gpio; DeviceState *ppc;
@@ -63,7 +62,6 @@ typedef struct { SSIBus *ssp_bus; } StrongARMState; -StrongARMState *sa1110_init (MemoryRegion *sysmem, -unsigned int sdram_size,const char *rev); +StrongARMState *sa1110_init (const char *cpu_type);#endif
Signature · 1 line
2.21.0
PATCH v2 4/6 hw/arm/omap2: Create the RAM in the board
In reply to Philippe Mathieu-DaudéThe SDRAM is incorrectly created in the OMAP2420 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.
---
v2: Move MemoryRegion sdram to struct n800_s (Richard)
--- hw/arm/nseries.c | 10 +++++++--- hw/arm/omap2.c | 13 +++++-------- include/hw/arm/omap.h | 4 +--- 3 files changed, 13 insertions(+), 14 deletions(-)
hw/arm/nseries.c +7 -3
@@ -47,6 +47,7 @@/* Nokia N8x0 support */ struct n800_s { +MemoryRegion sdram;struct omap_mpu_state_s *mpu;struct rfbi_chip_s blizzard;
@@ -1311,11 +1312,14 @@ static int n810_atag_setup(const struct arm_boot_info *info, void *p)static void n8x0_init (MachineState *machine,struct arm_boot_info *binfo,int model) { -MemoryRegion *sysmem =get_system_memory ();struct n800_s *s = (struct n800_s *)g_malloc0 (sizeof (*s)); -int sdram_size = binfo->ram_size; +uint64_t sdram_size = binfo->ram_size; - s->mpu =omap2420_mpu_init (sysmem, sdram_size, machine->cpu_type); +memory_region_allocate_system_memory (&s->sdram,NULL ,"omap2.dram" , + sdram_size); +memory_region_add_subregion (get_system_memory (),OMAP2_Q2_BASE , &s->sdram); + + s->mpu =omap2420_mpu_init (&s->sdram, machine->cpu_type);/* Setup peripherals *
hw/arm/omap2.c +5 -8
@@ -22,6 +22,7 @@#include "qemu/error-report.h" #include "qapi/error.h" #include "cpu.h" +#include "exec/address-spaces.h" #include "sysemu/blockdev.h" #include "sysemu/qtest.h" #include "sysemu/reset.h"
@@ -2276,8 +2277,7 @@ static const struct dma_irq_map omap2_dma_irq_map[] = { { 0, OMAP_INT_24XX_SDMA_IRQ3 }, }; -struct omap_mpu_state_s *omap2420_mpu_init (MemoryRegion *sysmem, -unsigned long sdram_size, +struct omap_mpu_state_s *omap2420_mpu_init (MemoryRegion *sdram,const char *cpu_type) { struct omap_mpu_state_s *s = g_new0(struct omap_mpu_state_s, 1);
@@ -2286,11 +2286,11 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,int i;SysBusDevice *busdev;struct omap_target_agent_s *ta; +MemoryRegion *sysmem =get_system_memory ();/* Core */ s->mpu_model = omap2420; s->cpu =ARM_CPU (cpu_create (cpu_type)); - s->sdram_size = sdram_size; s->sram_size =OMAP242X_SRAM_SIZE ; s->wakeup =qemu_allocate_irq (omap_mpu_wakeup, s,0 );
@@ -2299,9 +2299,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,omap_clk_init (s);/* Memory-mapped stuff */ -memory_region_allocate_system_memory (&s->sdram,NULL ,"omap2.dram" , - s->sdram_size); -memory_region_add_subregion (sysmem,OMAP2_Q2_BASE , &s->sdram);memory_region_init_ram (&s->sram,NULL ,"omap2.sram" , s->sram_size, &error_fatal);memory_region_add_subregion (sysmem,OMAP2_SRAM_BASE , &s->sram);
@@ -2338,8 +2335,8 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem, s->port->addr_valid = omap2_validate_addr;/* Register SDRAM and SRAM ports for fast DMA transfers. */ -soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (&s->sdram), -OMAP2_Q2_BASE , s->sdram_size); +soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (sdram), +OMAP2_Q2_BASE ,memory_region_size (sdram));soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (&s->sram),OMAP2_SRAM_BASE , s->sram_size);
include/hw/arm/omap.h +1 -3
@@ -824,7 +824,6 @@ struct omap_mpu_state_s {MemoryRegion tap_iomem;MemoryRegion imif_ram;MemoryRegion emiff_ram; -MemoryRegion sdram;MemoryRegion sram;struct omap_dma_port_if_s {
@@ -938,8 +937,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, const char *core);/* omap2.c */ -struct omap_mpu_state_s *omap2420_mpu_init (MemoryRegion *sysmem, -unsigned long sdram_size, +struct omap_mpu_state_s *omap2420_mpu_init (MemoryRegion *sdram,const char *core);uint32_t omap_badwidth_read8 (void *opaque,hwaddr addr);
Signature · 1 line
2.21.0
PATCH v2 5/6 hw/arm/omap1: Create the RAM in the board
In reply to Philippe Mathieu-DaudéThe SDRAM is incorrectly created in the OMAP310 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.
--- hw/arm/omap1.c | 12 +++++------- hw/arm/omap_sx1.c | 8 ++++++-- hw/arm/palm.c | 8 ++++++-- include/hw/arm/omap.h | 6 ++---- 4 files changed, 19 insertions(+), 15 deletions(-)
hw/arm/omap1.c +5 -7
@@ -23,6 +23,7 @@#include "qapi/error.h" #include "qemu-common.h" #include "cpu.h" +#include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/hw.h" #include "hw/irq.h"
@@ -3858,8 +3859,7 @@ static int omap_validate_tipb_mpui_addr(struct omap_mpu_state_s *s,return range_covers_byte (0xe1010000 ,0xe1020004 -0xe1010000 , addr); } -struct omap_mpu_state_s *omap310_mpu_init (MemoryRegion *system_memory, -unsigned long sdram_size, +struct omap_mpu_state_s *omap310_mpu_init (MemoryRegion *dram,const char *cpu_type) {int i;
@@ -3867,11 +3867,12 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,qemu_irq dma_irqs[6 ];DriveInfo *dinfo;SysBusDevice *busdev; +MemoryRegion *system_memory =get_system_memory ();/* Core */ s->mpu_model = omap310; s->cpu =ARM_CPU (cpu_create (cpu_type)); - s->sdram_size = sdram_size; + s->sdram_size =memory_region_size (dram); s->sram_size =OMAP15XX_SRAM_SIZE ; s->wakeup =qemu_allocate_irq (omap_mpu_wakeup, s,0 );
@@ -3880,9 +3881,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,omap_clk_init (s);/* Memory-mapped stuff */ -memory_region_allocate_system_memory (&s->emiff_ram,NULL ,"omap1.dram" , - s->sdram_size); -memory_region_add_subregion (system_memory,OMAP_EMIFF_BASE , &s->emiff_ram);memory_region_init_ram (&s->imif_ram,NULL ,"omap1.sram" , s->sram_size, &error_fatal);memory_region_add_subregion (system_memory,OMAP_IMIF_BASE , &s->imif_ram);
@@ -3925,7 +3923,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory, s->port[tipb_mpui].addr_valid = omap_validate_tipb_mpui_addr;/* Register SDRAM and SRAM DMA ports for fast transfers. */ -soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (&s->emiff_ram), +soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (dram),OMAP_EMIFF_BASE , s->sdram_size);soc_dma_port_add_mem (s->dma,memory_region_get_ram_ptr (&s->imif_ram),OMAP_IMIF_BASE , s->sram_size);
hw/arm/omap_sx1.c +6 -2
@@ -103,6 +103,7 @@ static void sx1_init(MachineState *machine, const int version) {struct omap_mpu_state_s *mpu;MemoryRegion *address_space =get_system_memory (); +MemoryRegion *dram =g_new (MemoryRegion,1 );MemoryRegion *flash =g_new (MemoryRegion,1 );MemoryRegion *cs =g_new (MemoryRegion,4 );static uint32_t cs0val =0x00213090 ;
@@ -118,8 +119,11 @@ static void sx1_init(MachineState *machine, const int version) flash_size = flash2_size; } - mpu =omap310_mpu_init (address_space, sx1_binfo.ram_size, - machine->cpu_type); +memory_region_allocate_system_memory (dram,NULL ,"omap1.dram" , + sx1_binfo.ram_size); +memory_region_add_subregion (address_space,OMAP_EMIFF_BASE , dram); + + mpu =omap310_mpu_init (dram, machine->cpu_type);/* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
hw/arm/palm.c +6 -2
@@ -190,16 +190,20 @@ static void palmte_init(MachineState *machine)MemoryRegion *address_space_mem =get_system_memory ();struct omap_mpu_state_s *mpu;int flash_size =0x00800000 ; -int sdram_size = palmte_binfo.ram_size;static uint32_t cs0val =0xffffffff ;static uint32_t cs1val =0x0000e1a0 ;static uint32_t cs2val =0x0000e1a0 ;static uint32_t cs3val =0xe1a0e1a0 ;int rom_size, rom_loaded =0 ; +MemoryRegion *dram =g_new (MemoryRegion,1 );MemoryRegion *flash =g_new (MemoryRegion,1 );MemoryRegion *cs =g_new (MemoryRegion,4 ); - mpu =omap310_mpu_init (address_space_mem, sdram_size, machine->cpu_type); +memory_region_allocate_system_memory (dram,NULL ,"omap1.dram" , + palmte_binfo.ram_size); +memory_region_add_subregion (address_space_mem,OMAP_EMIFF_BASE , dram); + + mpu =omap310_mpu_init (dram, machine->cpu_type);/* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
include/hw/arm/omap.h +2 -4
@@ -823,7 +823,6 @@ struct omap_mpu_state_s {MemoryRegion mpui_io_iomem;MemoryRegion tap_iomem;MemoryRegion imif_ram; -MemoryRegion emiff_ram;MemoryRegion sram;struct omap_dma_port_if_s {
@@ -835,7 +834,7 @@ struct omap_mpu_state_s { hwaddr addr); } port[__omap_dma_port_last]; -unsigned long sdram_size; +uint64_t sdram_size;unsigned long sram_size;/* MPUI-TIPB peripherals */
@@ -932,8 +931,7 @@ struct omap_mpu_state_s { };/* omap1.c */ -struct omap_mpu_state_s *omap310_mpu_init (MemoryRegion *system_memory, -unsigned long sdram_size, +struct omap_mpu_state_s *omap310_mpu_init (MemoryRegion *sdram,const char *core);/* omap2.c */
Signature · 1 line
2.21.0
PATCH v2 6/6 hw/arm/digic4: Inline digic4_board_setup_ram() function
In reply to Philippe Mathieu-DaudéHaving the RAM creation code in a separate function is not very helpful. Move this code directly inside the board_init() function, this will later allow the board to have the QOM ownership of the RAM.
--- hw/arm/digic_boards.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
hw/arm/digic_boards.c +2 -7
@@ -53,12 +53,6 @@ typedef struct DigicBoard {const char *rom1_def_filename; } DigicBoard; -static void digic4_board_setup_ram (DigicBoardState *s,hwaddr ram_size) -{ -memory_region_allocate_system_memory (&s->ram,NULL ,"ram" , ram_size); -memory_region_add_subregion (get_system_memory (),0 , &s->ram); -} -static void digic4_board_init (DigicBoard *board) {Error *err =NULL ;
@@ -72,7 +66,8 @@ static void digic4_board_init(DigicBoard *board)exit (1 ); } -digic4_board_setup_ram (s, board->ram_size); +memory_region_allocate_system_memory (&s->ram,NULL ,"ram" , board->ram_size); +memory_region_add_subregion (get_system_memory (),0 , &s->ram);if (board->add_rom0) { board->add_rom0 (s,DIGIC4_ROM0_BASE , board->rom0_def_filename);
Signature · 1 line
2.21.0
Quoted 11 lines · Philippe Mathieu-Daudé
Hi Peter,
This series contains the ARM patches extracted from the "Let the machine be the owner of the system memory" series [1] reviewed by Richard.
These are cleanups moving the creation of the system ram at the board level. The other series will enforce
memory_region_allocate_system_memory()get called with a MachineState argument, this preliminary cleanup is required.
For the whole series:
Alistair
Quoted 34 lines
Regard,
Phil.
[1] https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg05085.html
Philippe Mathieu-Daudé (6):
hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board hw/arm/omap2: Create the RAM in the board hw/arm/omap1: Create the RAM in the board hw/arm/digic4: Inlinedigic4_board_setup_ram()functionhw/arm/collie.c | 8 ++++++-- hw/arm/digic_boards.c | 9 ++------- hw/arm/mps2-tz.c | 3 ++- hw/arm/mps2.c | 3 ++- hw/arm/nseries.c | 10 +++++++--- hw/arm/omap1.c | 12 +++++------- hw/arm/omap2.c | 13 +++++-------- hw/arm/omap_sx1.c | 8 ++++++-- hw/arm/palm.c | 8 ++++++-- hw/arm/strongarm.c | 7 +------ hw/arm/strongarm.h | 4 +--- hw/arm/xilinx_zynq.c | 3 ++- include/hw/arm/omap.h | 10 +++------- 13 files changed, 48 insertions(+), 50 deletions(-)--
2.21.0
Peter Maydell
AppliedQuoted 18 lines · Philippe Mathieu-Daudé
Hi Peter,
This series contains the ARM patches extracted from the "Let the machine be the owner of the system memory" series [1] reviewed by Richard.
These are cleanups moving the creation of the system ram at the board level. The other series will enforce
memory_region_allocate_system_memory()get called with a MachineState argument, this preliminary cleanup is required.Regard,
Phil.
[1] https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg05085.html
Quoted 7 lines
Philippe Mathieu-Daudé (6):
hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board hw/arm/omap2: Create the RAM in the board hw/arm/omap1: Create the RAM in the board hw/arm/digic4: Inlinedigic4_board_setup_ram()function
Applied to target-arm.next, thanks.
-- PMM