@samitouri / QOSamiQemu / commits / b8939158c3

hw/arm: mcimx7d-sabre: 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 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") Signed-off-by: Bin Meng <bin.meng@processmission.com> Message-id: 20260816131300.51799-12-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 b8939158c37afd88ea252dc2e11ca387ffeb4ce3
1 file changed +19 -9
hw/arm/mcimx7d-sabre.c
+19 -9
@@ -22,9 +22,19 @@
22 #include "qemu/error-report.h"
23 #include "system/qtest.h"
24
25 +#define TYPE_MCIMX7D_SABRE_MACHINE MACHINE_TYPE_NAME("mcimx7d-sabre")
26 +OBJECT_DECLARE_SIMPLE_TYPE(Mcimx7dSabreMachineState,
27 + MCIMX7D_SABRE_MACHINE)
28 +
29 +struct Mcimx7dSabreMachineState {
30 + MachineState parent;
31 +
32 + struct arm_boot_info bootinfo;
33 +};
34 +
35 static void mcimx7d_sabre_init(MachineState *machine)
36 {
27 - static struct arm_boot_info boot_info;
37 + Mcimx7dSabreMachineState *msms = MCIMX7D_SABRE_MACHINE(machine);
38 FslIMX7State *s;
39 int i;
40
@@ -34,12 +44,10 @@ static void mcimx7d_sabre_init(MachineState *machine)
44 exit(1);
45 }
46
37 - boot_info = (struct arm_boot_info) {
38 - .loader_start = FSL_IMX7_MMDC_ADDR,
39 - .board_id = -1,
40 - .ram_size = machine->ram_size,
41 - .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
42 - };
47 + msms->bootinfo.loader_start = FSL_IMX7_MMDC_ADDR;
48 + msms->bootinfo.board_id = -1;
49 + msms->bootinfo.ram_size = machine->ram_size;
50 + msms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
51
52 s = FSL_IMX7(object_new(TYPE_FSL_IMX7));
53 object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
@@ -65,7 +73,7 @@ static void mcimx7d_sabre_init(MachineState *machine)
73 }
74
75 if (!qtest_enabled()) {
68 - arm_load_kernel(&s->cpu[0], machine, &boot_info);
76 + arm_load_kernel(&s->cpu[0], machine, &msms->bootinfo);
77 }
78 }
79
@@ -78,4 +86,6 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc)
86 mc->auto_create_sdcard = true;
87 }
88
81 -DEFINE_MACHINE_ARM("mcimx7d-sabre", mcimx7d_sabre_machine_init)
89 +DEFINE_MACHINE_EXTENDED("mcimx7d-sabre", MACHINE, Mcimx7dSabreMachineState,
90 + mcimx7d_sabre_machine_init, false,
91 + arm_machine_interfaces)