@samitouri / QOSamiQemu / commits / 92fbe79cb0

hw/arm: npcm7xx: 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 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> Message-id: 20260816131300.51799-14-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 92fbe79cb0f5d0b72e88513205365448346d4e41
3 files changed +26 -22
hw/arm/npcm7xx.c
+13 -15
@@ -364,22 +364,20 @@ static void npcm7xx_write_secondary_boot(ARMCPU *cpu,
364 NPCM7XX_SMP_LOADER_START);
365 }
366
367 -static struct arm_boot_info npcm7xx_binfo = {
368 - .loader_start = NPCM7XX_LOADER_START,
369 - .smp_loader_start = NPCM7XX_SMP_LOADER_START,
370 - .smp_bootreg_addr = NPCM7XX_SMP_BOOTREG_ADDR,
371 - .gic_cpu_if_addr = NPCM7XX_GIC_CPU_IF_ADDR,
372 - .write_secondary_boot = npcm7xx_write_secondary_boot,
373 - .board_id = -1,
374 - .board_setup_addr = NPCM7XX_BOARD_SETUP_ADDR,
375 - .write_board_setup = npcm7xx_write_board_setup,
376 -};
377 -
378 -void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc)
367 +void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc,
368 + struct arm_boot_info *binfo)
369 {
380 - npcm7xx_binfo.ram_size = machine->ram_size;
381 -
382 - arm_load_kernel(&soc->cpu[0], machine, &npcm7xx_binfo);
370 + binfo->loader_start = NPCM7XX_LOADER_START;
371 + binfo->smp_loader_start = NPCM7XX_SMP_LOADER_START;
372 + binfo->smp_bootreg_addr = NPCM7XX_SMP_BOOTREG_ADDR;
373 + binfo->gic_cpu_if_addr = NPCM7XX_GIC_CPU_IF_ADDR;
374 + binfo->write_secondary_boot = npcm7xx_write_secondary_boot;
375 + binfo->board_id = -1;
376 + binfo->board_setup_addr = NPCM7XX_BOARD_SETUP_ADDR;
377 + binfo->write_board_setup = npcm7xx_write_board_setup;
378 + binfo->ram_size = machine->ram_size;
379 +
380 + arm_load_kernel(&soc->cpu[0], machine, binfo);
381 }
382
383 static void npcm7xx_init_fuses(NPCM7xxState *s)
hw/arm/npcm7xx_boards.c
+5 -5
@@ -374,7 +374,7 @@ static void npcm750_evb_init(MachineState *machine)
374 npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0));
375 npcm750_evb_i2c_init(soc);
376 npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc);
377 - npcm7xx_load_kernel(machine, soc);
377 + npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
378 }
379
380 static void quanta_gsj_init(MachineState *machine)
@@ -390,7 +390,7 @@ static void quanta_gsj_init(MachineState *machine)
390 drive_get(IF_MTD, 0, 0));
391 quanta_gsj_i2c_init(soc);
392 quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc);
393 - npcm7xx_load_kernel(machine, soc);
393 + npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
394 }
395
396 static void quanta_gbs_init(MachineState *machine)
@@ -408,7 +408,7 @@ static void quanta_gbs_init(MachineState *machine)
408
409 quanta_gbs_i2c_init(soc);
410 sdhci_attach_drive(&soc->mmc.sdhci, 0);
411 - npcm7xx_load_kernel(machine, soc);
411 + npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
412 }
413
414 static void kudo_bmc_init(MachineState *machine)
@@ -427,7 +427,7 @@ static void kudo_bmc_init(MachineState *machine)
427
428 kudo_bmc_i2c_init(soc);
429 sdhci_attach_drive(&soc->mmc.sdhci, 0);
430 - npcm7xx_load_kernel(machine, soc);
430 + npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
431 }
432
433 static void mori_bmc_init(MachineState *machine)
@@ -442,7 +442,7 @@ static void mori_bmc_init(MachineState *machine)
442 npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f",
443 drive_get(IF_MTD, 3, 0));
444
445 - npcm7xx_load_kernel(machine, soc);
445 + npcm7xx_load_kernel(machine, soc, &NPCM7XX_MACHINE(machine)->bootinfo);
446 }
447
448 static void npcm7xx_set_soc_type(NPCM7xxMachineClass *nmc, const char *type)
include/hw/arm/npcm7xx.h
+8 -2
@@ -19,6 +19,7 @@
19 #include "hw/core/boards.h"
20 #include "hw/adc/npcm7xx_adc.h"
21 #include "hw/core/split-irq.h"
22 +#include "hw/arm/boot.h"
23 #include "hw/cpu/a9mpcore.h"
24 #include "hw/gpio/npcm7xx_gpio.h"
25 #include "hw/i2c/npcm7xx_smbus.h"
@@ -62,6 +63,7 @@ struct NPCM7xxMachine {
63 */
64 SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
65 NPCM7XX_PWM_PER_MODULE];
66 + struct arm_boot_info bootinfo;
67 };
68
69 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
@@ -129,11 +131,15 @@ typedef struct NPCM7xxClass {
131 * npcm7xx_load_kernel - Loads memory with everything needed to boot
132 * @machine - The machine containing the SoC to be booted.
133 * @soc - The SoC containing the CPU to be booted.
134 + * @binfo - Caller owned boot info structure to be filled in.
135 *
136 * This will set up the ARM boot info structure for the specific NPCM7xx
137 * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
135 - * into memory, if requested by the user.
138 + * into memory, if requested by the user. The boot info is owned by the
139 + * caller because arm_load_kernel() keeps a pointer to it for the lifetime
140 + * of the CPUs.
141 */
137 -void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc);
142 +void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc,
143 + struct arm_boot_info *binfo);
144
145 #endif /* NPCM7XX_H */