hw/arm: Store the ARM boot info in the machine state
Subsystems (4)
v2 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.
Changes in v2:
Addressed 2 review comments from Peter:
- All assignments now use individual field writes (e.g.:
bpms->bootinfo.loader_start = ...). This applies to: collie, cubieboard, exynos4, imx8mm-evk, integratorcp, kzm, mcimx7d-sabre, musicpal, npcm7xx, npcm8xx, omap_sx1, realview, sabrelite
- The following boards that previously used DEFINE_MACHINE_ARM/AARCH64 now use the macro DEFINE_MACHINE_EXTENDED() instead: bananapi_m2u, cubieboard, imx8mm-evk, integratorcp, mcimx7d-sabre, musicpal, orangepi-pc
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 | 21 +++++++++++++++------ hw/arm/collie.c | 12 +++++------- hw/arm/cubieboard.c | 21 +++++++++++++++------ hw/arm/exynos4_boards.c | 26 +++++++++++--------------- hw/arm/imx25_pdk.c | 11 +++++------ hw/arm/imx8mm-evk.c | 29 +++++++++++++++++++---------- hw/arm/integratorcp.c | 22 ++++++++++++++++------ hw/arm/kzm.c | 12 +++++------- hw/arm/mcimx7d-sabre.c | 28 +++++++++++++++++++--------- hw/arm/musicpal.c | 21 +++++++++++++++------ hw/arm/npcm7xx.c | 28 +++++++++++++--------------- hw/arm/npcm7xx_boards.c | 10 +++++----- hw/arm/npcm8xx.c | 28 +++++++++++++--------------- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/omap_sx1.c | 19 +++++++++++++------ hw/arm/orangepi.c | 22 ++++++++++++++++------ hw/arm/realview.c | 27 ++++++++++++++++++--------- hw/arm/sabrelite.c | 22 ++++++++++------------ 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, 267 insertions(+), 181 deletions(-)
---
base-commit: af06b5df2610fe5de6c02d17c17bced9e9f0d47d
branch: cleanup-arm-static-boot-info
Signature · 1 line
2.53.0
PATCH v2 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
Re: [PATCH v2 01/20] hw/arm: aspeed: Store boot info in the machine state
Quoted 25 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 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: Movearm_boot_infointo XlnxZCU102")0f15c6e338("hw/arm/raspi: Movearm_boot_infostructure to RaspiMachineState")Signed-off-by Bin Meng <[email protected]>---
hw/arm/aspeed.c | 17 +++++++---------- include/hw/arm/aspeed.h | 2 ++ 2 files changed, 9 insertions(+), 10 deletions(-)hw/arm/aspeed.c +0
-0@@ -24,10 +24,6 @@#include "hw/core/qdev-clock.h"
hw/arm/aspeed.c line 29
Quoted 10 lines
hw/arm/aspeed.c +1
-5#include "system/system.h" -static struct arm_boot_info aspeed_board_binfo = { - .board_id =-1 ,/* device-tree-only board */ -}; - 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 */
Should #define a self-explanatory BOARD_ID_DEVICE_TREE?
Quoted 13 lines
include/hw/arm/aspeed.h +1
-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 ;
include/hw/arm/aspeed.h struct AspeedMachineState { · line 47
Quoted 5 lines
include/hw/arm/aspeed.h +1
-0@@ -42,6 +43,7 @@ struct AspeedMachineState {char *fmc_model;char *spi_model;uint32_t hw_strap1; +struct arm_boot_info bootinfo; };
Maybe time to add a typedef to be style-consistent.
Anyhow:
Re: [PATCH v2 01/20] hw/arm: aspeed: Store boot info in the machine state
Quoted 14 lines · Philippe Mathieu-Daudé
hw/arm/aspeed.c static void aspeed_machine_init(MachineState *machine) · line 210
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 AspeedMachineState.
hw/arm/aspeed.c +1
-2- 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 */ Should #define a self-explanatory
BOARD_ID_DEVICE_TREE?
Quoted 8 lines
include/hw/arm/aspeed.h struct AspeedMachineState { · line 47
Quoted 6 lines
include/hw/arm/aspeed.h +1
-0@@ -42,6 +43,7 @@ struct AspeedMachineState {char *fmc_model;char *spi_model;uint32_t hw_strap1; +struct arm_boot_info bootinfo; };Maybe time to add a typedef to be style-consistent.
Mmm, and if we're adding a typedef then fixing the capitalization style to ArmBootInfo is what matches our style guide.
I think these are both good ideas but in the interests of not delaying this touch-lots-of-files patchset too much longer I think we can do them as separate patches afterwards.
(Interestingly the kernel does not bother to define a name for the -1 value -- it just hardcodes ~0 in its DT_MACHINE_START macro.)
thanks
-- PMM
PATCH v2 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
Re: [PATCH v2 02/20] hw/arm: aspeed_ast27x0-fc: 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 Ast2700FCState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
Quoted 8 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]>---
hw/arm/aspeed_ast27x0-fc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
PATCH v2 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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/arm/bananapi_m2u.c +15 -6
@@ -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,10 +128,10 @@ 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)
@@ -145,4 +153,5 @@ static void bpim2u_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("bpim2u" , bpim2u_machine_init) +DEFINE_MACHINE_EXTENDED ("bpim2u" ,MACHINE , Bpim2uMachineState, + bpim2u_machine_init, false, arm_machine_interfaces)
Signature · 1 line
2.53.0
PATCH v2 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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
hw/arm/collie.c +5 -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,10 @@ 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.loader_start =SA_SDCS0 ; + cms->bootinfo.ram_size =RAM_SIZE ; + cms->bootinfo.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 v2 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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/arm/cubieboard.c +15 -6
@@ -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,8 +108,10 @@ 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.loader_start =AW_A10_SDRAM_BASE ; + cbs->bootinfo.board_id =0x1008 ; + cbs->bootinfo.ram_size = machine->ram_size; +arm_load_kernel (&a10->cpu, machine, &cbs->bootinfo); }static void cubieboard_machine_init (MachineClass *mc)
@@ -126,4 +133,6 @@ static void cubieboard_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("cubieboard" , cubieboard_machine_init) +DEFINE_MACHINE_EXTENDED ("cubieboard" ,MACHINE , CubieboardMachineState, + cubieboard_machine_init, false, + arm_machine_interfaces)
Signature · 1 line
2.53.0
PATCH v2 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, 11 insertions(+), 15 deletions(-)
hw/arm/exynos4_boards.c +11 -15
@@ -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;
@@ -113,14 +108,15 @@ static Exynos4BoardState *exynos4_boards_init_common (MachineState *machine, Exynos4BoardType board_type) { -Exynos4BoardState *s =g_new (Exynos4BoardState,1 ); +Exynos4BoardState *s =g_new0 (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.loader_start =EXYNOS4210_BASE_BOOT_ADDR ; + s->bootinfo.smp_loader_start =EXYNOS4210_SMP_BOOT_ADDR ; + s->bootinfo.write_secondary_boot = exynos4210_write_secondary; + s->bootinfo.ram_size = exynos4_board_ram_size[board_type]; + s->bootinfo.board_id = exynos4_board_id[board_type]; + s->bootinfo.smp_bootreg_addr = exynos4_board_smp_bootreg_addr[board_type]; + s->bootinfo.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 +133,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 +143,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
Re: [PATCH v2 06/20] hw/arm: exynos4_boards: Store boot info in the board state
Quoted 10 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.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:
Quoted 8 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]>---
hw/arm/exynos4_boards.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
PATCH v2 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 v2 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 | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
hw/arm/imx8mm-evk.c +19 -10
@@ -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,13 +78,11 @@ static void imx8mm_evk_init(MachineState *machine)exit (1 ); } - boot_info = (struct arm_boot_info ) { - .loader_start =FSL_IMX8MM_RAM_START , - .board_id =-1 , - .ram_size = machine->ram_size, - .psci_conduit =QEMU_PSCI_CONDUIT_SMC , - .modify_dtb = imx8mm_evk_modify_dtb, - }; + ims->bootinfo.loader_start =FSL_IMX8MM_RAM_START ; + ims->bootinfo.board_id =-1 ; + ims->bootinfo.ram_size = machine->ram_size; + ims->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; + ims->bootinfo.modify_dtb = imx8mm_evk_modify_dtb; s =FSL_IMX8MM (object_new_with_props (TYPE_FSL_IMX8MM ,OBJECT (machine),"soc" , &error_fatal,NULL ));
@@ -103,7 +110,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); } }
@@ -127,4 +134,6 @@ 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) +DEFINE_MACHINE_EXTENDED ("imx8mm-evk" ,MACHINE , Imx8mmEvkMachineState, + imx8mm_evk_machine_init, false, + aarch64_machine_interfaces)
Signature · 1 line
2.53.0
PATCH v2 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 | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
hw/arm/integratorcp.c +16 -6
@@ -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,8 +686,10 @@ 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.loader_start =0x0 ; + icms->bootinfo.board_id =0x113 ; + icms->bootinfo.ram_size = ram_size; +arm_load_kernel (cpu, machine, &icms->bootinfo); }static void integratorcp_machine_init (MachineClass *mc)
@@ -696,7 +704,9 @@ static void integratorcp_machine_init(MachineClass *mc)machine_add_audiodev_property (mc); } -DEFINE_MACHINE_ARM("integratorcp", integratorcp_machine_init) +DEFINE_MACHINE_EXTENDED ("integratorcp" ,MACHINE , IntegratorcpMachineState, + integratorcp_machine_init, false, + arm_machine_interfaces)static const Property core_properties[] = {DEFINE_PROP_UINT32 ("memsz" , IntegratorCMState, memsz,0 ),
Signature · 1 line
2.53.0
PATCH v2 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 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
hw/arm/kzm.c +5 -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,12 @@ static void kzm_init(MachineState *machine) 14745600, serial_hd(2), DEVICE_NATIVE_ENDIAN); } - kzm_binfo.ram_size = machine->ram_size; + s->bootinfo.loader_start =KZM_RAM_ADDR ; + s->bootinfo.board_id =1722 ; + s->bootinfo.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 v2 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 | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
hw/arm/mcimx7d-sabre.c +19 -9
@@ -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,12 +44,10 @@ static void mcimx7d_sabre_init(MachineState *machine)exit (1 ); } - boot_info = (struct arm_boot_info ) { - .loader_start =FSL_IMX7_MMDC_ADDR , - .board_id =-1 , - .ram_size = machine->ram_size, - .psci_conduit =QEMU_PSCI_CONDUIT_SMC , - }; + msms->bootinfo.loader_start =FSL_IMX7_MMDC_ADDR ; + msms->bootinfo.board_id =-1 ; + msms->bootinfo.ram_size = machine->ram_size; + msms->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; s =FSL_IMX7 (object_new (TYPE_FSL_IMX7 ));object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s));
@@ -65,7 +73,7 @@ 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); } }
@@ -78,4 +86,6 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("mcimx7d-sabre" , mcimx7d_sabre_machine_init) +DEFINE_MACHINE_EXTENDED ("mcimx7d-sabre" ,MACHINE , Mcimx7dSabreMachineState, + mcimx7d_sabre_machine_init, false, + arm_machine_interfaces)
Signature · 1 line
2.53.0
PATCH v2 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 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/arm/musicpal.c +15 -6
@@ -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,8 +1346,10 @@ 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.loader_start =0x0 ; + mpms->bootinfo.board_id =0x20e ; + mpms->bootinfo.ram_size =MP_RAM_DEFAULT_SIZE ; +arm_load_kernel (cpu, machine, &mpms->bootinfo); }static void musicpal_machine_init (MachineClass *mc)
@@ -1357,7 +1364,9 @@ static void musicpal_machine_init(MachineClass *mc)machine_add_audiodev_property (mc); } -DEFINE_MACHINE_ARM("musicpal", musicpal_machine_init) +DEFINE_MACHINE_EXTENDED ("musicpal" ,MACHINE , MusicPalMachineState, + musicpal_machine_init, false, + arm_machine_interfaces)static void mv88w8618_wlan_class_init (ObjectClass *klass,const void *data) {
Signature · 1 line
2.53.0
PATCH v2 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 | 10 +++++----- include/hw/arm/npcm7xx.h | 10 ++++++++-- 3 files changed, 26 insertions(+), 22 deletions(-)
hw/arm/npcm7xx.c +13 -15
@@ -364,22 +364,20 @@ 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; - -arm_load_kernel (&soc->cpu[0 ], machine, &npcm7xx_binfo); + binfo->loader_start =NPCM7XX_LOADER_START ; + binfo->smp_loader_start =NPCM7XX_SMP_LOADER_START ; + binfo->smp_bootreg_addr =NPCM7XX_SMP_BOOTREG_ADDR ; + binfo->gic_cpu_if_addr =NPCM7XX_GIC_CPU_IF_ADDR ; + binfo->write_secondary_boot = npcm7xx_write_secondary_boot; + binfo->board_id =-1 ; + binfo->board_setup_addr =NPCM7XX_BOARD_SETUP_ADDR ; + binfo->write_board_setup = npcm7xx_write_board_setup; + binfo->ram_size = machine->ram_size; + +arm_load_kernel (&soc->cpu[0 ], machine, binfo); }static void npcm7xx_init_fuses (NPCM7xxState *s)
hw/arm/npcm7xx_boards.c +5 -5
@@ -374,7 +374,7 @@ 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 +390,7 @@ 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 +408,7 @@ 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 +427,7 @@ 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 +442,7 @@ 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 v2 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 | 28 +++++++++++++--------------- hw/arm/npcm8xx_boards.c | 2 +- include/hw/arm/npcm8xx.h | 10 ++++++++-- 3 files changed, 22 insertions(+), 18 deletions(-)
hw/arm/npcm8xx.c +13 -15
@@ -357,22 +357,20 @@ 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->loader_start =NPCM8XX_LOADER_START ; + binfo->smp_loader_start =NPCM8XX_SMP_LOADER_START ; + binfo->smp_bootreg_addr =NPCM8XX_SMP_BOOTREG_ADDR ; + binfo->gic_cpu_if_addr =NPCM8XX_GICC_BA ; + binfo->secure_boot = false; + binfo->board_id =-1 ; + binfo->board_setup_addr =NPCM8XX_BOARD_SETUP_ADDR ; + binfo->psci_conduit =QEMU_PSCI_CONDUIT_SMC ; + binfo->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 +1 -1
@@ -198,7 +198,7 @@ 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 v2 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 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hw/arm/omap_sx1.c +13 -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,10 @@ static void sx1_init(MachineState *machine, const int version) }/* Load the kernel. */ -arm_load_kernel (mpu->cpu, machine, &sx1_binfo); + sms->bootinfo.loader_start =OMAP_EMIFF_BASE ; + sms->bootinfo.ram_size =SDRAM_SIZE ; + sms->bootinfo.board_id =0x265 ; +arm_load_kernel (mpu->cpu, machine, &sms->bootinfo);/* TODO: fix next line */ //~ qemu_console_resize(ds, 640, 480);
@@ -220,6 +225,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 +246,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
Re: [PATCH v2 15/20] hw/arm: omap_sx1: Store boot info in the machine state
Quoted 10 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.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:
Quoted 8 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]>---
hw/arm/omap_sx1.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
PATCH v2 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 | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
hw/arm/orangepi.c +16 -6
@@ -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,10 +106,10 @@ 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)
@@ -125,4 +133,6 @@ static void orangepi_machine_init(MachineClass *mc) mc->auto_create_sdcard = true; } -DEFINE_MACHINE_ARM ("orangepi-pc" , orangepi_machine_init) +DEFINE_MACHINE_EXTENDED ("orangepi-pc" ,MACHINE , OrangePiMachineState, + orangepi_machine_init, false, + arm_machine_interfaces)
Signature · 1 line
2.53.0
PATCH v2 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 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
hw/arm/realview.c +18 -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,12 @@ 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.smp_loader_start =SMP_BOOT_ADDR ; + rvms->bootinfo.smp_bootreg_addr =SMP_BOOTREG_ADDR ; + rvms->bootinfo.ram_size = ram_size; + rvms->bootinfo.board_id = realview_board_id[board_type]; + rvms->bootinfo.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 +436,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 +459,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 +480,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 +502,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 v2 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 | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
hw/arm/sabrelite.c +10 -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,17 @@ 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; +/* DDR memory start */ + s->bootinfo.loader_start =FSL_IMX6_MMDC_ADDR ; +/* No board ID, we boot from DT tree */ + s->bootinfo.board_id =-1 ; + s->bootinfo.ram_size = machine->ram_size; + s->bootinfo.secure_boot = true; + s->bootinfo.write_secondary_boot = sabrelite_write_secondary; + s->bootinfo.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
Re: [PATCH v2 18/20] hw/arm: sabrelite: 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 SabreliteMachineState.
As in the xlnx-zcu102 and raspi machines, the boot info belongs to the machine rather than to a static object:
Quoted 8 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]>---
hw/arm/sabrelite.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
PATCH v2 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
Re: [PATCH v2 19/20] hw/arm: versatilepb: Store boot info in the machine state
Quoted 28 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.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: Movearm_boot_infointo XlnxZCU102")0f15c6e338("hw/arm/raspi: Movearm_boot_infostructure to RaspiMachineState")Signed-off-by Bin Meng <[email protected]>---
hw/arm/versatilepb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)hw/arm/versatilepb.c +0
-1@@ -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;
hw/arm/versatilepb.c static void vpb_sic_init(Object *obj) · line 194
Quoted 10 lines
hw/arm/versatilepb.c +7
-0+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;
Use OBJECT_DECLARE_SIMPLE_TYPE() and the defined macro?
Re: [PATCH v2 19/20] hw/arm: versatilepb: Store boot info in the machine state
Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 34 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.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: Movearm_boot_infointo XlnxZCU102")0f15c6e338("hw/arm/raspi: Movearm_boot_infostructure to RaspiMachineState")Signed-off-by Bin Meng <[email protected]>---
hw/arm/versatilepb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)hw/arm/versatilepb.c +5
-1@@ -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 ;
Quoted 6 lines
hw/arm/versatilepb.c static void vpb_sic_init(Object *obj) · line 194
Quoted 4 lines
hw/arm/versatilepb.c +2
-0static void versatile_init (MachineState *machine,int board_id) { +/* versatilepb and versatileab embed the same state as first member */ +VersatileMachineState *vms = (VersatileMachineState *)machine;Use
OBJECT_DECLARE_SIMPLE_TYPE()and the defined macro?
That doesn't work, unfortunately, because in this file we define two machine types (versatileab and versatilepb) which are separate classes directly inheriting from TYPE_MACHINE but which share a common init function (both classes have an instance_init method which calls versatile_init()). OBJECT_DECLARE_SIMPLE_TYPE wants a 1:1 relation between the state struct and the type.
I think to get this into a shape where we could use the standard QOM macros we would probably need to define a common abstract class that both the leaf machine types inherited from. That feels like it's probably a worthwhile cleanup, but I'm OK with what this patch is doing rather than making the "create the abstract parent" refactor a dependency for this series.
The same applies for the omap_sx1.c and realview.c patches in this series, which do a similar thing.
thanks
-- PMM
PATCH v2 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
Peter Maydell
AppliedQuoted 20 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.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.Changes in v2:
Addressed 2 review comments from Peter:
Quoted 9 lines
- All assignments now use individual field writes (e.g.:
bpms->bootinfo.loader_start= ...). This applies to: collie, cubieboard, exynos4, imx8mm-evk, integratorcp, kzm, mcimx7d-sabre, musicpal, npcm7xx, npcm8xx,omap_sx1, realview, sabrelite
- The following boards that previously used DEFINE_MACHINE_ARM/AARCH64 now use the macroDEFINE_MACHINE_EXTENDED()instead:bananapi_m2u, cubieboard, imx8mm-evk, integratorcp, mcimx7d-sabre, musicpal, orangepi-pc
Applied to target-arm.next, thanks.
-- PMM