All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Hao Wu <wuhaotsh@google.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Tyrone Ting <kfting@nuvoton.com>,
	qemu-arm@nongnu.org
Subject: [PATCH v2 13/20] hw/arm: npcm7xx: Store boot info in the machine state
Date: Sun, 16 Aug 2026 21:12:43 +0800	[thread overview]
Message-ID: <20260816131300.51799-14-bin.meng@processmission.com> (raw)
In-Reply-To: <20260816131300.51799-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 file scoped static object inside
npcm7xx_load_kernel().

Let the caller own the boot info: the boards store it in their
NPCM7xxMachine and pass it to npcm7xx_load_kernel(), which only fills
in the SoC specific values.

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/npcm7xx.c         | 28 +++++++++++++---------------
 hw/arm/npcm7xx_boards.c  | 10 +++++-----
 include/hw/arm/npcm7xx.h | 10 ++++++++--
 3 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index c27f149c04..695f30a0dc 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -364,22 +364,20 @@ static void npcm7xx_write_secondary_boot(ARMCPU *cpu,
                        NPCM7XX_SMP_LOADER_START);
 }
 
-static struct arm_boot_info npcm7xx_binfo = {
-    .loader_start           = NPCM7XX_LOADER_START,
-    .smp_loader_start       = NPCM7XX_SMP_LOADER_START,
-    .smp_bootreg_addr       = NPCM7XX_SMP_BOOTREG_ADDR,
-    .gic_cpu_if_addr        = NPCM7XX_GIC_CPU_IF_ADDR,
-    .write_secondary_boot   = npcm7xx_write_secondary_boot,
-    .board_id               = -1,
-    .board_setup_addr       = NPCM7XX_BOARD_SETUP_ADDR,
-    .write_board_setup      = npcm7xx_write_board_setup,
-};
-
-void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc)
+void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc,
+                         struct arm_boot_info *binfo)
 {
-    npcm7xx_binfo.ram_size = machine->ram_size;
-
-    arm_load_kernel(&soc->cpu[0], machine, &npcm7xx_binfo);
+    binfo->loader_start = NPCM7XX_LOADER_START;
+    binfo->smp_loader_start = NPCM7XX_SMP_LOADER_START;
+    binfo->smp_bootreg_addr = NPCM7XX_SMP_BOOTREG_ADDR;
+    binfo->gic_cpu_if_addr = NPCM7XX_GIC_CPU_IF_ADDR;
+    binfo->write_secondary_boot = npcm7xx_write_secondary_boot;
+    binfo->board_id = -1;
+    binfo->board_setup_addr = NPCM7XX_BOARD_SETUP_ADDR;
+    binfo->write_board_setup = npcm7xx_write_board_setup;
+    binfo->ram_size = machine->ram_size;
+
+    arm_load_kernel(&soc->cpu[0], machine, binfo);
 }
 
 static void npcm7xx_init_fuses(NPCM7xxState *s)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 57a8d3186e..4f14d25746 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -374,7 +374,7 @@ static void npcm750_evb_init(MachineState *machine)
     npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0));
     npcm750_evb_i2c_init(soc);
     npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc);
-    npcm7xx_load_kernel(machine, soc);
+    npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
 }
 
 static void quanta_gsj_init(MachineState *machine)
@@ -390,7 +390,7 @@ static void quanta_gsj_init(MachineState *machine)
                           drive_get(IF_MTD, 0, 0));
     quanta_gsj_i2c_init(soc);
     quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc);
-    npcm7xx_load_kernel(machine, soc);
+    npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
 }
 
 static void quanta_gbs_init(MachineState *machine)
@@ -408,7 +408,7 @@ static void quanta_gbs_init(MachineState *machine)
 
     quanta_gbs_i2c_init(soc);
     sdhci_attach_drive(&soc->mmc.sdhci, 0);
-    npcm7xx_load_kernel(machine, soc);
+    npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
 }
 
 static void kudo_bmc_init(MachineState *machine)
@@ -427,7 +427,7 @@ static void kudo_bmc_init(MachineState *machine)
 
     kudo_bmc_i2c_init(soc);
     sdhci_attach_drive(&soc->mmc.sdhci, 0);
