[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 03/19] hw/mips/malta: Keep reference of vCPUs in MaltaState
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 03/19] hw/mips/malta: Keep reference of vCPUs in MaltaState |
Date: |
Mon, 13 Jan 2025 20:55:09 +0100 |
When a QOM object create children with object_new(),
it is better to keep reference to them for further
use. This will be helpful to remove &first_cpu uses
in few commits.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/malta.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 37be2330eda..090c2514354 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -107,6 +107,7 @@ struct MaltaState {
SysBusDevice parent_obj;
Clock *cpuclk;
+ MIPSCPU **cpus;
MIPSCPSState cps;
};
@@ -1037,6 +1038,7 @@ static void create_cpu_without_cps(MachineState *ms,
MaltaState *s,
for (i = 0; i < ms->smp.cpus; i++) {
cpu = mips_cpu_create_with_clock(ms->cpu_type, s->cpuclk,
TARGET_BIG_ENDIAN);
+ s->cpus[i] = cpu;
/* Init internal devices */
cpu_mips_irq_init_cpu(cpu);
@@ -1063,6 +1065,7 @@ static void create_cps(MachineState *ms, MaltaState *s,
&error_fatal);
qdev_connect_clock_in(DEVICE(&s->cps), "clk-in", s->cpuclk);
sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
+ memcpy(s->cpus, s->cps.cpus, ms->smp.cpus * sizeof(MIPSCPU *));
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
@@ -1070,9 +1073,11 @@ static void create_cps(MachineState *ms, MaltaState *s,
*cbus_irq = NULL;
}
-static void mips_create_cpu(MachineState *ms, MaltaState *s,
- qemu_irq *cbus_irq, qemu_irq *i8259_irq)
+/* Initialize MaltaState::cpus[] */
+static void mips_create_cpus(MachineState *ms, MaltaState *s,
+ qemu_irq *cbus_irq, qemu_irq *i8259_irq)
{
+ s->cpus = g_new(MIPSCPU *, ms->smp.cpus);
if ((ms->smp.cpus > 1) && cpu_type_supports_cps_smp(ms->cpu_type)) {
create_cps(ms, s, cbus_irq, i8259_irq);
} else {
@@ -1111,7 +1116,7 @@ void mips_malta_init(MachineState *machine)
sysbus_realize_and_unref(SYS_BUS_DEVICE(s), &error_fatal);
/* create CPU */
- mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
+ mips_create_cpus(machine, s, &cbus_irq, &i8259_irq);
/* allocate RAM */
if (ram_size > 2 * GiB) {
--
2.47.1
- [PATCH v2 00/19] hw/mips: Remove all uses of &first_cpu, Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 01/19] hw/mips/cps: Keep reference of vCPUs in MIPSCPSState, Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 02/19] hw/mips/malta: Check CPU index instead of using &first_cpu, Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 03/19] hw/mips/malta: Keep reference of vCPUs in MaltaState,
Philippe Mathieu-Daudé <=
- [PATCH v2 04/19] hw/mips/malta: Propagate MaltaState to write_bootloader(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 05/19] hw/mips/malta: Propagate MaltaState to bl_setup_gt64120_jump_kernel(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 06/19] hw/mips/boston: Replace bl_gen_write_ulong() -> bl_gen_write_u64(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 07/19] hw/mips/boston: Propagate CPU to gen_firmware(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 08/19] hw/mips/fuloong: Propagate CPU to write_bootloader(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 09/19] hw/mips/bootloader: Document public API, Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 11/19] hw/mips/bootloader: Propagate CPU to bl_gen_jump_[to, kernel](), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 12/19] hw/mips/bootloader: Propagate CPU env to bl_gen_load_ulong(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 13/19] hw/mips/bootloader: Propagate CPU env to bl_gen_[d]li(), Philippe Mathieu-Daudé, 2025/01/13
- [PATCH v2 14/19] hw/mips/bootloader: Propagate CPU env to bl_gen_s[w, d](), Philippe Mathieu-Daudé, 2025/01/13