QEMU-Arm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-arm@nongnu.org
Subject: [PATCH 11/20] hw/arm: mcimx7d-sabre: Store boot info in the machine state
Date: Thu, 13 Aug 2026 23:48:59 +0800	[thread overview]
Message-ID: <20260813154918.996812-12-bin.meng@processmission.com> (raw)
In-Reply-To: <20260813154918.996812-1-bin.meng@processmission.com>

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 function scoped static object.

Move it into a new Mcimx7dSabreMachineState 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>
---

 hw/arm/mcimx7d-sabre.c | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c
index a0ac647c3d..43d7916b08 100644
--- a/hw/arm/mcimx7d-sabre.c
+++ b/hw/arm/mcimx7d-sabre.c
@@ -22,9 +22,19 @@
 #include "qemu/error-report.h"
 #include "system/qtest.h"
 
+#define TYPE_MCIMX7D_SABRE_MACHINE MACHINE_TYPE_NAME("mcimx7d-sabre")
+OBJECT_DECLARE_SIMPLE_TYPE(Mcimx7dSabreMachineState,
+                           MCIMX7D_SABRE_MACHINE)
+
+struct Mcimx7dSabreMachineState {
+    MachineState parent;
+
+    struct arm_boot_info bootinfo;
+};
+
 static void mcimx7d_sabre_init(MachineState *machine)
 {
-    static struct arm_boot_info boot_info;
+    Mcimx7dSabreMachineState *msms = MCIMX7D_SABRE_MACHINE(machine);
     FslIMX7State *s;
     int i;
 
@@ -34,7 +44,7 @@ static void mcimx7d_sabre_init(MachineState *machine)
         exit(1);
     }
 
-    boot_info = (struct arm_boot_info) {
+    msms->bootinfo = (struct arm_boot_info) {
         .loader_start = FSL_IMX7_MMDC_ADDR,
         .board_id = -1,
         .ram_size = machine->ram_size,
@@ -65,12 +75,15 @@ static void mcimx7d_sabre_init(MachineState *machine)
     }
 
     if (!qtest_enabled()) {
-        arm_load_kernel(&s->cpu[0], machine, &boot_info);
+        arm_load_kernel(&s->cpu[0], machine, &msms->bootinfo);
     }
 }
 
-static void mcimx7d_sabre_machine_init(MachineClass *mc)
+static void mcimx7d_sabre_machine_class_init(ObjectClass *oc,
+                                             const void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Freescale i.MX7 DUAL SABRE (Cortex-A7)";
     mc->init = mcimx7d_sabre_init;
     mc->max_cpus = FSL_IMX7_NUM_CPUS;
@@ -78,4 +91,17 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE_ARM("mcimx7d-sabre", mcimx7d_sabre_machine_init)
+static const TypeInfo mcimx7d_sabre_machine_typeinfo = {
+    .name = TYPE_MCIMX7D_SABRE_MACHINE,
+    .parent = TYPE_MACHINE,
+    .class_init = mcimx7d_sabre_machine_class_init,
+    .instance_size = sizeof(Mcimx7dSabreMachineState),
+    .interfaces = arm_machine_interfaces,
+};
+
+static void mcimx7d_sabre_machine_register_types(void)
+{
+    type_register_static(&mcimx7d_sabre_machine_typeinfo);
+}
+
+type_init(mcimx7d_sabre_machine_register_types)
-- 
2.53.0



  parent reply	other threads:[~2026-08-13 15:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:48 [PATCH 00/20] hw/arm: Store the ARM boot info in the machine state Bin Meng
2026-08-13 15:48 ` [PATCH 01/20] hw/arm: aspeed: Store " Bin Meng
2026-08-13 15:48 ` [PATCH 02/20] hw/arm: aspeed_ast27x0-fc: " Bin Meng
2026-08-13 15:48 ` [PATCH 03/20] hw/arm: bananapi_m2u: " Bin Meng
2026-08-13 15:48 ` [PATCH 04/20] hw/arm: collie: " Bin Meng
2026-08-13 15:48 ` [PATCH 05/20] hw/arm: cubieboard: " Bin Meng
2026-08-13 15:48 ` [PATCH 06/20] hw/arm: exynos4_boards: Store boot info in the board state Bin Meng
2026-08-13 15:48 ` [PATCH 07/20] hw/arm: imx25_pdk: " Bin Meng
2026-08-13 15:48 ` [PATCH 08/20] hw/arm: imx8mm-evk: Store boot info in the machine state Bin Meng
2026-08-13 15:48 ` [PATCH 09/20] hw/arm: integratorcp: " Bin Meng
2026-08-13 15:48 ` [PATCH 10/20] hw/arm: kzm: Store boot info in the board state Bin Meng
2026-08-13 15:48 ` Bin Meng [this message]
2026-08-13 15:49 ` [PATCH 12/20] hw/arm: musicpal: Store boot info in the machine state Bin Meng
2026-08-13 15:49 ` [PATCH 13/20] hw/arm: npcm7xx: " Bin Meng
2026-08-13 15:49 ` [PATCH 14/20] hw/arm: npcm8xx: " Bin Meng
2026-08-13 15:49 ` [PATCH 15/20] hw/arm: omap_sx1: " Bin Meng
2026-08-13 15:49 ` [PATCH 16/20] hw/arm: orangepi: " Bin Meng
2026-08-13 21:10   ` Niek Linnenbank
2026-08-13 15:49 ` [PATCH 17/20] hw/arm: realview: " Bin Meng
2026-08-13 15:49 ` [PATCH 18/20] hw/arm: sabrelite: " Bin Meng
2026-08-13 15:49 ` [PATCH 19/20] hw/arm: versatilepb: " Bin Meng
2026-08-13 15:49 ` [PATCH 20/20] hw/arm: xilinx_zynq: " Bin Meng
2026-08-14 15:32   ` Alistair
2026-08-14  5:58 ` [PATCH 00/20] hw/arm: Store the ARM " Philippe Mathieu-Daudé
2026-08-15 15:06 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813154918.996812-12-bin.meng@processmission.com \
    --to=bin.meng@processmission.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox