@samitouri / QOSamiQemu / commits / edb0b93a70

hw/arm: cubieboard: 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 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") Signed-off-by: Bin Meng <bin.meng@processmission.com> Message-id: 20260816131300.51799-6-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 edb0b93a7000e6eb49cb51284555f54db6489f04
1 file changed +15 -6
hw/arm/cubieboard.c
+15 -6
@@ -25,13 +25,18 @@
25 #include "hw/arm/machines-qom.h"
26 #include "hw/i2c/i2c.h"
27
28 -static struct arm_boot_info cubieboard_binfo = {
29 - .loader_start = AW_A10_SDRAM_BASE,
30 - .board_id = 0x1008,
28 +#define TYPE_CUBIEBOARD_MACHINE MACHINE_TYPE_NAME("cubieboard")
29 +OBJECT_DECLARE_SIMPLE_TYPE(CubieboardMachineState, CUBIEBOARD_MACHINE)
30 +
31 +struct CubieboardMachineState {
32 + MachineState parent;
33 +
34 + struct arm_boot_info bootinfo;
35 };
36
37 static void cubieboard_init(MachineState *machine)
38 {
39 + CubieboardMachineState *cbs = CUBIEBOARD_MACHINE(machine);
40 AwA10State *a10;
41 Error *err = NULL;
42 DriveInfo *di;
@@ -103,8 +108,10 @@ static void cubieboard_init(MachineState *machine)
108 }
109 /* TODO create and connect IDE devices for ide_drive_get() */
110
106 - cubieboard_binfo.ram_size = machine->ram_size;
107 - arm_load_kernel(&a10->cpu, machine, &cubieboard_binfo);
111 + cbs->bootinfo.loader_start = AW_A10_SDRAM_BASE;
112 + cbs->bootinfo.board_id = 0x1008;
113 + cbs->bootinfo.ram_size = machine->ram_size;
114 + arm_load_kernel(&a10->cpu, machine, &cbs->bootinfo);
115 }
116
117 static void cubieboard_machine_init(MachineClass *mc)
@@ -126,4 +133,6 @@ static void cubieboard_machine_init(MachineClass *mc)
133 mc->auto_create_sdcard = true;
134 }
135
129 -DEFINE_MACHINE_ARM("cubieboard", cubieboard_machine_init)
136 +DEFINE_MACHINE_EXTENDED("cubieboard", MACHINE, CubieboardMachineState,
137 + cubieboard_machine_init, false,
138 + arm_machine_interfaces)