diff options
-rw-r--r-- | hw/pc.c | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -1062,6 +1062,25 @@ int cpu_is_bsp(CPUState *env) return env->cpuid_apic_id == 0; } +static CPUState *pc_new_cpu(const char *cpu_model) +{ + CPUState *env; + + env = cpu_init(cpu_model); + if (!env) { + fprintf(stderr, "Unable to find x86 CPU definition\n"); + exit(1); + } + if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { + env->cpuid_apic_id = env->cpu_index; + /* APIC reset callback resets cpu */ + apic_init(env); + } else { + qemu_register_reset((QEMUResetHandler*)cpu_reset, env); + } + return env; +} + /* PC hardware initialisation */ static void pc_init1(ram_addr_t ram_size, const char *boot_device, @@ -1103,20 +1122,9 @@ static void pc_init1(ram_addr_t ram_size, cpu_model = "qemu32"; #endif } - - for(i = 0; i < smp_cpus; i++) { - env = cpu_init(cpu_model); - if (!env) { - fprintf(stderr, "Unable to find x86 CPU definition\n"); - exit(1); - } - if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { - env->cpuid_apic_id = env->cpu_index; - /* APIC reset callback resets cpu */ - apic_init(env); - } else { - qemu_register_reset((QEMUResetHandler*)cpu_reset, env); - } + + for (i = 0; i < smp_cpus; i++) { + env = pc_new_cpu(cpu_model); } vmport_init(); |