@samitouri / QOSamiQemu / commits / 1fa13d2eef

hw/arm: bananapi_m2u: 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 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") Signed-off-by: Bin Meng <bin.meng@processmission.com> Message-id: 20260816131300.51799-4-bin.meng@processmission.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Bin Meng committed Aug 16, 2026 at 21:12 UTC 1fa13d2eef9ddbf0191d2c3a5a78e8b9167829a8
1 file changed +15 -6
hw/arm/bananapi_m2u.c
+15 -6
@@ -29,7 +29,14 @@
29 #include "hw/arm/boot.h"
30 #include "hw/arm/machines-qom.h"
31
32 -static struct arm_boot_info bpim2u_binfo;
32 +#define TYPE_BPIM2U_MACHINE MACHINE_TYPE_NAME("bpim2u")
33 +OBJECT_DECLARE_SIMPLE_TYPE(Bpim2uMachineState, BPIM2U_MACHINE)
34 +
35 +struct Bpim2uMachineState {
36 + MachineState parent;
37 +
38 + struct arm_boot_info bootinfo;
39 +};
40
41 /*
42 * 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,
69
70 static void bpim2u_init(MachineState *machine)
71 {
72 + Bpim2uMachineState *bpms = BPIM2U_MACHINE(machine);
73 bool bootroom_loaded = false;
74 AwR40State *r40;
75 I2CBus *i2c;
@@ -120,10 +128,10 @@ static void bpim2u_init(MachineState *machine)
128 memory_region_add_subregion(get_system_memory(),
129 r40->memmap[AW_R40_DEV_SDRAM], machine->ram);
130
123 - bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
124 - bpim2u_binfo.ram_size = machine->ram_size;
125 - bpim2u_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
126 - arm_load_kernel(&r40->cpus[0], machine, &bpim2u_binfo);
131 + bpms->bootinfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
132 + bpms->bootinfo.ram_size = machine->ram_size;
133 + bpms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
134 + arm_load_kernel(&r40->cpus[0], machine, &bpms->bootinfo);
135 }
136
137 static void bpim2u_machine_init(MachineClass *mc)
@@ -145,4 +153,5 @@ static void bpim2u_machine_init(MachineClass *mc)
153 mc->auto_create_sdcard = true;
154 }
155
148 -DEFINE_MACHINE_ARM("bpim2u", bpim2u_machine_init)
156 +DEFINE_MACHINE_EXTENDED("bpim2u", MACHINE, Bpim2uMachineState,
157 + bpim2u_machine_init, false, arm_machine_interfaces)