[PATCH 03/20] hw/arm: bananapi_m2u: Store boot info in the machine state
Bin Meng <[email protected]>
| Newsgroups | org.nongnu.qemu-devel,org.nongnu.qemu-arm |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
---
hw/arm/bananapi_m2u.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
index 9b468cd8ac..4648d915ae 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,14 +128,16 @@ 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)
+static void bpim2u_machine_class_init(ObjectClass *oc, const void *data)
{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
static const char * const valid_cpu_types[] = {
ARM_CPU_TYPE_NAME("cortex-a7"),
NULL
@@ -145,4 +155,17 @@ static void bpim2u_machine_init(MachineClass *mc)
mc->auto_create_sdcard = true;
}
-DEFINE_MACHINE_ARM("bpim2u", bpim2u_machine_init)
+static const TypeInfo bpim2u_machine_typeinfo = {
+ .name = TYPE_BPIM2U_MACHINE,
+ .parent = TYPE_MACHINE,
+ .class_init = bpim2u_machine_class_init,
+ .instance_size = sizeof(Bpim2uMachineState),
+ .interfaces = arm_machine_interfaces,
+};
+
+static void bpim2u_machine_register_types(void)
+{
+ type_register_static(&bpim2u_machine_typeinfo);
+}
+
+type_init(bpim2u_machine_register_types)
--
2.53.0