[PATCH 12/20] hw/arm: musicpal: 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 MusicPalMachineState 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/musicpal.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 69e83bdd97..158a3ccae4 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1200,13 +1200,18 @@ static const TypeInfo musicpal_key_info = {
#define FLASH_SECTOR_SIZE (64 * KiB)
-static struct arm_boot_info musicpal_binfo = {
- .loader_start = 0x0,
- .board_id = 0x20e,
+#define TYPE_MUSICPAL_MACHINE MACHINE_TYPE_NAME("musicpal")
+OBJECT_DECLARE_SIMPLE_TYPE(MusicPalMachineState, MUSICPAL_MACHINE)
+
+struct MusicPalMachineState {
+ MachineState parent;
+
+ struct arm_boot_info bootinfo;
};
static void musicpal_init(MachineState *machine)
{
+ MusicPalMachineState *mpms = MUSICPAL_MACHINE(machine);
ARMCPU *cpu;
DeviceState *dev;
DeviceState *pic;
@@ -1341,12 +1346,18 @@ static void musicpal_init(MachineState *machine)
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, qdev_get_gpio_in(pic, MP_AUDIO_IRQ));
- musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
- arm_load_kernel(cpu, machine, &musicpal_binfo);
+ mpms->bootinfo = (struct arm_boot_info) {
+ .loader_start = 0x0,
+ .board_id = 0x20e,
+ .ram_size = MP_RAM_DEFAULT_SIZE,
+ };
+ arm_load_kernel(cpu, machine, &mpms->bootinfo);
}
-static void musicpal_machine_init(MachineClass *mc)
+static void musicpal_machine_class_init(ObjectClass *oc, const void *data)
{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
mc->desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)";
mc->init = musicpal_init;
mc->ignore_memory_transaction_failures = true;
@@ -1357,7 +1368,13 @@ static void musicpal_machine_init(MachineClass *mc)
machine_add_audiodev_property(mc);
}
-DEFINE_MACHINE_ARM("musicpal", musicpal_machine_init)
+static const TypeInfo musicpal_machine_typeinfo = {
+ .name = TYPE_MUSICPAL_MACHINE,
+ .parent = TYPE_MACHINE,
+ .class_init = musicpal_machine_class_init,
+ .instance_size = sizeof(MusicPalMachineState),
+ .interfaces = arm_machine_interfaces,
+};
static void mv88w8618_wlan_class_init(ObjectClass *klass, const void *data)
{
@@ -1383,6 +1400,7 @@ static void musicpal_register_types(void)
type_register_static(&musicpal_gpio_info);
type_register_static(&musicpal_key_info);
type_register_static(&musicpal_misc_info);
+ type_register_static(&musicpal_machine_typeinfo);
}
type_init(musicpal_register_types)
--
2.53.0