hw/arm: Store the ARM boot info in the machine state
Subsystems (4)
cover hw/arm: Store the ARM boot info in the machine state
Most ARM board files declare their struct arm_boot_info as a static object at file scope (or, occasionally, as a function-local static inside the machine init function). arm_load_kernel() stashes a pointer to that struct in every CPU and dereferences it from do_cpu_reset() on each reset, so the boot info conceptually belongs to the machine for the lifetime of the VM, not to a static object whose ownership is left implicit.
This is a longstanding leftover pattern: modern machines such as virt, raspi and xlnx-zcu102 already keep the boot info in their MachineState subclass. This series converts the remaining machines that still use a static object, moving the struct into their machine state so that its lifetime and ownership match how arm_load_kernel() actually uses it.
Bin Meng (20):
hw/arm: aspeed: Store boot info in the machine state hw/arm: aspeed_ast27x0-fc: Store boot info in the machine state hw/arm: bananapi_m2u: Store boot info in the machine state hw/arm: collie: Store boot info in the machine state hw/arm: cubieboard: Store boot info in the machine state hw/arm: exynos4_boards: Store boot info in the board state hw/arm: imx25_pdk: Store boot info in the board state hw/arm: imx8mm-evk: Store boot info in the machine state hw/arm: integratorcp: Store boot info in the machine state hw/arm: kzm: Store boot info in the board state hw/arm: mcimx7d-sabre: Store boot info in the machine state hw/arm: musicpal: Store boot info in the machine state hw/arm: npcm7xx: Store boot info in the machine state hw/arm: npcm8xx: Store boot info in the machine state hw/arm: omap_sx1: Store boot info in the machine state hw/arm: orangepi: Store boot info in the machine state hw/arm: realview: Store boot info in the machine state hw/arm: sabrelite: Store boot info in the machine state hw/arm: versatilepb: Store boot info in the machine state hw/arm: xilinx_zynq: Store boot info in the machine state
hw/arm/aspeed.c | 17 +++++++-------- hw/arm/aspeed_ast27x0-fc.c | 13 ++++++------ hw/arm/bananapi_m2u.c | 37 ++++++++++++++++++++++++++------- hw/arm/collie.c | 14 ++++++------- hw/arm/cubieboard.c | 38 +++++++++++++++++++++++++++------- hw/arm/exynos4_boards.c | 26 +++++++++++------------ hw/arm/imx25_pdk.c | 11 +++++----- hw/arm/imx8mm-evk.c | 34 +++++++++++++++++++++++++----- hw/arm/integratorcp.c | 40 +++++++++++++++++++++++++++++------- hw/arm/kzm.c | 14 ++++++------- hw/arm/mcimx7d-sabre.c | 36 +++++++++++++++++++++++++++----- hw/arm/musicpal.c | 32 ++++++++++++++++++++++------- hw/arm/npcm7xx.c | 28 ++++++++++++------------- hw/arm/npcm7xx_boards.c | 15 +++++++++----- hw/arm/npcm8xx.c | 30 +++++++++++++-------------- hw/arm/npcm8xx_boards.c | 3 ++- hw/arm/omap_sx1.c | 21 +++++++++++++------ hw/arm/orangepi.c | 37 ++++++++++++++++++++++++++------- hw/arm/realview.c | 30 +++++++++++++++++++-------- hw/arm/sabrelite.c | 24 +++++++++++----------- hw/arm/versatilepb.c | 16 +++++++++++---- hw/arm/xilinx_zynq.c | 17 ++++++++------- include/hw/arm/aspeed.h | 2 ++ include/hw/arm/npcm7xx.h | 10 +++++++-- include/hw/arm/npcm8xx.h | 10 +++++++-- include/hw/arm/xilinx_zynq.h | 2 ++ 26 files changed, 382 insertions(+), 175 deletions(-)
---
base-commit: 539bc315538afe036a4b99088659aa82e3b489f2
branch: cleanup-arm-static-boot-info
Signature · 1 line
2.53.0
PATCH 1/20 hw/arm: aspeed: Store boot info in the machine state
arm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move the boot info into the existing AspeedMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/aspeed.c | 17 +++++++---------- include/hw/arm/aspeed.h | 2 ++ 2 files changed, 9 insertions(+), 10 deletions(-)
hw/arm/aspeed.c +7 -10
@@ -24,10 +24,6 @@#include "hw/core/qdev-clock.h" #include "system/system.h" -static struct arm_boot_info aspeed_board_binfo = { - .board_id =-1 ,/* device-tree-only board */ -}; -#define AST_SMP_MAILBOX_BASE 0x1e6e2180#define AST_SMP_MBOX_FIELD_ENTRY (AST_SMP_MAILBOX_BASE + 0x0)#define AST_SMP_MBOX_FIELD_GOSIGN (AST_SMP_MAILBOX_BASE + 0x4)
@@ -206,13 +202,14 @@ static void aspeed_machine_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),AST_SMP_MAILBOX_BASE , smpboot); - aspeed_board_binfo.write_secondary_boot = aspeed_write_smpboot; - aspeed_board_binfo.secondary_cpu_reset_hook = aspeed_reset_secondary; - aspeed_board_binfo.smp_loader_start =AST_SMP_MBOX_CODE ; + bmc->bootinfo.write_secondary_boot = aspeed_write_smpboot; + bmc->bootinfo.secondary_cpu_reset_hook = aspeed_reset_secondary; + bmc->bootinfo.smp_loader_start =AST_SMP_MBOX_CODE ; } - aspeed_board_binfo.ram_size = machine->ram_size; - aspeed_board_binfo.loader_start = sc->memmap[ASPEED_DEV_SDRAM ]; + bmc->bootinfo.board_id =-1 ;/* device-tree-only board */ + bmc->bootinfo.ram_size = machine->ram_size; + bmc->bootinfo.loader_start = sc->memmap[ASPEED_DEV_SDRAM ];if (amc->i2c_init) { amc->i2c_init (bmc);
@@ -248,7 +245,7 @@ static void aspeed_machine_init(MachineState *machine)aspeed_load_vbootrom (bmc->soc, bios_name, &error_abort); } -arm_load_kernel (ARM_CPU (first_cpu), machine, &aspeed_board_binfo); +arm_load_kernel (ARM_CPU (first_cpu), machine, &bmc->bootinfo); }void aspeed_create_pca9552 (AspeedSoCState *soc,int bus_id,int addr)
include/hw/arm/aspeed.h +2 -0
@@ -12,6 +12,7 @@#include "hw/core/boards.h" #include "qom/object.h" #include "hw/arm/aspeed_soc.h" +#include "hw/arm/boot.h" typedef struct AspeedMachineState AspeedMachineState ;
@@ -42,6 +43,7 @@ struct AspeedMachineState {char *fmc_model;char *spi_model;uint32_t hw_strap1; +struct arm_boot_info bootinfo; };struct AspeedMachineClass {
Signature · 1 line
2.53.0
PATCH 2/20 hw/arm: aspeed_ast27x0-fc: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move the boot info into the existing Ast2700FCState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/aspeed_ast27x0-fc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/arm/aspeed_ast27x0-fc.c +6 -7
@@ -27,10 +27,6 @@#define TYPE_AST2700FC MACHINE_TYPE_NAME("ast2700fc")OBJECT_DECLARE_SIMPLE_TYPE (Ast2700FCState,AST2700FC ); -static struct arm_boot_info ast2700fc_board_info = { - .board_id =-1 ,/* device-tree-only board */ -}; -struct Ast2700FCState {MachineState parent_obj;
@@ -46,6 +42,8 @@ struct Ast2700FCState {Aspeed27x0SoCState ca35;Aspeed27x0CoprocessorState ssp;Aspeed27x0CoprocessorState tsp; + +struct arm_boot_info bootinfo; };#define AST2700FC_BMC_RAM_SIZE (2 * GiB)
@@ -114,8 +112,9 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)aspeed_board_init_flashes (&soc->fmc,AST2700FC_FMC_MODEL ,2 ,0 );aspeed_board_init_flashes (&soc->spi[0 ],AST2700FC_SPI_MODEL ,1 ,2 ); - ast2700fc_board_info.ram_size = machine->ram_size; - ast2700fc_board_info.loader_start = sc->memmap[ASPEED_DEV_SDRAM ]; + s->bootinfo.ram_size = machine->ram_size; + s->bootinfo.loader_start = sc->memmap[ASPEED_DEV_SDRAM ]; + s->bootinfo.board_id =-1 ;/* device-tree-only board */ dev =ssi_get_cs (soc->fmc.spi,0 ); fmc0 = dev ?m25p80_get_blk (dev) :NULL ;
@@ -129,7 +128,7 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp) bios_name = machine->firmware ?:VBOOTROM_FILE_NAME ;aspeed_load_vbootrom (soc, bios_name, errp); -arm_load_kernel (ARM_CPU (first_cpu), machine, &ast2700fc_board_info); +arm_load_kernel (ARM_CPU (first_cpu), machine, &s->bootinfo);return true; }
Signature · 1 line
2.53.0
PATCH 3/20 hw/arm: bananapi_m2u: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move it into a new Bpim2uMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/bananapi_m2u.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
hw/arm/bananapi_m2u.c +30 -7
@@ -29,7 +29,14 @@#include "hw/arm/boot.h" #include "hw/arm/machines-qom.h" -static struct arm_boot_info bpim2u_binfo; +#define TYPE_BPIM2U_MACHINE MACHINE_TYPE_NAME("bpim2u") +OBJECT_DECLARE_SIMPLE_TYPE(Bpim2uMachineState, BPIM2U_MACHINE) + +struct Bpim2uMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +};/* * R40 can boot from mmc0 and mmc2, and bpim2u has two mmc interface, one is
@@ -62,6 +69,7 @@ static void mmc_attach_drive(AwR40State *s, AwSdHostState *mmc, int unit,static void bpim2u_init (MachineState *machine) { +Bpim2uMachineState *bpms =BPIM2U_MACHINE (machine);bool bootroom_loaded = false;AwR40State *r40;I2CBus *i2c;
@@ -120,14 +128,16 @@ static void bpim2u_init(MachineState *machine)memory_region_add_subregion (get_system_memory (), r40->memmap[AW_R40_DEV_SDRAM ], machine->ram); - bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM ]; - bpim2u_binfo.ram_size = machine->ram_size; - bpim2u_binfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; -arm_load_kernel (&r40->cpus[0 ], machine, &bpim2u_binfo); + bpms->bootinfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM ]; + bpms->bootinfo.ram_size = machine->ram_size; + bpms->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; +arm_load_kernel (&r40->cpus[0 ], machine, &bpms->bootinfo); } -static void bpim2u_machine_init (MachineClass *mc) +static void bpim2u_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); +static const char *const valid_cpu_types[] = {ARM_CPU_TYPE_NAME ("cortex-a7" ),NULL
@@ -145,4 +155,17 @@ static void bpim2u_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("bpim2u" , bpim2u_machine_init) +static const TypeInfo bpim2u_machine_typeinfo = { + .name =TYPE_BPIM2U_MACHINE , + .parent =TYPE_MACHINE , + .class_init = bpim2u_machine_class_init, + .instance_size =sizeof (Bpim2uMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void bpim2u_machine_register_types (void ) +{ +type_register_static (&bpim2u_machine_typeinfo); +} + +type_init (bpim2u_machine_register_types)
Signature · 1 line
2.53.0
PATCH 4/20 hw/arm: collie: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move the boot info into the existing CollieMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/collie.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/arm/collie.c +7 -7
@@ -30,16 +30,12 @@ struct CollieMachineState {MachineState parent;StrongARMState *sa1110; +struct arm_boot_info bootinfo; };#define TYPE_COLLIE_MACHINE MACHINE_TYPE_NAME("collie") OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE) -static struct arm_boot_info collie_binfo = { - .loader_start =SA_SDCS0 , - .ram_size =RAM_SIZE , -}; -static void collie_init (MachineState *machine) {MachineClass *mc =MACHINE_GET_CLASS (machine);
@@ -66,8 +62,12 @@ static void collie_init(MachineState *machine)sysbus_create_simple ("scoop" ,0x40800000 ,NULL ); - collie_binfo.board_id =0x208 ; -arm_load_kernel (cms->sa1110->cpu, machine, &collie_binfo); + cms->bootinfo = (struct arm_boot_info ) { + .loader_start =SA_SDCS0 , + .ram_size =RAM_SIZE , + .board_id =0x208 , + }; +arm_load_kernel (cms->sa1110->cpu, machine, &cms->bootinfo); }static void collie_machine_class_init (ObjectClass *oc,const void *data)
Signature · 1 line
2.53.0
PATCH 5/20 hw/arm: cubieboard: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move it into a new CubieboardMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/cubieboard.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-)
hw/arm/cubieboard.c +31 -7
@@ -25,13 +25,18 @@#include "hw/arm/machines-qom.h" #include "hw/i2c/i2c.h" -static struct arm_boot_info cubieboard_binfo = { - .loader_start =AW_A10_SDRAM_BASE , - .board_id =0x1008 , +#define TYPE_CUBIEBOARD_MACHINE MACHINE_TYPE_NAME("cubieboard") +OBJECT_DECLARE_SIMPLE_TYPE(CubieboardMachineState, CUBIEBOARD_MACHINE) + +struct CubieboardMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; };static void cubieboard_init (MachineState *machine) { +CubieboardMachineState *cbs =CUBIEBOARD_MACHINE (machine);AwA10State *a10;Error *err =NULL ;DriveInfo *di;
@@ -103,12 +108,18 @@ static void cubieboard_init(MachineState *machine) }/* TODO create and connect IDE devices for ide_drive_get() */ - cubieboard_binfo.ram_size = machine->ram_size; -arm_load_kernel (&a10->cpu, machine, &cubieboard_binfo); + cbs->bootinfo = (struct arm_boot_info ) { + .loader_start =AW_A10_SDRAM_BASE , + .board_id =0x1008 , + .ram_size = machine->ram_size, + }; +arm_load_kernel (&a10->cpu, machine, &cbs->bootinfo); } -static void cubieboard_machine_init (MachineClass *mc) +static void cubieboard_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); +static const char *const valid_cpu_types[] = {ARM_CPU_TYPE_NAME ("cortex-a8" ),NULL
@@ -126,4 +137,17 @@ static void cubieboard_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("cubieboard" , cubieboard_machine_init) +static const TypeInfo cubieboard_machine_typeinfo = { + .name =TYPE_CUBIEBOARD_MACHINE , + .parent =TYPE_MACHINE , + .class_init = cubieboard_machine_class_init, + .instance_size =sizeof (CubieboardMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void cubieboard_machine_register_types (void ) +{ +type_register_static (&cubieboard_machine_typeinfo); +} + +type_init (cubieboard_machine_register_types)
Signature · 1 line
2.53.0
PATCH 6/20 hw/arm: exynos4_boards: Store boot info in the board state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
The Exynos4BoardState struct is already allocated per machine instance, so move the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/exynos4_boards.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
hw/arm/exynos4_boards.c +12 -14
@@ -49,6 +49,7 @@ typedef struct Exynos4BoardState {Exynos4210State soc;MemoryRegion dram0_mem;MemoryRegion dram1_mem; +struct arm_boot_info bootinfo; } Exynos4BoardState;static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS ] = {
@@ -66,12 +67,6 @@ static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = { [EXYNOS4_BOARD_SMDKC210] = 1 * GiB, }; -static struct arm_boot_info exynos4_board_binfo = { - .loader_start =EXYNOS4210_BASE_BOOT_ADDR , - .smp_loader_start =EXYNOS4210_SMP_BOOT_ADDR , - .write_secondary_boot = exynos4210_write_secondary, -}; -static void lan9215_init (uint32_t base,qemu_irq irq) {DeviceState *dev;
@@ -115,12 +110,15 @@ exynos4_boards_init_common(MachineState *machine, {Exynos4BoardState *s =g_new (Exynos4BoardState,1 ); - exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; - exynos4_board_binfo.board_id = exynos4_board_id[board_type]; - exynos4_board_binfo.smp_bootreg_addr = - exynos4_board_smp_bootreg_addr[board_type]; - exynos4_board_binfo.gic_cpu_if_addr = -EXYNOS4210_SMP_PRIVATE_BASE_ADDR +0x100 ; + s->bootinfo = (struct arm_boot_info ) { + .loader_start =EXYNOS4210_BASE_BOOT_ADDR , + .smp_loader_start =EXYNOS4210_SMP_BOOT_ADDR , + .write_secondary_boot = exynos4210_write_secondary, + .ram_size = exynos4_board_ram_size[board_type], + .board_id = exynos4_board_id[board_type], + .smp_bootreg_addr = exynos4_board_smp_bootreg_addr[board_type], + .gic_cpu_if_addr =EXYNOS4210_SMP_PRIVATE_BASE_ADDR +0x100 , + };exynos4_boards_init_ram (s,get_system_memory (), exynos4_board_ram_size[board_type]);
@@ -137,7 +135,7 @@ static void nuri_init(MachineState *machine)Exynos4BoardState *s =exynos4_boards_init_common (machine,EXYNOS4_BOARD_NURI ); -arm_load_kernel (s->soc.cpu[0 ], machine, &exynos4_board_binfo); +arm_load_kernel (s->soc.cpu[0 ], machine, &s->bootinfo); }static void smdkc210_init (MachineState *machine)
@@ -147,7 +145,7 @@ static void smdkc210_init(MachineState *machine)lan9215_init (SMDK_LAN9118_BASE_ADDR ,qemu_irq_invert (s->soc.irq_table[exynos4210_get_irq (37 ,1 )])); -arm_load_kernel (s->soc.cpu[0 ], machine, &exynos4_board_binfo); +arm_load_kernel (s->soc.cpu[0 ], machine, &s->bootinfo); }static const char *const valid_cpu_types[] = {
Signature · 1 line
2.53.0
PATCH 7/20 hw/arm: imx25_pdk: Store boot info in the board state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
The IMX25PDK struct is already allocated per machine instance, so move the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/imx25_pdk.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
hw/arm/imx25_pdk.c +5 -6
@@ -61,10 +61,9 @@typedef struct IMX25PDK {FslIMX25State soc;MemoryRegion ram_alias; +struct arm_boot_info bootinfo; }IMX25PDK ; -static struct arm_boot_info imx25_pdk_binfo; -static void imx25_pdk_init (MachineState *machine) {IMX25PDK *s =g_new0 (IMX25PDK ,1 );
@@ -114,9 +113,9 @@ static void imx25_pdk_init(MachineState *machine) alias_offset += ram[i].size; } - imx25_pdk_binfo.ram_size = machine->ram_size; - imx25_pdk_binfo.loader_start =FSL_IMX25_SDRAM0_ADDR ; - imx25_pdk_binfo.board_id =1771 ; + s->bootinfo.ram_size = machine->ram_size; + s->bootinfo.loader_start =FSL_IMX25_SDRAM0_ADDR ; + s->bootinfo.board_id =1771 ;for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) {BusState *bus;
@@ -138,7 +137,7 @@ static void imx25_pdk_init(MachineState *machine)* fail. */ if (!qtest_enabled ()) { -arm_load_kernel (&s->soc.cpu, machine, &imx25_pdk_binfo); +arm_load_kernel (&s->soc.cpu, machine, &s->bootinfo); } }
Signature · 1 line
2.53.0
PATCH 8/20 hw/arm: imx8mm-evk: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a function scoped static object.
Move it into a new Imx8mmEvkMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_AARCH64 macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/imx8mm-evk.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
hw/arm/imx8mm-evk.c +29 -5
@@ -20,6 +20,15 @@#include "qapi/error.h" #include <libfdt.h> +#define TYPE_IMX8MM_EVK_MACHINE MACHINE_TYPE_NAME("imx8mm-evk") +OBJECT_DECLARE_SIMPLE_TYPE(Imx8mmEvkMachineState, IMX8MM_EVK_MACHINE) + +struct Imx8mmEvkMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +}; +static void imx8mm_evk_modify_dtb (const struct arm_boot_info *info,void *fdt) {int i, offset;
@@ -60,7 +69,7 @@ static void imx8mm_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)static void imx8mm_evk_init (MachineState *machine) { -static struct arm_boot_info boot_info; +Imx8mmEvkMachineState *ims =IMX8MM_EVK_MACHINE (machine);FslImx8mmState *s;if (machine->ram_size >FSL_IMX8MM_RAM_SIZE_MAX ) {
@@ -69,7 +78,7 @@ static void imx8mm_evk_init(MachineState *machine)exit (1 ); } - boot_info = (struct arm_boot_info ) { + ims->bootinfo = (struct arm_boot_info ) { .loader_start =FSL_IMX8MM_RAM_START , .board_id =-1 , .ram_size = machine->ram_size,
@@ -103,7 +112,7 @@ static void imx8mm_evk_init(MachineState *machine) }if (!qtest_enabled ()) { -arm_load_kernel (&s->cpu[0 ], machine, &boot_info); +arm_load_kernel (&s->cpu[0 ], machine, &ims->bootinfo); } }
@@ -116,8 +125,10 @@ static const char *imx8mm_evk_get_default_cpu_type(const MachineState *ms)return ARM_CPU_TYPE_NAME ("cortex-a53" ); } -static void imx8mm_evk_machine_init (MachineClass *mc) +static void imx8mm_evk_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="NXP i.MX 8MM EVK Board" ; mc->init = imx8mm_evk_init; mc->max_cpus =FSL_IMX8MM_NUM_CPUS ;
@@ -127,4 +138,17 @@ static void imx8mm_evk_machine_init(MachineClass *mc) mc->get_default_cpu_type = imx8mm_evk_get_default_cpu_type; } -DEFINE_MACHINE_AARCH64 ("imx8mm-evk" , imx8mm_evk_machine_init) +static const TypeInfo imx8mm_evk_machine_typeinfo = { + .name =TYPE_IMX8MM_EVK_MACHINE , + .parent =TYPE_MACHINE , + .class_init = imx8mm_evk_machine_class_init, + .instance_size =sizeof (Imx8mmEvkMachineState), + .interfaces = aarch64_machine_interfaces, +}; + +static void imx8mm_evk_machine_register_types (void ) +{ +type_register_static (&imx8mm_evk_machine_typeinfo); +} + +type_init (imx8mm_evk_machine_register_types)
Signature · 1 line
2.53.0
PATCH 9/20 hw/arm: integratorcp: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move it into a new IntegratorcpMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/integratorcp.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-)
hw/arm/integratorcp.c +33 -7
@@ -581,13 +581,19 @@ static void icp_control_init(Object *obj)/* Board init. */ -static struct arm_boot_info integrator_binfo = { - .loader_start =0x0 , - .board_id =0x113 , +#define TYPE_INTEGRATORCP_MACHINE MACHINE_TYPE_NAME("integratorcp") +OBJECT_DECLARE_SIMPLE_TYPE (IntegratorcpMachineState, + INTEGRATORCP_MACHINE) + +struct IntegratorcpMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; };static void integratorcp_init (MachineState *machine) { +IntegratorcpMachineState *icms =INTEGRATORCP_MACHINE (machine);ram_addr_t ram_size = machine->ram_size;Object *cpuobj;ARMCPU *cpu;
@@ -680,12 +686,19 @@ static void integratorcp_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0xc0000000 );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[22 ]); - integrator_binfo.ram_size = ram_size; -arm_load_kernel (cpu, machine, &integrator_binfo); + icms->bootinfo = (struct arm_boot_info ) { + .loader_start =0x0 , + .board_id =0x113 , + .ram_size = ram_size, + }; +arm_load_kernel (cpu, machine, &icms->bootinfo); } -static void integratorcp_machine_init (MachineClass *mc) +static void integratorcp_machine_class_init (ObjectClass *oc, +const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="ARM Integrator/CP (ARM926EJ-S)" ; mc->init = integratorcp_init; mc->ignore_memory_transaction_failures = true;
@@ -696,7 +709,20 @@ static void integratorcp_machine_init(MachineClass *mc)machine_add_audiodev_property (mc); } -DEFINE_MACHINE_ARM("integratorcp", integratorcp_machine_init) +static const TypeInfo integratorcp_machine_typeinfo = { + .name =TYPE_INTEGRATORCP_MACHINE , + .parent =TYPE_MACHINE , + .class_init = integratorcp_machine_class_init, + .instance_size =sizeof (IntegratorcpMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void integratorcp_machine_register_types (void ) +{ +type_register_static (&integratorcp_machine_typeinfo); +} + +type_init (integratorcp_machine_register_types) static const Property core_properties[] = {DEFINE_PROP_UINT32 ("memsz" , IntegratorCMState, memsz,0 ),
Signature · 1 line
2.53.0
PATCH 10/20 hw/arm: kzm: Store boot info in the board state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
The IMX31KZM struct is already allocated per machine instance, so move the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/kzm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/arm/kzm.c +7 -7
@@ -54,17 +54,13 @@typedef struct IMX31KZM {FslIMX31State soc;MemoryRegion ram_alias; +struct arm_boot_info bootinfo; }IMX31KZM ;#define KZM_RAM_ADDR (FSL_IMX31_SDRAM0_ADDR)#define KZM_FPGA_ADDR (FSL_IMX31_CS4_ADDR + 0x1040)#define KZM_LAN9118_ADDR (FSL_IMX31_CS5_ADDR) -static struct arm_boot_info kzm_binfo = { - .loader_start =KZM_RAM_ADDR , - .board_id =1722 , -}; -static void kzm_init (MachineState *machine) {IMX31KZM *s =g_new0 (IMX31KZM ,1 );
@@ -125,10 +121,14 @@ static void kzm_init(MachineState *machine) 14745600, serial_hd(2), DEVICE_NATIVE_ENDIAN); } - kzm_binfo.ram_size = machine->ram_size; + s->bootinfo = (struct arm_boot_info ) { + .loader_start =KZM_RAM_ADDR , + .board_id =1722 , + .ram_size = machine->ram_size, + };if (!qtest_enabled ()) { -arm_load_kernel (&s->soc.cpu, machine, &kzm_binfo); +arm_load_kernel (&s->soc.cpu, machine, &s->bootinfo); } }
Signature · 1 line
2.53.0
PATCH 11/20 hw/arm: mcimx7d-sabre: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a function scoped static object.
Move it into a new Mcimx7dSabreMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/mcimx7d-sabre.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
hw/arm/mcimx7d-sabre.c +31 -5
@@ -22,9 +22,19 @@#include "qemu/error-report.h" #include "system/qtest.h" +#define TYPE_MCIMX7D_SABRE_MACHINE MACHINE_TYPE_NAME("mcimx7d-sabre") +OBJECT_DECLARE_SIMPLE_TYPE (Mcimx7dSabreMachineState, + MCIMX7D_SABRE_MACHINE) + +struct Mcimx7dSabreMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +}; +static void mcimx7d_sabre_init (MachineState *machine) { -static struct arm_boot_info boot_info; +Mcimx7dSabreMachineState *msms =MCIMX7D_SABRE_MACHINE (machine);FslIMX7State *s;int i;
@@ -34,7 +44,7 @@ static void mcimx7d_sabre_init(MachineState *machine)exit (1 ); } - boot_info = (struct arm_boot_info ) { + msms->bootinfo = (struct arm_boot_info ) { .loader_start =FSL_IMX7_MMDC_ADDR , .board_id =-1 , .ram_size = machine->ram_size,
@@ -65,12 +75,15 @@ static void mcimx7d_sabre_init(MachineState *machine) }if (!qtest_enabled ()) { -arm_load_kernel (&s->cpu[0 ], machine, &boot_info); +arm_load_kernel (&s->cpu[0 ], machine, &msms->bootinfo); } } -static void mcimx7d_sabre_machine_init (MachineClass *mc) +static void mcimx7d_sabre_machine_class_init (ObjectClass *oc, +const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="Freescale i.MX7 DUAL SABRE (Cortex-A7)" ; mc->init = mcimx7d_sabre_init; mc->max_cpus =FSL_IMX7_NUM_CPUS ;
@@ -78,4 +91,17 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("mcimx7d-sabre" , mcimx7d_sabre_machine_init) +static const TypeInfo mcimx7d_sabre_machine_typeinfo = { + .name =TYPE_MCIMX7D_SABRE_MACHINE , + .parent =TYPE_MACHINE , + .class_init = mcimx7d_sabre_machine_class_init, + .instance_size =sizeof (Mcimx7dSabreMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void mcimx7d_sabre_machine_register_types (void ) +{ +type_register_static (&mcimx7d_sabre_machine_typeinfo); +} + +type_init (mcimx7d_sabre_machine_register_types)
Signature · 1 line
2.53.0
PATCH 12/20 hw/arm: musicpal: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move it into a new MusicPalMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/musicpal.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
hw/arm/musicpal.c +25 -7
@@ -1200,13 +1200,18 @@ static const TypeInfo musicpal_key_info = {#define FLASH_SECTOR_SIZE (64 * KiB) -static struct arm_boot_info musicpal_binfo = { - .loader_start =0x0 , - .board_id =0x20e , +#define TYPE_MUSICPAL_MACHINE MACHINE_TYPE_NAME("musicpal") +OBJECT_DECLARE_SIMPLE_TYPE(MusicPalMachineState, MUSICPAL_MACHINE) + +struct MusicPalMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; };static void musicpal_init (MachineState *machine) { +MusicPalMachineState *mpms =MUSICPAL_MACHINE (machine);ARMCPU *cpu;DeviceState *dev;DeviceState *pic;
@@ -1341,12 +1346,18 @@ static void musicpal_init(MachineState *machine)sysbus_mmio_map (s,0 ,MP_AUDIO_BASE );sysbus_connect_irq (s,0 ,qdev_get_gpio_in (pic,MP_AUDIO_IRQ )); - musicpal_binfo.ram_size =MP_RAM_DEFAULT_SIZE ; -arm_load_kernel (cpu, machine, &musicpal_binfo); + mpms->bootinfo = (struct arm_boot_info ) { + .loader_start =0x0 , + .board_id =0x20e , + .ram_size =MP_RAM_DEFAULT_SIZE , + }; +arm_load_kernel (cpu, machine, &mpms->bootinfo); } -static void musicpal_machine_init (MachineClass *mc) +static void musicpal_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); + mc->desc ="Marvell 88w8618 / MusicPal (ARM926EJ-S)" ; mc->init = musicpal_init; mc->ignore_memory_transaction_failures = true;
@@ -1357,7 +1368,13 @@ static void musicpal_machine_init(MachineClass *mc)machine_add_audiodev_property (mc); } -DEFINE_MACHINE_ARM("musicpal", musicpal_machine_init) +static const TypeInfo musicpal_machine_typeinfo = { + .name =TYPE_MUSICPAL_MACHINE , + .parent =TYPE_MACHINE , + .class_init = musicpal_machine_class_init, + .instance_size =sizeof (MusicPalMachineState), + .interfaces = arm_machine_interfaces, +};static void mv88w8618_wlan_class_init (ObjectClass *klass,const void *data) {
@@ -1383,6 +1400,7 @@ static void musicpal_register_types(void)type_register_static (&musicpal_gpio_info);type_register_static (&musicpal_key_info);type_register_static (&musicpal_misc_info); +type_register_static (&musicpal_machine_typeinfo); }type_init (musicpal_register_types)
Signature · 1 line
2.53.0
PATCH 13/20 hw/arm: npcm7xx: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object inside npcm7xx_load_kernel().
Let the caller own the boot info: the boards store it in their NPCM7xxMachine and pass it to npcm7xx_load_kernel(), which only fills in the SoC specific values.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/npcm7xx.c | 28 ++++++++++++++-------------- hw/arm/npcm7xx_boards.c | 15 ++++++++++----- include/hw/arm/npcm7xx.h | 10 ++++++++-- 3 files changed, 32 insertions(+), 21 deletions(-)
hw/arm/npcm7xx.c +14 -14
@@ -364,22 +364,22 @@ static void npcm7xx_write_secondary_boot(ARMCPU *cpu, NPCM7XX_SMP_LOADER_START); } -static struct arm_boot_info npcm7xx_binfo = { - .loader_start =NPCM7XX_LOADER_START , - .smp_loader_start =NPCM7XX_SMP_LOADER_START , - .smp_bootreg_addr =NPCM7XX_SMP_BOOTREG_ADDR , - .gic_cpu_if_addr =NPCM7XX_GIC_CPU_IF_ADDR , - .write_secondary_boot = npcm7xx_write_secondary_boot, - .board_id =-1 , - .board_setup_addr =NPCM7XX_BOARD_SETUP_ADDR , - .write_board_setup = npcm7xx_write_board_setup, -}; - -void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc) +void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc, +struct arm_boot_info *binfo) { - npcm7xx_binfo.ram_size = machine->ram_size; + *binfo = (struct arm_boot_info ) { + .loader_start =NPCM7XX_LOADER_START , + .smp_loader_start =NPCM7XX_SMP_LOADER_START , + .smp_bootreg_addr =NPCM7XX_SMP_BOOTREG_ADDR , + .gic_cpu_if_addr =NPCM7XX_GIC_CPU_IF_ADDR , + .write_secondary_boot = npcm7xx_write_secondary_boot, + .board_id =-1 , + .board_setup_addr =NPCM7XX_BOARD_SETUP_ADDR , + .write_board_setup = npcm7xx_write_board_setup, + .ram_size = machine->ram_size, + }; -arm_load_kernel (&soc->cpu[0 ], machine, &npcm7xx_binfo); +arm_load_kernel (&soc->cpu[0 ], machine, binfo); }static void npcm7xx_init_fuses (NPCM7xxState *s)
hw/arm/npcm7xx_boards.c +10 -5
@@ -374,7 +374,8 @@ static void npcm750_evb_init(MachineState *machine)npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"w25q256" ,drive_get (IF_MTD ,0 ,0 ));npcm750_evb_i2c_init (soc);npcm750_evb_fan_init (NPCM7XX_MACHINE (machine), soc); -npcm7xx_load_kernel (machine, soc); +npcm7xx_load_kernel (machine, soc, + &NPCM7XX_MACHINE (machine)->bootinfo); }static void quanta_gsj_init (MachineState *machine)
@@ -390,7 +391,8 @@ static void quanta_gsj_init(MachineState *machine) drive_get(IF_MTD, 0, 0));quanta_gsj_i2c_init (soc);quanta_gsj_fan_init (NPCM7XX_MACHINE (machine), soc); -npcm7xx_load_kernel (machine, soc); +npcm7xx_load_kernel (machine, soc, + &NPCM7XX_MACHINE (machine)->bootinfo); }static void quanta_gbs_init (MachineState *machine)
@@ -408,7 +410,8 @@ static void quanta_gbs_init(MachineState *machine)quanta_gbs_i2c_init (soc);sdhci_attach_drive (&soc->mmc.sdhci,0 ); -npcm7xx_load_kernel (machine, soc); +npcm7xx_load_kernel (machine, soc, + &NPCM7XX_MACHINE (machine)->bootinfo); }static void kudo_bmc_init (MachineState *machine)
@@ -427,7 +430,8 @@ static void kudo_bmc_init(MachineState *machine)kudo_bmc_i2c_init (soc);sdhci_attach_drive (&soc->mmc.sdhci,0 ); -npcm7xx_load_kernel (machine, soc); +npcm7xx_load_kernel (machine, soc, + &NPCM7XX_MACHINE (machine)->bootinfo); }static void mori_bmc_init (MachineState *machine)
@@ -442,7 +446,8 @@ static void mori_bmc_init(MachineState *machine)npcm7xx_connect_flash (&soc->fiu[1 ],0 ,"mx66u51235f" ,drive_get (IF_MTD ,3 ,0 )); -npcm7xx_load_kernel (machine, soc); +npcm7xx_load_kernel (machine, soc, + &NPCM7XX_MACHINE (machine)->bootinfo); }static void npcm7xx_set_soc_type (NPCM7xxMachineClass *nmc,const char *type)
include/hw/arm/npcm7xx.h +8 -2
@@ -19,6 +19,7 @@#include "hw/core/boards.h" #include "hw/adc/npcm7xx_adc.h" #include "hw/core/split-irq.h" +#include "hw/arm/boot.h" #include "hw/cpu/a9mpcore.h" #include "hw/gpio/npcm7xx_gpio.h" #include "hw/i2c/npcm7xx_smbus.h"
@@ -62,6 +63,7 @@ struct NPCM7xxMachine {*/ SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *NPCM7XX_PWM_PER_MODULE ]; +struct arm_boot_info bootinfo; };#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
@@ -129,11 +131,15 @@ typedef struct NPCM7xxClass {* npcm7xx_load_kernel - Loads memory with everything needed to boot * @machine - The machine containing the SoC to be booted. * @soc - The SoC containing the CPU to be booted. +* @binfo - Caller owned boot info structure to be filled in. * * This will set up the ARM boot info structure for the specific NPCM7xx * derivative and call arm_load_kernel() to set up loading of the kernel, etc. -* into memory, if requested by the user. +* into memory, if requested by the user. The boot info is owned by the +* caller because arm_load_kernel() keeps a pointer to it for the lifetime +* of the CPUs. */ -void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc); +void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc, +struct arm_boot_info *binfo);#endif /* NPCM7XX_H */
Signature · 1 line
2.53.0
PATCH 14/20 hw/arm: npcm8xx: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object inside npcm8xx_load_kernel().
Let the caller own the boot info: the board stores it in its NPCM8xxMachine and passes it to npcm8xx_load_kernel(), which only fills in the SoC specific values.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/npcm8xx.c | 30 +++++++++++++++--------------- hw/arm/npcm8xx_boards.c | 3 ++- include/hw/arm/npcm8xx.h | 10 ++++++++-- 3 files changed, 25 insertions(+), 18 deletions(-)
hw/arm/npcm8xx.c +15 -15
@@ -357,22 +357,22 @@ static const struct { }, }; -static struct arm_boot_info npcm8xx_binfo = { - .loader_start =NPCM8XX_LOADER_START , - .smp_loader_start =NPCM8XX_SMP_LOADER_START , - .smp_bootreg_addr =NPCM8XX_SMP_BOOTREG_ADDR , - .gic_cpu_if_addr =NPCM8XX_GICC_BA , - .secure_boot = false, - .board_id =-1 , - .board_setup_addr =NPCM8XX_BOARD_SETUP_ADDR , - .psci_conduit =QEMU_PSCI_CONDUIT_SMC , -}; - -void npcm8xx_load_kernel (MachineState *machine,NPCM8xxState *soc) +void npcm8xx_load_kernel (MachineState *machine,NPCM8xxState *soc, +struct arm_boot_info *binfo) { - npcm8xx_binfo.ram_size = machine->ram_size; - -arm_load_kernel (&soc->cpu[0 ], machine, &npcm8xx_binfo); + *binfo = (struct arm_boot_info ) { + .loader_start =NPCM8XX_LOADER_START , + .smp_loader_start =NPCM8XX_SMP_LOADER_START , + .smp_bootreg_addr =NPCM8XX_SMP_BOOTREG_ADDR , + .gic_cpu_if_addr =NPCM8XX_GICC_BA , + .secure_boot = false, + .board_id =-1 , + .board_setup_addr =NPCM8XX_BOARD_SETUP_ADDR , + .psci_conduit =QEMU_PSCI_CONDUIT_SMC , + .ram_size = machine->ram_size, + }; + +arm_load_kernel (&soc->cpu[0 ], machine, binfo); }static void npcm8xx_init_fuses (NPCM8xxState *s)
hw/arm/npcm8xx_boards.c +2 -1
@@ -198,7 +198,8 @@ static void npcm845_evb_init(MachineState *machine)npcm8xx_connect_flash (&soc->fiu[0 ],0 ,"w25q256" ,drive_get (IF_MTD ,0 ,0 ));npcm845_evb_i2c_init (soc);npcm845_evb_fan_init (NPCM8XX_MACHINE (machine), soc); -npcm8xx_load_kernel (machine, soc); +npcm8xx_load_kernel (machine, soc, + &NPCM8XX_MACHINE (machine)->bootinfo); }static void npcm8xx_set_soc_type (NPCM8xxMachineClass *nmc,const char *type)
include/hw/arm/npcm8xx.h +8 -2
@@ -23,6 +23,7 @@#include "hw/i2c/npcm7xx_smbus.h" #include "hw/intc/arm_gic_common.h" #include "hw/mem/npcm7xx_mc.h" +#include "hw/arm/boot.h" #include "hw/misc/npcm_clk.h" #include "hw/misc/npcm_gcr.h" #include "hw/misc/npcm7xx_mft.h"
@@ -62,6 +63,7 @@ struct NPCM8xxMachine {*/ SplitIRQ fan_splitter[NPCM8XX_NR_PWM_MODULES *NPCM7XX_PWM_PER_MODULE ]; +struct arm_boot_info bootinfo; };
@@ -122,11 +124,15 @@ OBJECT_DECLARE_TYPE(NPCM8xxState, NPCM8xxClass, NPCM8XX)* npcm8xx_load_kernel - Loads memory with everything needed to boot * @machine - The machine containing the SoC to be booted. * @soc - The SoC containing the CPU to be booted. +* @binfo - Caller owned boot info structure to be filled in. * * This will set up the ARM boot info structure for the specific NPCM8xx * derivative and call arm_load_kernel() to set up loading of the kernel, etc. -* into memory, if requested by the user. +* into memory, if requested by the user. The boot info is owned by the +* caller because arm_load_kernel() keeps a pointer to it for the lifetime +* of the CPUs. */ -void npcm8xx_load_kernel (MachineState *machine,NPCM8xxState *soc); +void npcm8xx_load_kernel (MachineState *machine,NPCM8xxState *soc, +struct arm_boot_info *binfo);#endif /* NPCM8XX_H */
Signature · 1 line
2.53.0
PATCH 15/20 hw/arm: omap_sx1: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Give both the sx1 and sx1-v1 machine types the same Sx1MachineState instance struct and store the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/omap_sx1.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/arm/omap_sx1.c +15 -6
@@ -91,14 +91,16 @@ static const MemoryRegionOps static_ops = {#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 , - .board_id =0x265 , -}; +typedef struct Sx1MachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +}Sx1MachineState ;static void sx1_init (MachineState *machine,const int version) { +/* Both sx1 and sx1-v1 embed the same state as their first member */ +Sx1MachineState *sms = (Sx1MachineState *)machine;struct omap_mpu_state_s *mpu;MachineClass *mc =MACHINE_GET_CLASS (machine);MemoryRegion *address_space =get_system_memory ();
@@ -187,7 +189,12 @@ static void sx1_init(MachineState *machine, const int version) }/* Load the kernel. */ -arm_load_kernel (mpu->cpu, machine, &sx1_binfo); + sms->bootinfo = (struct arm_boot_info ) { + .loader_start =OMAP_EMIFF_BASE , + .ram_size =SDRAM_SIZE , + .board_id =0x265 , + }; +arm_load_kernel (mpu->cpu, machine, &sms->bootinfo);/* TODO: fix next line */ //~ qemu_console_resize(ds, 640, 480);
@@ -220,6 +227,7 @@ static const TypeInfo sx1_machine_v2_type = { .name = MACHINE_TYPE_NAME("sx1"), .parent = TYPE_MACHINE, .class_init = sx1_machine_v2_class_init, + .instance_size = sizeof(Sx1MachineState), .interfaces = arm_machine_interfaces, };
@@ -240,6 +248,7 @@ static const TypeInfo sx1_machine_v1_type = { .name = MACHINE_TYPE_NAME("sx1-v1"), .parent = TYPE_MACHINE, .class_init = sx1_machine_v1_class_init, + .instance_size = sizeof(Sx1MachineState), .interfaces = arm_machine_interfaces, };
Signature · 1 line
2.53.0
PATCH 16/20 hw/arm: orangepi: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move it into a new OrangePiMachineState and register the machine type explicitly instead of through the DEFINE_MACHINE_ARM macro.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/orangepi.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
hw/arm/orangepi.c +30 -7
@@ -28,10 +28,18 @@#include "hw/arm/boot.h" #include "hw/arm/machines-qom.h" -static struct arm_boot_info orangepi_binfo; +#define TYPE_ORANGEPI_MACHINE MACHINE_TYPE_NAME("orangepi-pc") +OBJECT_DECLARE_SIMPLE_TYPE(OrangePiMachineState, ORANGEPI_MACHINE) + +struct OrangePiMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +};static void orangepi_init (MachineState *machine) { +OrangePiMachineState *opms =ORANGEPI_MACHINE (machine);AwH3State *h3;DriveInfo *di;BlockBackend *blk;
@@ -98,14 +106,16 @@ static void orangepi_init(MachineState *machine)/* Use Boot ROM to copy data from SD card to SRAM */ allwinner_h3_bootrom_setup (h3, blk); } - orangepi_binfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM ]; - orangepi_binfo.ram_size = machine->ram_size; - orangepi_binfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; -arm_load_kernel (&h3->cpus[0 ], machine, &orangepi_binfo); + opms->bootinfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM ]; + opms->bootinfo.ram_size = machine->ram_size; + opms->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; +arm_load_kernel (&h3->cpus[0 ], machine, &opms->bootinfo); } -static void orangepi_machine_init (MachineClass *mc) +static void orangepi_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); +static const char *const valid_cpu_types[] = {ARM_CPU_TYPE_NAME ("cortex-a7" ),NULL
@@ -125,4 +135,17 @@ static void orangepi_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("orangepi-pc" , orangepi_machine_init) +static const TypeInfo orangepi_machine_typeinfo = { + .name =TYPE_ORANGEPI_MACHINE , + .parent =TYPE_MACHINE , + .class_init = orangepi_machine_class_init, + .instance_size =sizeof (OrangePiMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void orangepi_machine_register_types (void ) +{ +type_register_static (&orangepi_machine_typeinfo); +} + +type_init (orangepi_machine_register_types)
Signature · 1 line
2.53.0
Re: [PATCH 16/20] hw/arm: orangepi: Store boot info in the machine state
Op do 13 aug. 2026 17:51 schreef Bin Meng <[email protected]>:
Quoted 7 lines
arm_load_kernel()keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.Move it into a new OrangePiMachineState and register the machine type explicitly instead of through the
DEFINE_MACHINE_ARMmacro.
Quoted 9 lines
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7("hw/arm: xlnx-zcu102: Movearm_boot_infointo XlnxZCU102")0f15c6e338("hw/arm/raspi: Movearm_boot_infostructure to RaspiMachineState")Signed-off-by Bin Meng <[email protected]>
---
Quoted 73 lines
hw/arm/orangepi.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)hw/arm/orangepi.c +30
-8@@ -28,10 +28,18 @@#include "hw/arm/boot.h" #include "hw/arm/machines-qom.h" -static struct arm_boot_info orangepi_binfo; +#define TYPE_ORANGEPI_MACHINE MACHINE_TYPE_NAME("orangepi-pc") +OBJECT_DECLARE_SIMPLE_TYPE(OrangePiMachineState, ORANGEPI_MACHINE) + +struct OrangePiMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +};static void orangepi_init (MachineState *machine) { +OrangePiMachineState *opms =ORANGEPI_MACHINE (machine);AwH3State *h3;DriveInfo *di;BlockBackend *blk;@@ -98,14 +106,16 @@ static void orangepi_init(MachineState *machine)/* Use Boot ROM to copy data from SD card to SRAM */ allwinner_h3_bootrom_setup (h3, blk); } - orangepi_binfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM ]; - orangepi_binfo.ram_size = machine->ram_size; - orangepi_binfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; -arm_load_kernel (&h3->cpus[0 ], machine, &orangepi_binfo); + opms->bootinfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM ]; + opms->bootinfo.ram_size = machine->ram_size; + opms->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; +arm_load_kernel (&h3->cpus[0 ], machine, &opms->bootinfo); } -static void orangepi_machine_init (MachineClass *mc) +static void orangepi_machine_class_init (ObjectClass *oc,const void *data) { +MachineClass *mc =MACHINE_CLASS (oc); +static const char *const valid_cpu_types[] = {ARM_CPU_TYPE_NAME ("cortex-a7" ),NULL @@ -125,4 +135,17 @@ static void orangepi_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("orangepi-pc" , orangepi_machine_init) +static const TypeInfo orangepi_machine_typeinfo = { + .name =TYPE_ORANGEPI_MACHINE , + .parent =TYPE_MACHINE , + .class_init = orangepi_machine_class_init, + .instance_size =sizeof (OrangePiMachineState), + .interfaces = arm_machine_interfaces, +}; + +static void orangepi_machine_register_types (void ) +{ +type_register_static (&orangepi_machine_typeinfo); +} + +type_init (orangepi_machine_register_types) --2.53.0
PATCH 17/20 hw/arm: realview: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Give all four realview machine types the same RealViewMachineState instance struct and store the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/realview.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
hw/arm/realview.c +21 -9
@@ -39,10 +39,11 @@/* Board init. */ -static struct arm_boot_info realview_binfo = { - .smp_loader_start =SMP_BOOT_ADDR , - .smp_bootreg_addr =SMP_BOOTREG_ADDR , -}; +typedef struct RealViewMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +}RealViewMachineState ;/* The following two lists must be consistent. */ enum realview_board_type {
@@ -76,6 +77,8 @@ static void split_irq_from_named(DeviceState *src, const char* outname,static void realview_init (MachineState *machine,enum realview_board_type board_type) { +/* All realview-* machines embed the same state as their first member */ +RealViewMachineState *rvms = (RealViewMachineState *)machine;ARMCPU *cpu =NULL ;CPUARMState *env;MemoryRegion *sysmem =get_system_memory ();
@@ -202,7 +205,7 @@ static void realview_init(MachineState *machine, }sysbus_create_varargs ("l2x0" , periphbase +0x2000 ,NULL );/* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */ - realview_binfo.gic_cpu_if_addr = periphbase +0x100 ; + rvms->bootinfo.gic_cpu_if_addr = periphbase +0x100 ; }else {uint32_t gic_addr = is_pb ?0x1e000000 :0x10040000 ;/* For now just create the nIRQ GIC, and ignore the others. */
@@ -387,10 +390,15 @@ static void realview_init(MachineState *machine, &error_fatal);memory_region_add_subregion (sysmem,SMP_BOOT_ADDR , ram_hack); - realview_binfo.ram_size = ram_size; - realview_binfo.board_id = realview_board_id[board_type]; - realview_binfo.loader_start = (board_type ==BOARD_PB_A8 ?0x70000000 :0 ); -arm_load_kernel (cpu, machine, &realview_binfo); + rvms->bootinfo = (struct arm_boot_info ) { + .smp_loader_start =SMP_BOOT_ADDR , + .smp_bootreg_addr =SMP_BOOTREG_ADDR , + .gic_cpu_if_addr = rvms->bootinfo.gic_cpu_if_addr, + .ram_size = ram_size, + .board_id = realview_board_id[board_type], + .loader_start = board_type ==BOARD_PB_A8 ?0x70000000 :0 , + }; +arm_load_kernel (cpu, machine, &rvms->bootinfo); }static void realview_eb_init (MachineState *machine)
@@ -431,6 +439,7 @@ static const TypeInfo realview_eb_type = { .name = MACHINE_TYPE_NAME("realview-eb"), .parent = TYPE_MACHINE, .class_init = realview_eb_class_init, + .instance_size = sizeof(RealViewMachineState), .interfaces = arm_machine_interfaces, };
@@ -453,6 +462,7 @@ static const TypeInfo realview_eb_mpcore_type = { .name = MACHINE_TYPE_NAME("realview-eb-mpcore"), .parent = TYPE_MACHINE, .class_init = realview_eb_mpcore_class_init, + .instance_size = sizeof(RealViewMachineState), .interfaces = arm_machine_interfaces, };
@@ -473,6 +483,7 @@ static const TypeInfo realview_pb_a8_type = { .name = MACHINE_TYPE_NAME("realview-pb-a8"), .parent = TYPE_MACHINE, .class_init = realview_pb_a8_class_init, + .instance_size = sizeof(RealViewMachineState), .interfaces = arm_machine_interfaces, };
@@ -494,6 +505,7 @@ static const TypeInfo realview_pbx_a9_type = { .name = MACHINE_TYPE_NAME("realview-pbx-a9"), .parent = TYPE_MACHINE, .class_init = realview_pbx_a9_class_init, + .instance_size = sizeof(RealViewMachineState), .interfaces = arm_machine_interfaces, };
Signature · 1 line
2.53.0
PATCH 18/20 hw/arm: sabrelite: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move the boot info into the existing SabreliteMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/sabrelite.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/arm/sabrelite.c +12 -12
@@ -25,18 +25,12 @@ struct SabreliteMachineState {FslIMX6State soc;CanBusState *canbus[FSL_IMX6_NUM_CANS ]; +struct arm_boot_info bootinfo; };#define TYPE_SABRELITE_MACHINE MACHINE_TYPE_NAME("sabrelite")OBJECT_DECLARE_SIMPLE_TYPE (SabreliteMachineState,SABRELITE_MACHINE ) -static struct arm_boot_info sabrelite_binfo = { -/* DDR memory start */ - .loader_start =FSL_IMX6_MMDC_ADDR , -/* No board ID, we boot from DT tree */ - .board_id =-1 , -}; - /* No need to do any particular setup for secondary boot */static void sabrelite_write_secondary (ARMCPU *cpu,const struct arm_boot_info *info)
@@ -110,13 +104,19 @@ static void sabrelite_init(MachineState *machine) } } - sabrelite_binfo.ram_size = machine->ram_size; - sabrelite_binfo.secure_boot = true; - sabrelite_binfo.write_secondary_boot = sabrelite_write_secondary; - sabrelite_binfo.secondary_cpu_reset_hook = sabrelite_reset_secondary; + s->bootinfo = (struct arm_boot_info ) { +/* DDR memory start */ + .loader_start =FSL_IMX6_MMDC_ADDR , +/* No board ID, we boot from DT tree */ + .board_id =-1 , + .ram_size = machine->ram_size, + .secure_boot = true, + .write_secondary_boot = sabrelite_write_secondary, + .secondary_cpu_reset_hook = sabrelite_reset_secondary, + };if (!qtest_enabled ()) { -arm_load_kernel (&s->soc.cpu[0 ], machine, &sabrelite_binfo); +arm_load_kernel (&s->soc.cpu[0 ], machine, &s->bootinfo); } }
Signature · 1 line
2.53.0
PATCH 19/20 hw/arm: versatilepb: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Give both machine types the same VersatileMachineState instance struct and store the boot info there.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/versatilepb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
hw/arm/versatilepb.c +12 -4
@@ -182,10 +182,16 @@ static void vpb_sic_init(Object *obj)peripherals and expansion busses. For now we emulate a subset of the PB peripherals and just change the board ID. */ -static struct arm_boot_info versatile_binfo; +typedef struct VersatileMachineState { +MachineState parent; + +struct arm_boot_info bootinfo; +}VersatileMachineState ;static void versatile_init (MachineState *machine,int board_id) { +/* versatilepb and versatileab embed the same state as first member */ +VersatileMachineState *vms = (VersatileMachineState *)machine;Object *cpuobj;ARMCPU *cpu;MemoryRegion *sysmem =get_system_memory ();
@@ -397,9 +403,9 @@ static void versatile_init(MachineState *machine, int board_id)VERSATILE_FLASH_SECT_SIZE , 4, 0x0089, 0x0018, 0x0000, 0x0, 0); - versatile_binfo.ram_size = machine->ram_size; - versatile_binfo.board_id = board_id; -arm_load_kernel (cpu, machine, &versatile_binfo); + vms->bootinfo.ram_size = machine->ram_size; + vms->bootinfo.board_id = board_id; +arm_load_kernel (cpu, machine, &vms->bootinfo); }static void vpb_init (MachineState *machine)
@@ -431,6 +437,7 @@ static const TypeInfo versatilepb_type = { .name = MACHINE_TYPE_NAME("versatilepb"), .parent = TYPE_MACHINE, .class_init = versatilepb_class_init, + .instance_size = sizeof(VersatileMachineState), .interfaces = arm_machine_interfaces, };
@@ -453,6 +460,7 @@ static const TypeInfo versatileab_type = { .name = MACHINE_TYPE_NAME("versatileab"), .parent = TYPE_MACHINE, .class_init = versatileab_class_init, + .instance_size = sizeof(VersatileMachineState), .interfaces = arm_machine_interfaces, };
Signature · 1 line
2.53.0
PATCH 20/20 hw/arm: xilinx_zynq: Store boot info in the machine state
In reply to Bin Mengarm_load_kernel() keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.
Move the boot info into the existing ZynqMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
4d1ac883a7 ("hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102") 0f15c6e338 ("hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState")
---
hw/arm/xilinx_zynq.c | 17 ++++++++--------- include/hw/arm/xilinx_zynq.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-)
hw/arm/xilinx_zynq.c +8 -9
@@ -103,8 +103,6 @@ static void zynq_write_board_setup(ARMCPU *cpu, sizeof(board_setup_blob), BOARD_SETUP_ADDR); } -static struct arm_boot_info zynq_binfo = {}; -static void gem_init (uint32_t base,qemu_irq irq) {DeviceState *dev;
@@ -268,7 +266,7 @@ static void zynq_init(MachineState *machine) busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,MPCORE_PERIPHBASE ); - zynq_binfo.gic_cpu_if_addr =MPCORE_PERIPHBASE +0x100 ; + zynq_machine->bootinfo.gic_cpu_if_addr =MPCORE_PERIPHBASE +0x100 ;sysbus_create_varargs ("l2x0" ,MPCORE_PERIPHBASE +0x2000 ,NULL );for (n =0 ; n < smp_cpus; n++) {/* See "hw/intc/arm_gic.h" for the IRQ line association */
@@ -444,13 +442,14 @@ static void zynq_init(MachineState *machine)create_unimplemented_device ("zynq.qos301_dmac" ,0xF8947000 ,0x130 );create_unimplemented_device ("zynq.qos301_iou" ,0xF8948000 ,0x130 ); - zynq_binfo.ram_size = machine->ram_size; - zynq_binfo.board_id =0xd32 ; - zynq_binfo.loader_start =0 ; - zynq_binfo.board_setup_addr =BOARD_SETUP_ADDR ; - zynq_binfo.write_board_setup = zynq_write_board_setup; + zynq_machine->bootinfo.ram_size = machine->ram_size; + zynq_machine->bootinfo.board_id =0xd32 ; + zynq_machine->bootinfo.loader_start =0 ; + zynq_machine->bootinfo.board_setup_addr =BOARD_SETUP_ADDR ; + zynq_machine->bootinfo.write_board_setup = zynq_write_board_setup; -arm_load_kernel (zynq_machine->cpu[0 ], machine, &zynq_binfo); +arm_load_kernel (zynq_machine->cpu[0 ], machine, + &zynq_machine->bootinfo); }static void zynq_machine_class_init (ObjectClass *oc,const void *data)
include/hw/arm/xilinx_zynq.h +2 -0
@@ -14,6 +14,7 @@#include "target/arm/cpu-qom.h" #include "hw/core/qdev-clock.h" +#include "hw/arm/boot.h" #define TYPE_ZYNQ_MACHINE MACHINE_TYPE_NAME("xilinx-zynq-a9")OBJECT_DECLARE_SIMPLE_TYPE (ZynqMachineState,ZYNQ_MACHINE )
@@ -25,6 +26,7 @@ struct ZynqMachineState {Clock *ps_clk;ARMCPU *cpu[ZYNQ_MAX_CPUS ];uint8_t boot_mode; + struct arm_boot_info bootinfo; };#endif /* QEMU_ARM_ZYNQ_H */
Signature · 1 line
2.53.0
Re: [PATCH 20/20] hw/arm: xilinx_zynq: Store boot info in the machine state
Quoted 9 lines · Bin Meng
arm_load_kernel()keeps a pointer to the boot info struct for the lifetime of the VM, so the struct logically belongs to the machine rather than to a file scoped static object.Move the boot info into the existing ZynqMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
Quoted 6 lines
4d1ac883a7("hw/arm: xlnx-zcu102: Movearm_boot_infointo XlnxZCU102")0f15c6e338("hw/arm/raspi: Movearm_boot_infostructure to RaspiMachineState")Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 76 lines
---
hw/arm/xilinx_zynq.c | 17 ++++++++---------
include/hw/arm/xilinx_zynq.h| 2 ++2 files changed, 10 insertions(+), 9 deletions(-)hw/arm/xilinx_zynq.c +0
-0@@ -103,8 +103,6 @@ static void zynq_write_board_setup(ARMCPU *cpu, sizeof(board_setup_blob), BOARD_SETUP_ADDR); }hw/arm/xilinx_zynq.c +0
-2-static struct arm_boot_info zynq_binfo = {}; -static void
gem_init(uint32_t base, qemu_irq irq){
DeviceState *dev;hw/arm/xilinx_zynq.c +1
-1@@ -268,7 +266,7 @@ static void zynq_init(MachineState *machine) busdev = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(busdev, &error_fatal); sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE); - zynq_binfo.gic_cpu_if_addr = MPCORE_PERIPHBASE + 0x100; + zynq_machine->bootinfo.gic_cpu_if_addr = MPCORE_PERIPHBASE +0x100 ; sysbus_create_varargs("l2x0", MPCORE_PERIPHBASE + 0x2000, NULL); for (n = 0; n < smp_cpus; n++) {/* See "
hw/intc/arm_gic.h" for the IRQ line association */hw/arm/xilinx_zynq.c +0
-0@@ -444,13 +442,14 @@ static void zynq_init(MachineState *machine) create_unimplemented_device("zynq.qos301_dmac", 0xF8947000,0x130 ); create_unimplemented_device("zynq.qos301_iou", 0xF8948000,0x130 );
- zynq_binfo.ram_size =machine->ram_size;
- zynq_binfo.board_id =0xd32;
- zynq_binfo.loader_start = 0;
- zynq_binfo.board_setup_addr =BOARD_SETUP_ADDR;
- zynq_binfo.write_board_setup =zynq_write_board_setup; +zynq_machine->bootinfo.ram_size=machine->ram_size; +zynq_machine->bootinfo.board_id=0xd32;
+zynq_machine->bootinfo.loader_start= 0;
+zynq_machine->bootinfo.board_setup_addr=BOARD_SETUP_ADDR; +zynq_machine->bootinfo.write_board_setup=zynq_write_board_setup;
-arm_load_kernel(zynq_machine->cpu[0], machine, &zynq_binfo); + arm_load_kernel(zynq_machine->cpu[0], machine,
+&zynq_machine->bootinfo);
}
static voidzynq_machine_class_init(ObjectClass *oc, const void *data)include/hw/arm/xilinx_zynq.h +0
-0@@ -14,6 +14,7 @@
#include "target/arm/cpu-qom.h"
#include "hw/core/qdev-clock.h"
+#include "hw/arm/boot.h"
#defineTYPE_ZYNQ_MACHINEMACHINE_TYPE_NAME("xilinx-zynq-a9")OBJECT_DECLARE_SIMPLE_TYPE(ZynqMachineState, ZYNQ_MACHINE)include/hw/arm/xilinx_zynq.h +1
-0@@ -25,6 +26,7 @@ struct ZynqMachineState { Clock *ps_clk; ARMCPU *cpu[ZYNQ_MAX_CPUS]; uint8_t boot_mode; + struct arm_boot_info bootinfo; };
#endif /*QEMU_ARM_ZYNQ_H*/
Quoted 9 lines · Bin Meng
Most ARM board files declare their struct
arm_boot_infoas a static object at file scope (or, occasionally, as a function-local static inside the machine init function).arm_load_kernel()stashes a pointer to that struct in every CPU and dereferences it fromdo_cpu_reset()on each reset, so the boot info conceptually belongs to the machine for the lifetime of the VM, not to a static object whose ownership is left implicit.
Quoted 5 lines
This is a longstanding leftover pattern: modern machines such as virt, raspi and xlnx-zcu102 already keep the boot info in their MachineState subclass. This series converts the remaining machines that still use a static object, moving the struct into their machine state so that its lifetime and ownership match how
arm_load_kernel()actually uses it.
I wanted that cleanup since a long time, excellent, thanks Bin!
Quoted 10 lines · Bin Meng
Most ARM board files declare their struct
arm_boot_infoas a static object at file scope (or, occasionally, as a function-local static inside the machine init function).arm_load_kernel()stashes a pointer to that struct in every CPU and dereferences it fromdo_cpu_reset()on each reset, so the boot info conceptually belongs to the machine for the lifetime of the VM, not to a static object whose ownership is left implicit.
Quoted 5 lines
This is a longstanding leftover pattern: modern machines such as virt, raspi and xlnx-zcu102 already keep the boot info in their MachineState subclass. This series converts the remaining machines that still use a static object, moving the struct into their machine state so that its lifetime and ownership match how
arm_load_kernel()actually uses it.
Yes, I think mostly we have this leftover because converting machines which don't yet have a state struct to have one seemed a bit tedious. But it'll be useful to have them for other cleanup reasons in future I suspect; I like the cleanup.
Rather than commenting on a lot of individual patches, I'll just list a couple of niggles here:
(1) Can we be consistent about whether we set fields individually, like this in patch 2:
+ bpms->bootinfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM]; + bpms->bootinfo.ram_size = machine->ram_size; + bpms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
or via a struct initializer, like this in patch 3:
+ cms->bootinfo = (struct arm_boot_info) {
+ .loader_start = SA_SDCS0, + .ram_size = RAM_SIZE, + .board_id = 0x208,
+ };
I don't particularly care which you pick, I'd just like to avoid the needless variation.
(2) Could we use DEFINE_MACHINE_EXTENDED() rather than writing out all the QOM boilerplate by hand, for the boards which previously used DEFINE_MACHINE_ARM? (No need to convert to macros if we were already using hand-written boilerplate, like omap_sx1.c.)
thanks
-- PMM