Commit 1fa13d2eef for qemu.org
commit 1fa13d2eef9ddbf0191d2c3a5a78e8b9167829a8
Author: Bin Meng <bin.meng@processmission.com>
Date: Sun Aug 16 21:12:33 2026 +0800
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>
diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
index 9b468cd8ac..0079aa1dd2 100644
--- a/hw/arm/bananapi_m2u.c
+++ b/hw/arm/bananapi_m2u.c
@@ -29,7 +29,14 @@
#include "hw/arm/boot.h"
#include "hw/arm/machines-qom.h"
-static struct arm_boot_info bpim2u_binfo;
+#define TYPE_BPIM2U_MACHINE MACHINE_TYPE_NAME("bpim2u")
+OBJECT_DECLARE_SIMPLE_TYPE(Bpim2uMachineState, BPIM2U_MACHINE)
+
+struct Bpim2uMachineState {
+ MachineState parent;
+
+ struct arm_boot_info bootinfo;
+};
/*
* 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,
static void bpim2u_init(MachineState *machine)
{
+ Bpim2uMachineState *bpms = BPIM2U_MACHINE(machine);
bool bootroom_loaded = false;
AwR40State *r40;
I2CBus *i2c;
@@ -120,10 +128,10 @@ static void bpim2u_init(MachineState *machine)
memory_region_add_subregion(get_system_memory(),
r40->memmap[AW_R40_DEV_SDRAM], machine->ram);
- bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
- bpim2u_binfo.ram_size = machine->ram_size;
- bpim2u_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
- arm_load_kernel(&r40->cpus[0], machine, &bpim2u_binfo);
+ bpms->bootinfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
+ bpms->bootinfo.ram_size = machine->ram_size;
+ bpms->bootinfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
+ arm_load_kernel(&r40->cpus[0], machine, &bpms->bootinfo);
}
static void bpim2u_machine_init(MachineClass *mc)
@@ -145,4 +153,5 @@ static void bpim2u_machine_init(MachineClass *mc)
mc->auto_create_sdcard = true;
}
-DEFINE_MACHINE_ARM("bpim2u", bpim2u_machine_init)
+DEFINE_MACHINE_EXTENDED("bpim2u", MACHINE, Bpim2uMachineState,
+ bpim2u_machine_init, false, arm_machine_interfaces)