@samitouri / QOSamiQemu / commits / 53fad63eeb

hw/arm: omap_sx1: 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. 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") Signed-off-by: Bin Meng <bin.meng@processmission.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Message-id: 20260816131300.51799-16-bin.meng@processmission.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Bin Meng committed Aug 16, 2026 at 21:12 UTC 53fad63eeb954200b667255b87e6d74b52720863
1 file changed +13 -6
hw/arm/omap_sx1.c
+13 -6
@@ -91,14 +91,16 @@ static const MemoryRegionOps static_ops = {
91 #define FLASH1_SIZE (8 * MiB)
92 #define FLASH2_SIZE (32 * MiB)
93
94 -static struct arm_boot_info sx1_binfo = {
95 - .loader_start = OMAP_EMIFF_BASE,
96 - .ram_size = SDRAM_SIZE,
97 - .board_id = 0x265,
98 -};
94 +typedef struct Sx1MachineState {
95 + MachineState parent;
96 +
97 + struct arm_boot_info bootinfo;
98 +} Sx1MachineState;
99
100 static void sx1_init(MachineState *machine, const int version)
101 {
102 + /* Both sx1 and sx1-v1 embed the same state as their first member */
103 + Sx1MachineState *sms = (Sx1MachineState *)machine;
104 struct omap_mpu_state_s *mpu;
105 MachineClass *mc = MACHINE_GET_CLASS(machine);
106 MemoryRegion *address_space = get_system_memory();
@@ -187,7 +189,10 @@ static void sx1_init(MachineState *machine, const int version)
189 }
190
191 /* Load the kernel. */
190 - arm_load_kernel(mpu->cpu, machine, &sx1_binfo);
192 + sms->bootinfo.loader_start = OMAP_EMIFF_BASE;
193 + sms->bootinfo.ram_size = SDRAM_SIZE;
194 + sms->bootinfo.board_id = 0x265;
195 + arm_load_kernel(mpu->cpu, machine, &sms->bootinfo);
196
197 /* TODO: fix next line */
198 //~ qemu_console_resize(ds, 640, 480);
@@ -220,6 +225,7 @@ static const TypeInfo sx1_machine_v2_type = {
225 .name = MACHINE_TYPE_NAME("sx1"),
226 .parent = TYPE_MACHINE,
227 .class_init = sx1_machine_v2_class_init,
228 + .instance_size = sizeof(Sx1MachineState),
229 .interfaces = arm_machine_interfaces,
230 };
231
@@ -240,6 +246,7 @@ static const TypeInfo sx1_machine_v1_type = {
246 .name = MACHINE_TYPE_NAME("sx1-v1"),
247 .parent = TYPE_MACHINE,
248 .class_init = sx1_machine_v1_class_init,
249 + .instance_size = sizeof(Sx1MachineState),
250 .interfaces = arm_machine_interfaces,
251 };
252