-    npcm7xx_load_kernel(machine, soc);
+    npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
 }
 
 static void mori_bmc_init(MachineState *machine)
@@ -442,7 +442,7 @@ static void mori_bmc_init(MachineState *machine)
     npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f",
                           drive_get(IF_MTD, 3, 0));
 
-    npcm7xx_load_kernel(machine, soc);
+    npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
 }
 
 static void npcm7xx_set_soc_type(NPCM7xxMachineClass *nmc, const char *type)
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
index eef7cc5332..9f3dd489ec 100644
--- a/include/hw/arm/npcm7xx.h
+++ b/include/hw/arm/npcm7xx.h
@@ -19,6 +19,7 @@
 #include "hw/core/boards.h"
 #include "hw/adc/npcm7xx_adc.h"
 #include "hw/core/split-irq.h"
+#include "hw/arm/boot.h"
 #include "hw/cpu/a9mpcore.h"
 #include "hw/gpio/npcm7xx_gpio.h"
 #include "hw/i2c/npcm7xx_smbus.h"
@@ -62,6 +63,7 @@ struct NPCM7xxMachine {
      */
     SplitIRQ            fan_splitter[NPCM7XX_NR_PWM_MODULES *
                                      NPCM7XX_PWM_PER_MODULE];
+    struct arm_boot_info bootinfo;
 };
 
 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
@@ -129,11 +131,15 @@ typedef struct NPCM7xxClass {
  * npcm7xx_load_kernel - Loads memory with everything needed to boot
  * @machine - The machine containing the SoC to be booted.
  * @soc - The SoC containing the CPU to be booted.
+ * @binfo - Caller owned boot info structure to be filled in.
  *
  * This will set up the ARM boot info structure for the specific NPCM7xx
  * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
- * into memory, if requested by the user.
+ * into memory, if requested by the user.  The boot info is owned by the
+ * caller because arm_load_kernel() keeps a pointer to it for the lifetime
+ * of the CPUs.
  */
-void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc);
+void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc,
+                         struct arm_boot_info *binfo);
 
 #endif /* NPCM7XX_H */
-- 
2.53.0



  parent reply	other threads:[~2026-08-16 13:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 13:12 [PATCH v2 00/20] hw/arm: Store the ARM boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 01/20] hw/arm: aspeed: Store " Bin Meng
2026-08-16 14:54   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 02/20] hw/arm: aspeed_ast27x0-fc: " Bin Meng
2026-08-16 14:55   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 03/20] hw/arm: bananapi_m2u: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 04/20] hw/arm: collie: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 05/20] hw/arm: cubieboard: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 06/20] hw/arm: exynos4_boards: Store boot info in the board state Bin Meng
2026-08-16 14:56   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 07/20] hw/arm: imx25_pdk: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 08/20] hw/arm: imx8mm-evk: Store boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 09/20] hw/arm: integratorcp: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 10/20] hw/arm: kzm: Store boot info in the board state Bin Meng
2026-08-16 13:12 ` [PATCH v2 11/20] hw/arm: mcimx7d-sabre: Store boot info in the machine state Bin Meng
2026-08-16 13:12 ` [PATCH v2 12/20] hw/arm: musicpal: " Bin Meng
2026-08-16 13:12 ` Bin Meng [this message]
2026-08-16 13:12 ` [PATCH v2 14/20] hw/arm: npcm8xx: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 15/20] hw/arm: omap_sx1: " Bin Meng
2026-08-16 14:57   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 16/20] hw/arm: orangepi: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 17/20] hw/arm: realview: " Bin Meng
2026-08-16 13:12 ` [PATCH v2 18/20] hw/arm: sabrelite: " Bin Meng
2026-08-16 15:07   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 19/20] hw/arm: versatilepb: " Bin Meng
2026-08-16 15:06   ` Philippe Mathieu-Daudé
2026-08-16 13:12 ` [PATCH v2 20/20] hw/arm: xilinx_zynq: " Bin Meng

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=20260816131300.51799-14-bin.meng@processmission.com \
    --to=bin.meng@processmission.com \
    --cc=kfting@nuvoton.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wuhaotsh@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.