@samitouri / QOSamiQemu / commits / 244b542695

hw/arm: npcm8xx: Store boot info in the machine state

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 npcm8xx_load_kernel(). Let the caller own the boot info: the board stores it in its NPCM8xxMachine and passes it to npcm8xx_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> Message-id: 20260816131300.51799-15-bin.meng@processmission.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Bin Meng committed Aug 16, 2026 at 21:12 UTC 244b54269530468b93b4bc3676f044f3da46ea15
3 files changed +22 -18
hw/arm/npcm8xx.c
+13 -15
@@ -357,22 +357,20 @@ static const struct {
357 },
358 };
359
360 -static struct arm_boot_info npcm8xx_binfo = {
361 - .loader_start = NPCM8XX_LOADER_START,
362 - .smp_loader_start = NPCM8XX_SMP_LOADER_START,
363 - .smp_bootreg_addr = NPCM8XX_SMP_BOOTREG_ADDR,
364 - .gic_cpu_if_addr = NPCM8XX_GICC_BA,
365 - .secure_boot = false,
366 - .board_id = -1,
367 - .board_setup_addr = NPCM8XX_BOARD_SETUP_ADDR,
368 - .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
369 -};
370 -
371 -void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc)
360 +void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc,
361 + struct arm_boot_info *binfo)
362 {
373 - npcm8xx_binfo.ram_size = machine->ram_size;
374 -
375 - arm_load_kernel(&soc->cpu[0], machine, &npcm8xx_binfo);
363 + binfo->loader_start = NPCM8XX_LOADER_START;
364 + binfo->smp_loader_start = NPCM8XX_SMP_LOADER_START;
365 + binfo->smp_bootreg_addr = NPCM8XX_SMP_BOOTREG_ADDR;
366 + binfo->gic_cpu_if_addr = NPCM8XX_GICC_BA;
367 + binfo->secure_boot = false;
368 + binfo->board_id = -1;
369 + binfo->board_setup_addr = NPCM8XX_BOARD_SETUP_ADDR;
370 + binfo->psci_conduit = QEMU_PSCI_CONDUIT_SMC;
371 + binfo->ram_size = machine->ram_size;
372 +
373 + arm_load_kernel(&soc->cpu[0], machine, binfo);
374 }
375
376 static void npcm8xx_init_fuses(NPCM8xxState *s)
hw/arm/npcm8xx_boards.c
+1 -1
@@ -198,7 +198,7 @@ static void npcm845_evb_init(MachineState *machine)
198 npcm8xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0));
199 npcm845_evb_i2c_init(soc);
200 npcm845_evb_fan_init(NPCM8XX_MACHINE(machine), soc);
201 - npcm8xx_load_kernel(machine, soc);
201 + npcm8xx_load_kernel(machine, soc, &NPCM8XX_MACHINE(machine)->bootinfo);
202 }
203
204 static void npcm8xx_set_soc_type(NPCM8xxMachineClass *nmc, const char *type)
include/hw/arm/npcm8xx.h
+8 -2
@@ -23,6 +23,7 @@
23 #include "hw/i2c/npcm7xx_smbus.h"
24 #include "hw/intc/arm_gic_common.h"
25 #include "hw/mem/npcm7xx_mc.h"
26 +#include "hw/arm/boot.h"
27 #include "hw/misc/npcm_clk.h"
28 #include "hw/misc/npcm_gcr.h"
29 #include "hw/misc/npcm7xx_mft.h"
@@ -62,6 +63,7 @@ struct NPCM8xxMachine {
63 */
64 SplitIRQ fan_splitter[NPCM8XX_NR_PWM_MODULES *
65 NPCM7XX_PWM_PER_MODULE];
66 + struct arm_boot_info bootinfo;
67 };
68
69
@@ -122,11 +124,15 @@ OBJECT_DECLARE_TYPE(NPCM8xxState, NPCM8xxClass, NPCM8XX)
124 * npcm8xx_load_kernel - Loads memory with everything needed to boot
125 * @machine - The machine containing the SoC to be booted.
126 * @soc - The SoC containing the CPU to be booted.
127 + * @binfo - Caller owned boot info structure to be filled in.
128 *
129 * This will set up the ARM boot info structure for the specific NPCM8xx
130 * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
128 - * into memory, if requested by the user.
131 + * into memory, if requested by the user. The boot info is owned by the
132 + * caller because arm_load_kernel() keeps a pointer to it for the lifetime
133 + * of the CPUs.
134 */
130 -void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc);
135 +void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc,
136 + struct arm_boot_info *binfo);
137
138 #endif /* NPCM8XX_H */