@samitouri / QOSamiQemu / commits / ab7794550f

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

Bin Meng committed Aug 16, 2026 at 21:12 UTC ab7794550fd24d1caca87e86f16d542195a02ce2
1 file changed +16 -6
hw/arm/orangepi.c
+16 -6
@@ -28,10 +28,18 @@
28 #include "hw/arm/boot.h"
29 #include "hw/arm/machines-qom.h"
30
31 -static struct arm_boot_info orangepi_binfo;
31 +#define TYPE_ORANGEPI_MACHINE MACHINE_TYPE_NAME("orangepi-pc")
32 +OBJECT_DECLARE_SIMPLE_TYPE(OrangePiMachineState, ORANGEPI_MACHINE)
33 +
34 +struct OrangePiMachineState {
35 + MachineState parent;
36 +
37 + struct arm_boot_info bootinfo;
38 +};
39
40 static void orangepi_init(MachineState *machine)
41 {
42 + OrangePiMachineState *opms = ORANGEPI_MACHINE(machine);
43 AwH3State *h3;
44 DriveInfo *di;
45 BlockBackend *blk;
@@ -98,10 +106,10 @@ static void orangepi_init(MachineState *machine)
106 /* Use Boot ROM to copy data from SD card to SRAM */
107 allwinner_h3_bootrom_setup(h3, blk);
108 }
101 - orangepi_binfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM];
102 - orangepi_binfo.ram_size = machine->ram_size;
103 - orangepi_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
104 - arm_load_kernel(&h3->cpus[0], machine, &orangepi_binfo);
109 + opms->bootinfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM];
110 + opms->bootinfo.ram_size = machine->ram_size;
111 + opms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
112 + arm_load_kernel(&h3->cpus[0], machine, &opms->bootinfo);
113 }
114
115 static void orangepi_machine_init(MachineClass *mc)
@@ -125,4 +133,6 @@ static void orangepi_machine_init(MachineClass *mc)
133 mc->auto_create_sdcard = true;
134 }
135
128 -DEFINE_MACHINE_ARM("orangepi-pc", orangepi_machine_init)
136 +DEFINE_MACHINE_EXTENDED("orangepi-pc", MACHINE, OrangePiMachineState,
137 + orangepi_machine_init, false,
138 + arm_machine_interfaces)