hw/arm: Cleanups before pflash refactor
cover hw/arm: Cleanups before pflash refactor
Various trivial cleanups:
- Remove unnecessary sysmem argument from pxa2xx_init()
- Use IEC binary prefix definitions
- Remove unreachable code calling pflash_cfi01_register() (another use in PPC sam460ex will be removed separately).
Philippe Mathieu-Daudé (13):
hw/arm/pxa2xx: Simplify pxa255_init()
hw/arm/pxa2xx: Simplify pxa270_init()
hw/arm/collie: Use the IEC binary prefix definitions hw/arm/collie: Simplify flash creation using for() loop hw/arm/gumstix: Improve documentation
hw/arm/gumstix: Use the IEC binary prefix definitions hw/arm/mainstone: Use the IEC binary prefix definitions hw/arm/musicpal: Use the IEC binary prefix definitions hw/arm/omap_sx1: Remove unused 'total_ram' definitions hw/arm/omap_sx1: Use the IEC binary prefix definitions hw/arm/z2: Use the IEC binary prefix definitions hw/arm/vexpress: Remove dead code in vexpress_common_init() hw/arm: Remove unreachable code calling pflash_cfi01_register()
hw/arm/collie.c | 25 +++++++++++----------- hw/arm/gumstix.c | 45 +++++++++++++++++--------------------- hw/arm/mainstone.c | 37 +++++++++++++++----------------- hw/arm/musicpal.c | 9 +++++--- hw/arm/omap_sx1.c | 51 +++++++++++++++++++------------------------- hw/arm/pxa2xx.c | 8 ++++--- hw/arm/spitz.c | 6 ++---- hw/arm/tosa.c | 2 +- hw/arm/versatilepb.c | 6 ++---- hw/arm/vexpress.c | 10 +-------- hw/arm/z2.c | 16 ++++++-------- include/hw/arm/pxa.h | 5 ++--- 12 files changed, 98 insertions(+), 122 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/13 hw/arm/pxa2xx: Simplify pxa255_init()
Since pxa255_init() must map the device in the system memory, there is no point in passing get_system_memory() by argument.
--- hw/arm/gumstix.c | 3 +-- hw/arm/pxa2xx.c | 4 +++- hw/arm/tosa.c | 2 +- include/hw/arm/pxa.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
hw/arm/gumstix.c +1 -2
@@ -51,12 +51,11 @@ static void connex_init(MachineState *machine) {PXA2xxState *cpu;DriveInfo *dinfo; -MemoryRegion *address_space_mem =get_system_memory ();uint32_t connex_rom =0x01000000 ;uint32_t connex_ram =0x04000000 ; - cpu =pxa255_init (address_space_mem, connex_ram); + cpu =pxa255_init (connex_ram); dinfo =drive_get (IF_PFLASH ,0 ,0 );if (!dinfo && !qtest_enabled ()) {
hw/arm/pxa2xx.c +3 -1
@@ -11,6 +11,7 @@#include "qemu/error-report.h" #include "qemu/module.h" #include "qapi/error.h" +#include "exec/address-spaces.h" #include "cpu.h" #include "hw/sysbus.h" #include "migration/vmstate.h"
@@ -2230,8 +2231,9 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, }/* Initialise a PXA255 integrated chip (ARM based core). */ -PXA2xxState *pxa255_init (MemoryRegion *address_space,unsigned int sdram_size) +PXA2xxState *pxa255_init (unsigned int sdram_size) { +MemoryRegion *address_space =get_system_memory ();PXA2xxState *s;int i;DriveInfo *dinfo;
hw/arm/tosa.c +1 -1
@@ -242,7 +242,7 @@ static void tosa_init(MachineState *machine)TC6393xbState *tmio;DeviceState *scp0, *scp1; - mpu =pxa255_init (address_space_mem, tosa_binfo.ram_size); + mpu =pxa255_init (tosa_binfo.ram_size);memory_region_init_rom (rom,NULL ,"tosa.rom" ,TOSA_ROM , &error_fatal);memory_region_add_subregion (address_space_mem,0 , rom);
include/hw/arm/pxa.h +1 -1
@@ -195,6 +195,6 @@ struct PXA2xxI2SState {PXA2xxState *pxa270_init (MemoryRegion *address_space,unsigned int sdram_size,const char *revision); -PXA2xxState *pxa255_init (MemoryRegion *address_space,unsigned int sdram_size); +PXA2xxState *pxa255_init (unsigned int sdram_size);#endif /* PXA_H */
Signature · 1 line
2.38.1
PATCH 2/13 hw/arm/pxa2xx: Simplify pxa270_init()
In reply to Philippe Mathieu-DaudéSince pxa270_init() must map the device in the system memory, there is no point in passing get_system_memory() by argument.
--- hw/arm/gumstix.c | 3 +-- hw/arm/mainstone.c | 10 ++++------ hw/arm/pxa2xx.c | 4 ++-- hw/arm/spitz.c | 6 ++---- hw/arm/z2.c | 3 +-- include/hw/arm/pxa.h | 3 +-- 6 files changed, 11 insertions(+), 18 deletions(-)
hw/arm/gumstix.c +1 -2
@@ -80,12 +80,11 @@ static void verdex_init(MachineState *machine) {PXA2xxState *cpu;DriveInfo *dinfo; -MemoryRegion *address_space_mem =get_system_memory ();uint32_t verdex_rom =0x02000000 ;uint32_t verdex_ram =0x10000000 ; - cpu =pxa270_init (address_space_mem, verdex_ram, machine->cpu_type); + cpu =pxa270_init (verdex_ram, machine->cpu_type); dinfo =drive_get (IF_PFLASH ,0 ,0 );if (!dinfo && !qtest_enabled ()) {
hw/arm/mainstone.c +4 -6
@@ -108,8 +108,7 @@ static struct arm_boot_info mainstone_binfo = { .ram_size = 0x04000000, }; -static void mainstone_common_init (MemoryRegion *address_space_mem, -MachineState *machine, +static void mainstone_common_init (MachineState *machine,enum mainstone_model_e model,int arm_id) {uint32_t sector_len =256 *1024 ;
@@ -121,11 +120,10 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,MemoryRegion *rom =g_new (MemoryRegion,1 );/* Setup CPU & memory */ - mpu =pxa270_init (address_space_mem, mainstone_binfo.ram_size, - machine->cpu_type); + mpu =pxa270_init (mainstone_binfo.ram_size, machine->cpu_type);memory_region_init_rom (rom,NULL ,"mainstone.rom" ,MAINSTONE_ROM , &error_fatal); -memory_region_add_subregion (address_space_mem,0 , rom); +memory_region_add_subregion (get_system_memory (),0x00000000 , rom);/* There are two 32MiB flash devices on the board */ for (i =0 ; i <2 ; i ++) {
@@ -165,7 +163,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,static void mainstone_init (MachineState *machine) { -mainstone_common_init (get_system_memory (), machine, mainstone,0x196 ); +mainstone_common_init (machine, mainstone,0x196 ); }static void mainstone2_machine_init (MachineClass *mc)
hw/arm/pxa2xx.c +2 -2
@@ -2092,9 +2092,9 @@ static void pxa2xx_reset(void *opaque, int line, int level) }/* Initialise a PXA270 integrated chip (ARM based core). */ -PXA2xxState *pxa270_init (MemoryRegion *address_space, -unsigned int sdram_size,const char *cpu_type) +PXA2xxState *pxa270_init (unsigned int sdram_size,const char *cpu_type) { +MemoryRegion *address_space =get_system_memory ();PXA2xxState *s;int i;DriveInfo *dinfo;
hw/arm/spitz.c +2 -4
@@ -986,18 +986,16 @@ static void spitz_common_init(MachineState *machine)SpitzMachineState *sms =SPITZ_MACHINE (machine);enum spitz_model_e model = smc->model;PXA2xxState *mpu; -MemoryRegion *address_space_mem =get_system_memory ();MemoryRegion *rom =g_new (MemoryRegion,1 );/* Setup CPU & memory */ - mpu =pxa270_init (address_space_mem, spitz_binfo.ram_size, - machine->cpu_type); + mpu =pxa270_init (spitz_binfo.ram_size, machine->cpu_type); sms->mpu = mpu;sl_flash_register (mpu, (model == spitz) ?FLASH_128M :FLASH_1024M );memory_region_init_rom (rom,NULL ,"spitz.rom" ,SPITZ_ROM , &error_fatal); -memory_region_add_subregion (address_space_mem,0 , rom); +memory_region_add_subregion (get_system_memory (),0 , rom);/* Setup peripherals */ spitz_keyboard_register (mpu);
hw/arm/z2.c +1 -2
@@ -299,7 +299,6 @@ static const TypeInfo aer915_info = {static void z2_init (MachineState *machine) { -MemoryRegion *address_space_mem =get_system_memory ();uint32_t sector_len =0x10000 ;PXA2xxState *mpu;DriveInfo *dinfo;
@@ -308,7 +307,7 @@ static void z2_init(MachineState *machine)DeviceState *wm;/* Setup CPU & memory */ - mpu =pxa270_init (address_space_mem, z2_binfo.ram_size, machine->cpu_type); + mpu =pxa270_init (z2_binfo.ram_size, machine->cpu_type); dinfo =drive_get (IF_PFLASH ,0 ,0 ); if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
include/hw/arm/pxa.h +1 -2
@@ -193,8 +193,7 @@ struct PXA2xxI2SState {# define PA_FMT "0x%08lx" -PXA2xxState *pxa270_init (MemoryRegion *address_space,unsigned int sdram_size, -const char *revision); +PXA2xxState *pxa270_init (unsigned int sdram_size,const char *revision);PXA2xxState *pxa255_init (unsigned int sdram_size);#endif /* PXA_H */
Signature · 1 line
2.38.1
PATCH 3/13 hw/arm/collie: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
Add definitions for RAM / Flash / Flash blocksize.
--- hw/arm/collie.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
hw/arm/collie.c +10 -6
@@ -20,6 +20,10 @@#include "cpu.h" #include "qom/object.h" +#define RAM_SIZE (512 * MiB) +#define FLASH_SIZE (32 * MiB) +#define FLASH_SECTOR_SIZE (64 * KiB) +struct CollieMachineState {MachineState parent;
@@ -31,7 +35,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)static struct arm_boot_info collie_binfo = { .loader_start =SA_SDCS0 , - .ram_size =0x20000000 , + .ram_size =RAM_SIZE , };static void collie_init (MachineState *machine)
@@ -52,14 +56,14 @@ static void collie_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),SA_SDCS0 , machine->ram); dinfo =drive_get (IF_PFLASH ,0 ,0 ); -pflash_cfi01_register (SA_CS0 ,"collie.fl1" ,0x02000000 , +pflash_cfi01_register (SA_CS0 ,"collie.fl1" ,FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -64 * KiB,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); +FLASH_SECTOR_SIZE ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); dinfo =drive_get (IF_PFLASH ,0 ,1 ); -pflash_cfi01_register (SA_CS1 ,"collie.fl2" ,0x02000000 , +pflash_cfi01_register (SA_CS1 ,"collie.fl2" ,FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -64 * KiB,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); +FLASH_SECTOR_SIZE ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 );sysbus_create_simple ("scoop" ,0x40800000 ,NULL );
@@ -75,7 +79,7 @@ static void collie_machine_class_init(ObjectClass *oc, void *data) mc->init = collie_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type =ARM_CPU_TYPE_NAME ("sa1110" ); - mc->default_ram_size =0x20000000 ; + mc->default_ram_size =RAM_SIZE ; mc->default_ram_id ="strongarm.sdram" ; }
Signature · 1 line
2.38.1
PATCH 4/13 hw/arm/collie: Simplify flash creation using for() loop
In reply to Philippe Mathieu-Daudé--- hw/arm/collie.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
hw/arm/collie.c +7 -10
@@ -40,7 +40,6 @@ static struct arm_boot_info collie_binfo = {static void collie_init (MachineState *machine) { -DriveInfo *dinfo;MachineClass *mc =MACHINE_GET_CLASS (machine);CollieMachineState *cms =COLLIE_MACHINE (machine);
@@ -55,15 +54,13 @@ static void collie_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),SA_SDCS0 , machine->ram); - dinfo =drive_get (IF_PFLASH ,0 ,0 ); -pflash_cfi01_register (SA_CS0 ,"collie.fl1" ,FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); - - dinfo =drive_get (IF_PFLASH ,0 ,1 ); -pflash_cfi01_register (SA_CS1 ,"collie.fl2" ,FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); +for (unsigned i =0 ; i <2 ; i++) { +DriveInfo *dinfo =drive_get (IF_PFLASH ,0 , i); +pflash_cfi01_register (i ?SA_CS1 :SA_CS0 , + i ?"collie.fl2" :"collie.fl1" ,FLASH_SIZE , + dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , +FLASH_SECTOR_SIZE ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); + }sysbus_create_simple ("scoop" ,0x40800000 ,NULL );
Signature · 1 line
2.38.1
PATCH 5/13 hw/arm/gumstix: Improve documentation
In reply to Philippe Mathieu-DaudéFrom: Philippe Mathieu-Daudé <[email protected]>
Add a comment describing the Connex uses a Numonyx RC28F128J3F75 flash, and the Verdex uses a Micron RC28F256P30TFA.
Correct the Verdex machine description (we model the 'Pro' board).
Message-Id: <[email protected]>
--- hw/arm/gumstix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/gumstix.c +4 -2
@@ -10,7 +10,7 @@* Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ - +/* * Example usage: *
@@ -64,6 +64,7 @@ static void connex_init(MachineState *machine)exit (1 ); } +/* Numonyx RC28F128J3F75 */ if (!pflash_cfi01_register (0x00000000 ,"connext.rom" , connex_rom, dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , sector_len,2 ,0 ,0 ,0 ,0 ,0 )) {
@@ -93,6 +94,7 @@ static void verdex_init(MachineState *machine)exit (1 ); } +/* Micron RC28F256P30TFA */ if (!pflash_cfi01_register (0x00000000 ,"verdex.rom" , verdex_rom, dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , sector_len,2 ,0 ,0 ,0 ,0 ,0 )) {
@@ -124,7 +126,7 @@ static void verdex_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->desc ="Gumstix Verdex (PXA270)" ; + mc->desc ="Gumstix Verdex Pro XL6P COMs (PXA270)" ; mc->init = verdex_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type =ARM_CPU_TYPE_NAME ("pxa270-c0" );
Signature · 1 line
2.38.1
PATCH 6/13 hw/arm/gumstix: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéFrom: Philippe Mathieu-Daudé <[email protected]>
IEC binary prefixes ease code review: the unit is explicit.
Add definitions for RAM / Flash / Flash blocksize.
Message-Id: <[email protected]>
--- hw/arm/gumstix.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
hw/arm/gumstix.c +14 -13
@@ -35,6 +35,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qemu/error-report.h" #include "hw/arm/pxa.h" #include "net/net.h"
@@ -45,17 +46,20 @@#include "sysemu/qtest.h" #include "cpu.h" -static const int sector_len =128 *1024 ; +#define CONNEX_FLASH_SIZE (16 * MiB) +#define CONNEX_RAM_SIZE (64 * MiB) + +#define VERDEX_FLASH_SIZE (32 * MiB) +#define VERDEX_RAM_SIZE (256 * MiB) + +#define FLASH_SECTOR_SIZE (128 * KiB)static void connex_init (MachineState *machine) {PXA2xxState *cpu;DriveInfo *dinfo; -uint32_t connex_rom =0x01000000 ; -uint32_t connex_ram =0x04000000 ; - - cpu =pxa255_init (connex_ram); + cpu =pxa255_init (CONNEX_RAM_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 );if (!dinfo && !qtest_enabled ()) {
@@ -65,9 +69,9 @@ static void connex_init(MachineState *machine) }/* Numonyx RC28F128J3F75 */ -if (!pflash_cfi01_register (0x00000000 ,"connext.rom" , connex_rom, +if (!pflash_cfi01_register (0x00000000 ,"connext.rom" ,CONNEX_FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , - sector_len,2 ,0 ,0 ,0 ,0 ,0 )) { +FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 )) {error_report ("Error registering flash memory" );exit (1 ); }
@@ -82,10 +86,7 @@ static void verdex_init(MachineState *machine)PXA2xxState *cpu;DriveInfo *dinfo; -uint32_t verdex_rom =0x02000000 ; -uint32_t verdex_ram =0x10000000 ; - - cpu =pxa270_init (verdex_ram, machine->cpu_type); + cpu =pxa270_init (VERDEX_RAM_SIZE , machine->cpu_type); dinfo =drive_get (IF_PFLASH ,0 ,0 );if (!dinfo && !qtest_enabled ()) {
@@ -95,9 +96,9 @@ static void verdex_init(MachineState *machine) }/* Micron RC28F256P30TFA */ -if (!pflash_cfi01_register (0x00000000 ,"verdex.rom" , verdex_rom, +if (!pflash_cfi01_register (0x00000000 ,"verdex.rom" ,VERDEX_FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , - sector_len,2 ,0 ,0 ,0 ,0 ,0 )) { +FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 )) {error_report ("Error registering flash memory" );exit (1 ); }
Signature · 1 line
2.38.1
PATCH 7/13 hw/arm/mainstone: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
Add the FLASH_SECTOR_SIZE definition.
--- hw/arm/mainstone.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
hw/arm/mainstone.c +10 -8
@@ -12,6 +12,7 @@* GNU GPL, version 2 or (at your option) any later version. */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "hw/arm/pxa.h"
@@ -99,19 +100,20 @@ static const struct keymap map[0xE0] = {enum mainstone_model_e { mainstone }; -#define MAINSTONE_RAM 0x04000000 -#define MAINSTONE_ROM 0x00800000 -#define MAINSTONE_FLASH 0x02000000 +#define MAINSTONE_RAM_SIZE (64 * MiB) +#define MAINSTONE_ROM_SIZE (8 * MiB) +#define MAINSTONE_FLASH_SIZE (32 * MiB)static struct arm_boot_info mainstone_binfo = { .loader_start =PXA2XX_SDRAM_BASE , - .ram_size =0x04000000 , + .ram_size =MAINSTONE_RAM_SIZE , }; +#define FLASH_SECTOR_SIZE (256 * KiB) +static void mainstone_common_init (MachineState *machine,enum mainstone_model_e model,int arm_id) { -uint32_t sector_len =256 *1024 ;hwaddr mainstone_flash_base[] = {MST_FLASH_0 ,MST_FLASH_1 };PXA2xxState *mpu;DeviceState *mst_irq;
@@ -121,7 +123,7 @@ static void mainstone_common_init(MachineState *machine,/* Setup CPU & memory */ mpu =pxa270_init (mainstone_binfo.ram_size, machine->cpu_type); -memory_region_init_rom (rom,NULL ,"mainstone.rom" ,MAINSTONE_ROM , +memory_region_init_rom (rom,NULL ,"mainstone.rom" ,MAINSTONE_ROM_SIZE , &error_fatal);memory_region_add_subregion (get_system_memory (),0x00000000 , rom);
@@ -130,9 +132,9 @@ static void mainstone_common_init(MachineState *machine, dinfo =drive_get (IF_PFLASH ,0 , i);if (!pflash_cfi01_register (mainstone_flash_base[i], i ?"mainstone.flash1" :"mainstone.flash0" , -MAINSTONE_FLASH , +MAINSTONE_FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , - sector_len,4 ,0 ,0 ,0 ,0 ,0 )) { +FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) {error_report ("Error registering flash memory" );exit (1 ); }
Signature · 1 line
2.38.1
PATCH 8/13 hw/arm/musicpal: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
Add the FLASH_SECTOR_SIZE definition.
--- hw/arm/musicpal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/arm/musicpal.c +6 -3
@@ -10,6 +10,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" #include "hw/sysbus.h"
@@ -1196,6 +1197,8 @@ static const TypeInfo musicpal_key_info = { .class_init = musicpal_key_class_init, }; +#define FLASH_SECTOR_SIZE (64 * KiB) +static struct arm_boot_info musicpal_binfo = { .loader_start =0x0 , .board_id =0x20e ,
@@ -1264,8 +1267,8 @@ static void musicpal_init(MachineState *machine)BlockBackend *blk =blk_by_legacy_dinfo (dinfo); flash_size =blk_getlength (blk); -if (flash_size !=8 *1024 *1024 && flash_size !=16 *1024 *1024 && - flash_size !=32 *1024 *1024 ) { +if (flash_size !=8 * MiB && flash_size !=16 * MiB && + flash_size !=32 * MiB) {error_report ("Invalid flash image size" );exit (1 ); }
@@ -1277,7 +1280,7 @@ static void musicpal_init(MachineState *machine)*/ pflash_cfi02_register (0x100000000ULL -MP_FLASH_SIZE_MAX ,"musicpal.flash" , flash_size, - blk,0x10000 , + blk,FLASH_SECTOR_SIZE ,MP_FLASH_SIZE_MAX / flash_size,2 ,0x00BF ,0x236D ,0x0000 ,0x0000 ,0x5555 ,0x2AAA ,0 );
Signature · 1 line
2.38.1
PATCH 9/13 hw/arm/omap_sx1: Remove unused 'total_ram' definitions
In reply to Philippe Mathieu-DaudéThe total_ram_v1/total_ram_v2 definitions were never used.
--- hw/arm/omap_sx1.c | 2 -- 1 file changed, 2 deletions(-)
hw/arm/omap_sx1.c +0 -2
@@ -91,8 +91,6 @@ static const MemoryRegionOps static_ops = {#define flash0_size (16 * 1024 * 1024)#define flash1_size ( 8 * 1024 * 1024)#define flash2_size (32 * 1024 * 1024) -#define total_ram_v1 (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE) -#define total_ram_v2 (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)static struct arm_boot_info sx1_binfo = { .loader_start =OMAP_EMIFF_BASE ,
Signature · 1 line
2.38.1
PATCH 10/13 hw/arm/omap_sx1: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
--- hw/arm/omap_sx1.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
hw/arm/omap_sx1.c +17 -16
@@ -26,6 +26,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "ui/console.h" #include "hw/arm/omap.h"
@@ -86,15 +87,15 @@ static const MemoryRegionOps static_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -#define sdram_size 0x02000000 -#define sector_size (128 * 1024) -#define flash0_size (16 * 1024 * 1024) -#define flash1_size ( 8 * 1024 * 1024) -#define flash2_size (32 * 1024 * 1024) +#define SDRAM_SIZE (32 * MiB) +#define SECTOR_SIZE (128 * KiB) +#define FLASH0_SIZE (16 * MiB) +#define FLASH1_SIZE (8 * MiB) +#define FLASH2_SIZE (32 * MiB)static struct arm_boot_info sx1_binfo = { .loader_start =OMAP_EMIFF_BASE , - .ram_size = sdram_size, + .ram_size =SDRAM_SIZE , .board_id =0x265 , };
@@ -111,7 +112,7 @@ static void sx1_init(MachineState *machine, const int version)static uint32_t cs3val =0x00001139 ;DriveInfo *dinfo;int fl_idx; -uint32_t flash_size = flash0_size; +uint32_t flash_size =FLASH0_SIZE ;if (machine->ram_size != mc->default_ram_size) {char *sz =size_to_str (mc->default_ram_size);
@@ -121,7 +122,7 @@ static void sx1_init(MachineState *machine, const int version) }if (version ==2 ) { - flash_size = flash2_size; + flash_size =FLASH2_SIZE ; }memory_region_add_subregion (address_space,OMAP_EMIFF_BASE , machine->ram);
@@ -154,7 +155,7 @@ static void sx1_init(MachineState *machine, const int version)if (!pflash_cfi01_register (OMAP_CS0_BASE ,"omap_sx1.flash0-1" , flash_size,blk_by_legacy_dinfo (dinfo), - sector_size,4 ,0 ,0 ,0 ,0 ,0 )) { +SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) {fprintf (stderr,"qemu: Error registering flash memory %d.\n" , fl_idx); }
@@ -165,18 +166,18 @@ static void sx1_init(MachineState *machine, const int version) (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {MemoryRegion *flash_1 =g_new (MemoryRegion,1 );memory_region_init_rom (flash_1,NULL ,"omap_sx1.flash1-0" , - flash1_size, &error_fatal); +FLASH1_SIZE , &error_fatal);memory_region_add_subregion (address_space,OMAP_CS1_BASE , flash_1);memory_region_init_io (&cs[1 ],NULL , &static_ops, &cs1val, -"sx1.cs1" ,OMAP_CS1_SIZE - flash1_size); +"sx1.cs1" ,OMAP_CS1_SIZE -FLASH1_SIZE );memory_region_add_subregion (address_space, -OMAP_CS1_BASE + flash1_size, &cs[1 ]); +OMAP_CS1_BASE +FLASH1_SIZE , &cs[1 ]);if (!pflash_cfi01_register (OMAP_CS1_BASE , -"omap_sx1.flash1-1" , flash1_size, +"omap_sx1.flash1-1" ,FLASH1_SIZE ,blk_by_legacy_dinfo (dinfo), - sector_size,4 ,0 ,0 ,0 ,0 ,0 )) { +SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) {fprintf (stderr,"qemu: Error registering flash memory %d.\n" , fl_idx); }
@@ -218,7 +219,7 @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data) mc->init = sx1_init_v2; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type =ARM_CPU_TYPE_NAME ("ti925t" ); - mc->default_ram_size = sdram_size; + mc->default_ram_size =SDRAM_SIZE ; mc->default_ram_id ="omap1.dram" ; }
@@ -236,7 +237,7 @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data) mc->init = sx1_init_v1; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type =ARM_CPU_TYPE_NAME ("ti925t" ); - mc->default_ram_size = sdram_size; + mc->default_ram_size =SDRAM_SIZE ; mc->default_ram_id ="omap1.dram" ; }
Signature · 1 line
2.38.1
PATCH 11/13 hw/arm/z2: Use the IEC binary prefix definitions
In reply to Philippe Mathieu-DaudéIEC binary prefixes ease code review: the unit is explicit.
Add the FLASH_SECTOR_SIZE definition.
--- hw/arm/z2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/z2.c +4 -2
@@ -12,6 +12,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "hw/arm/pxa.h" #include "hw/arm/boot.h" #include "hw/i2c/i2c.h"
@@ -297,9 +298,10 @@ static const TypeInfo aer915_info = { .class_init = aer915_class_init, }; +#define FLASH_SECTOR_SIZE (64 * KiB) +static void z2_init (MachineState *machine) { -uint32_t sector_len =0x10000 ;PXA2xxState *mpu;DriveInfo *dinfo;void *z2_lcd;
@@ -312,7 +314,7 @@ static void z2_init(MachineState *machine) dinfo =drive_get (IF_PFLASH ,0 ,0 );if (!pflash_cfi01_register (Z2_FLASH_BASE ,"z2.flash0" ,Z2_FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , - sector_len,4 ,0 ,0 ,0 ,0 ,0 )) { +FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) {error_report ("Error registering flash memory" );exit (1 ); }
Signature · 1 line
2.38.1
PATCH 12/13 hw/arm/vexpress: Remove dead code in vexpress_common_init()
In reply to Philippe Mathieu-DaudéUpon introduction in commit b8433303fb ("Set proper device-width for vexpress flash"), ve_pflash_cfi01_register() was calling qdev_init_nofail() which can not fail. This call was later converted with a script to use &error_fatal, still unable to fail. Remove the unreachable code.
--- hw/arm/vexpress.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
hw/arm/vexpress.c +1 -9
@@ -659,10 +659,6 @@ static void vexpress_common_init(MachineState *machine) dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash0 =ve_pflash_cfi01_register (map[VE_NORFLASH0 ],"vexpress.flash0" , dinfo); -if (!pflash0) { -error_report ("vexpress: error registering flash 0" ); -exit (1 ); - }if (map[VE_NORFLASHALIAS ] !=-1 ) {/* Map flash 0 as an alias into low memory */
@@ -673,11 +669,7 @@ static void vexpress_common_init(MachineState *machine) } dinfo =drive_get (IF_PFLASH ,0 ,1 ); -if (!ve_pflash_cfi01_register (map[VE_NORFLASH1 ],"vexpress.flash1" , - dinfo)) { -error_report ("vexpress: error registering flash 1" ); -exit (1 ); - } +ve_pflash_cfi01_register (map[VE_NORFLASH1 ],"vexpress.flash1" , dinfo); sram_size =0x2000000 ; memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size,
Signature · 1 line
2.38.1
PATCH 13/13 hw/arm: Remove unreachable code calling pflash_cfi01_register()
In reply to Philippe Mathieu-DaudéSince its QOM'ification in commit 368a354f02 ("pflash_cfi0x:
QOMified") the pflash_cfi01_register() function does not fail.
This call was later converted with a script to use &error_fatal, still unable to fail. Remove the unreachable code.
--- hw/arm/gumstix.c | 18 ++++++------------ hw/arm/mainstone.c | 13 +++++-------- hw/arm/omap_sx1.c | 22 ++++++++-------------- hw/arm/versatilepb.c | 6 ++---- hw/arm/z2.c | 9 +++------ 5 files changed, 24 insertions(+), 44 deletions(-)
hw/arm/gumstix.c +6 -12
@@ -69,12 +69,9 @@ static void connex_init(MachineState *machine) }/* Numonyx RC28F128J3F75 */ -if (!pflash_cfi01_register (0x00000000 ,"connext.rom" ,CONNEX_FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 )) { -error_report ("Error registering flash memory" ); -exit (1 ); - } +pflash_cfi01_register (0x00000000 ,"connext.rom" ,CONNEX_FLASH_SIZE , + dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , +FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 );/* Interrupt line of NIC is connected to GPIO line 36 */ smc91c111_init(&nd_table[0], 0x04000300,
@@ -96,12 +93,9 @@ static void verdex_init(MachineState *machine) }/* Micron RC28F256P30TFA */ -if (!pflash_cfi01_register (0x00000000 ,"verdex.rom" ,VERDEX_FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 )) { -error_report ("Error registering flash memory" ); -exit (1 ); - } +pflash_cfi01_register (0x00000000 ,"verdex.rom" ,VERDEX_FLASH_SIZE , + dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , +FLASH_SECTOR_SIZE ,2 ,0 ,0 ,0 ,0 ,0 );/* Interrupt line of NIC is connected to GPIO line 99 */ smc91c111_init(&nd_table[0], 0x04000300,
hw/arm/mainstone.c +5 -8
@@ -130,14 +130,11 @@ static void mainstone_common_init(MachineState *machine,/* There are two 32MiB flash devices on the board */ for (i =0 ; i <2 ; i ++) { dinfo =drive_get (IF_PFLASH ,0 , i); -if (!pflash_cfi01_register (mainstone_flash_base[i], - i ?"mainstone.flash1" :"mainstone.flash0" , -MAINSTONE_FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) { -error_report ("Error registering flash memory" ); -exit (1 ); - } +pflash_cfi01_register (mainstone_flash_base[i], + i ?"mainstone.flash1" :"mainstone.flash0" , +MAINSTONE_FLASH_SIZE , + dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , +FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 ); } mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
hw/arm/omap_sx1.c +8 -14
@@ -152,13 +152,10 @@ static void sx1_init(MachineState *machine, const int version) fl_idx =0 ;if ((dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) { -if (!pflash_cfi01_register (OMAP_CS0_BASE , -"omap_sx1.flash0-1" , flash_size, -blk_by_legacy_dinfo (dinfo), -SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) { -fprintf (stderr,"qemu: Error registering flash memory %d.\n" , - fl_idx); - } +pflash_cfi01_register (OMAP_CS0_BASE , +"omap_sx1.flash0-1" , flash_size, +blk_by_legacy_dinfo (dinfo), +SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 ); fl_idx++; }
@@ -174,13 +171,10 @@ static void sx1_init(MachineState *machine, const int version)memory_region_add_subregion (address_space,OMAP_CS1_BASE +FLASH1_SIZE , &cs[1 ]); -if (!pflash_cfi01_register (OMAP_CS1_BASE , -"omap_sx1.flash1-1" ,FLASH1_SIZE , -blk_by_legacy_dinfo (dinfo), -SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) { -fprintf (stderr,"qemu: Error registering flash memory %d.\n" , - fl_idx); - } +pflash_cfi01_register (OMAP_CS1_BASE , +"omap_sx1.flash1-1" ,FLASH1_SIZE , +blk_by_legacy_dinfo (dinfo), +SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 ); fl_idx++; }else { memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
hw/arm/versatilepb.c +2 -4
@@ -385,13 +385,11 @@ static void versatile_init(MachineState *machine, int board_id)/* 0x34000000 NOR Flash */ dinfo =drive_get (IF_PFLASH ,0 ,0 ); -if (!pflash_cfi01_register (VERSATILE_FLASH_ADDR ,"versatile.flash" , +pflash_cfi01_register (VERSATILE_FLASH_ADDR ,"versatile.flash" ,VERSATILE_FLASH_SIZE , dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ,VERSATILE_FLASH_SECT_SIZE , -4 ,0x0089 ,0x0018 ,0x0000 ,0x0 ,0 )) { -fprintf (stderr,"qemu: Error registering flash memory.\n" ); - } +4 ,0x0089 ,0x0018 ,0x0000 ,0x0 ,0 ); versatile_binfo.ram_size = machine->ram_size; versatile_binfo.board_id = board_id;
hw/arm/z2.c +3 -6
@@ -312,12 +312,9 @@ static void z2_init(MachineState *machine) mpu =pxa270_init (z2_binfo.ram_size, machine->cpu_type); dinfo =drive_get (IF_PFLASH ,0 ,0 ); -if (!pflash_cfi01_register (Z2_FLASH_BASE ,"z2.flash0" ,Z2_FLASH_SIZE , - dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , -FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 )) { -error_report ("Error registering flash memory" ); -exit (1 ); - } +pflash_cfi01_register (Z2_FLASH_BASE ,"z2.flash0" ,Z2_FLASH_SIZE , + dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , +FLASH_SECTOR_SIZE ,4 ,0 ,0 ,0 ,0 ,0 );/* setup keypad */ pxa27x_register_keypad (mpu->kp, map,0x100 );
Signature · 1 line
2.38.1
Quoted 6 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (13):
hw/arm/pxa2xx: Simplifypxa255_init()hw/arm/pxa2xx: Simplifypxa270_init()hw/arm/collie: Use the IEC binary prefix definitions hw/arm/collie: Simplify flash creation usingfor()loop hw/arm/gumstix: Improve documentation
Quoted 8 lines
hw/arm/gumstix: Use the IEC binary prefix definitions hw/arm/mainstone: Use the IEC binary prefix definitions hw/arm/musicpal: Use the IEC binary prefix definitions hw/arm/omap_sx1: Remove unused '
total_ram' definitions hw/arm/omap_sx1: Use the IEC binary prefix definitions hw/arm/z2: Use the IEC binary prefix definitions hw/arm/vexpress: Remove dead code invexpress_common_init()hw/arm: Remove unreachable code callingpflash_cfi01_register()
r~
Peter Maydell
AppliedQuoted 7 lines · Philippe Mathieu-Daudé
Various trivial cleanups:
- Remove unnecessary sysmem argument frompxa2xx_init()
- Use IEC binary prefix definitions
- Remove unreachable code callingpflash_cfi01_register()(another use in PPC sam460ex will be removed separately).
Applied to target-arm.next, thanks.
-- PMM