This patch introduces the ppc_set_vcpu_dt_id() function. It is currently empty but it will be used to generate cpu_dt_id out of a cpu_index provided by the machine.
It also changes the machine types to provide cpu_index. Since all of them keep the cpus in an array, cpu_index is simply the index in the array. The only exception is pseries-2.7 which supports hotplug of cpu cores and already open codes the cpu creation. Its case will be covered in follow-up patch. Suggested-by: Igor Mammedov <imamm...@redhat.com> Signed-off-by: Greg Kurz <gr...@kaod.org> --- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/ppc.c | 12 +++++++++++- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/ppc/ppc.h | 2 +- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index ff5d92e48dd9..461dcdc031b0 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -821,7 +821,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) CPUState *cs; qemu_irq *input; - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 6ab675c498d0..888f448796e7 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -193,7 +193,7 @@ static void ppc_core99_init(MachineState *machine) #endif } for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 77fbdfffd4e2..ceb92f820dde 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -113,7 +113,7 @@ static void ppc_heathrow_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 57f4ddd073d0..dbc8ac7b3a9b 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1352,7 +1352,12 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) return NULL; } -PowerPCCPU *ppc_cpu_init(const char *cpu_model) +static void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp) +{ + ; +} + +PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index) { PowerPCCPU *cpu; CPUClass *cc; @@ -1374,6 +1379,11 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model) cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); + ppc_set_vcpu_dt_id(cpu, cpu_index, &err); + if (err != NULL) { + goto out; + } + cc = CPU_CLASS(oc); cc->parse_features(CPU(cpu), model_pieces[1], &err); g_strfreev(model_pieces); diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 7f22433c8e91..86c453542a94 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -186,7 +186,7 @@ static void bamboo_init(MachineState *machine) if (machine->cpu_model == NULL) { machine->cpu_model = "440EP"; } - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index e62fe643f492..d81d0675255e 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -509,7 +509,7 @@ static void ppc_prep_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { - cpu = ppc_cpu_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 690ee486aa07..57dbac2106d2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1828,7 +1828,7 @@ static void ppc_spapr_init(MachineState *machine) g_free(type); } else { for (i = 0; i < smp_cpus; i++) { - PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model); + PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model, i); if (cpu == NULL) { error_report("Unable to find PowerPC CPU definition"); exit(1); diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index a4db1db82e1b..647451c9b6ac 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -106,5 +106,5 @@ enum { /* ppc_booke.c */ void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); -PowerPCCPU *ppc_cpu_init(const char *cpu_model); +PowerPCCPU *ppc_cpu_init(const char *cpu_model, int cpu_index); #endif