diff mbox series

[RFC,14/16] hw/arm: move shared bootinfo member to ArmMachine

Message ID 1581925888-103620-15-git-send-email-xuyandong2@huawei.com
State New
Headers show
Series Implement Microvm for aarch64 architecture | expand

Commit Message

Xu Yandong Feb. 17, 2020, 7:51 a.m. UTC
Move bootinfo member from VirtMachineState to ArmMachineState.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
 hw/arm/arm.c          |  9 +++++++++
 hw/arm/virt.c         | 28 +++++++++-------------------
 include/hw/arm/arm.h  |  3 +++
 include/hw/arm/virt.h |  1 -
 4 files changed, 21 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/hw/arm/arm.c b/hw/arm/arm.c
index 4bffee0f37..7d880dd8e7 100644
--- a/hw/arm/arm.c
+++ b/hw/arm/arm.c
@@ -508,6 +508,15 @@  void create_virtio_devices(const ArmMachineState *ams)
     }
 }
 
+void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
+{
+    const ArmMachineState *board = container_of(binfo, ArmMachineState,
+                                                 bootinfo);
+
+    *fdt_size = board->fdt_size;
+    return board->fdt;
+}
+
 static char *virt_get_gic_version(Object *obj, Error **errp)
 {
     ArmMachineState *ams = ARM_MACHINE(obj);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 11e753906b..2f498ea687 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -971,16 +971,6 @@  static void create_secure_ram(VirtMachineState *vms,
     g_free(nodename);
 }
 
-static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
-{
-    const VirtMachineState *vms = container_of(binfo, VirtMachineState,
-                                                 bootinfo);
-
-    ArmMachineState *board = ARM_MACHINE(vms);
-    *fdt_size = board->fdt_size;
-    return board->fdt;
-}
-
 static void virt_build_smbios(VirtMachineState *vms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(vms);
@@ -1016,7 +1006,7 @@  void virt_machine_done(Notifier *notifier, void *data)
     MachineState *ms = MACHINE(vms);
     ArmMachineState *ams = ARM_MACHINE(vms);
     ARMCPU *cpu = ARM_CPU(first_cpu);
-    struct arm_boot_info *info = &vms->bootinfo;
+    struct arm_boot_info *info = &ams->bootinfo;
     AddressSpace *as = arm_boot_address_space(cpu, info);
 
     /*
@@ -1373,14 +1363,14 @@  static void machvirt_init(MachineState *machine)
 
     create_platform_bus(vms);
 
-    vms->bootinfo.ram_size = machine->ram_size;
-    vms->bootinfo.nb_cpus = smp_cpus;
-    vms->bootinfo.board_id = -1;
-    vms->bootinfo.loader_start = ams->memmap[VIRT_MEM].base;
-    vms->bootinfo.get_dtb = machvirt_dtb;
-    vms->bootinfo.skip_dtb_autoload = true;
-    vms->bootinfo.firmware_loaded = firmware_loaded;
-    arm_load_kernel(ARM_CPU(first_cpu), machine, &vms->bootinfo);
+    ams->bootinfo.ram_size = machine->ram_size;
+    ams->bootinfo.nb_cpus = smp_cpus;
+    ams->bootinfo.board_id = -1;
+    ams->bootinfo.loader_start = ams->memmap[VIRT_MEM].base;
+    ams->bootinfo.get_dtb = machvirt_dtb;
+    ams->bootinfo.skip_dtb_autoload = true;
+    ams->bootinfo.firmware_loaded = firmware_loaded;
+    arm_load_kernel(ARM_CPU(first_cpu), machine, &ams->bootinfo);
 
     vms->machine_done.notify = virt_machine_done;
     qemu_add_machine_init_done_notifier(&vms->machine_done);
diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
index 743a90ba36..372f4dea28 100644
--- a/include/hw/arm/arm.h
+++ b/include/hw/arm/arm.h
@@ -92,6 +92,7 @@  typedef struct {
 typedef struct {
     MachineState parent;
     int32_t gic_version;
+    struct arm_boot_info bootinfo;
     MemMapEntry *memmap;
     const int *irqmap;
     int smp_cpus;
@@ -130,6 +131,8 @@  void create_rtc(const ArmMachineState *ams);
 
 void create_virtio_devices(const ArmMachineState *ams);
 
+void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size);
+
 /* Return the number of used redistributor regions  */
 static inline int virt_gicv3_redist_region_count(ArmMachineState *ams)
 {
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 086a27682f..8276e2c02c 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -68,7 +68,6 @@  typedef struct {
     bool its;
     bool virt;
     VirtIOMMUType iommu;
-    struct arm_boot_info bootinfo;
     uint32_t msi_phandle;
     uint32_t iommu_phandle;
     hwaddr highest_gpa;