diff --git a/arch/x86/core/intel64/cpu.c b/arch/x86/core/intel64/cpu.c index f8f8c8a0482..212d5c41ade 100644 --- a/arch/x86/core/intel64/cpu.c +++ b/arch/x86/core/intel64/cpu.c @@ -18,7 +18,7 @@ __weak u8_t x86_cpu_loapics[] = { 0, 1, 2, 3 }; -extern FUNC_NORETURN void z_x86_prep_c(int, struct multiboot_info *); +extern FUNC_NORETURN void z_x86_prep_c(int dummy, struct multiboot_info *info); extern char x86_ap_start[]; /* AP entry point in locore.S */ @@ -110,4 +110,7 @@ void z_arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz, z_loapic_ipi(apic_id, LOAPIC_ICR_IPI_INIT, 0); k_busy_wait(10000); z_loapic_ipi(apic_id, LOAPIC_ICR_IPI_STARTUP, vector); + + while (x86_cpuboot[cpu_num].ready == 0) { + } } diff --git a/arch/x86/core/intel64/locore.S b/arch/x86/core/intel64/locore.S index 57a97088075..8fb9f9a214d 100644 --- a/arch/x86/core/intel64/locore.S +++ b/arch/x86/core/intel64/locore.S @@ -159,6 +159,7 @@ go64: movl %cr4, %eax /* enable PAE and SSE */ /* don't replace CALL with JMP; honor the ABI stack alignment! */ + incl __x86_cpuboot_t_ready_OFFSET(%rbp) movq __x86_cpuboot_t_arg_OFFSET(%rbp), %rsi call *__x86_cpuboot_t_fn_OFFSET(%rbp) /* enter kernel; never return */ diff --git a/arch/x86/core/offsets/intel64_offsets.c b/arch/x86/core/offsets/intel64_offsets.c index 34e2e4d0e05..0d2ca10380e 100644 --- a/arch/x86/core/offsets/intel64_offsets.c +++ b/arch/x86/core/offsets/intel64_offsets.c @@ -32,6 +32,7 @@ GEN_OFFSET_SYM(x86_tss64_t, ist1); GEN_OFFSET_SYM(x86_tss64_t, cpu); GEN_ABSOLUTE_SYM(__X86_TSS64_SIZEOF, sizeof(x86_tss64_t)); +GEN_OFFSET_SYM(x86_cpuboot_t, ready); GEN_OFFSET_SYM(x86_cpuboot_t, tr); GEN_OFFSET_SYM(x86_cpuboot_t, gs); GEN_OFFSET_SYM(x86_cpuboot_t, sp); diff --git a/arch/x86/include/intel64/kernel_arch_data.h b/arch/x86/include/intel64/kernel_arch_data.h index 42979c6a8d9..6885e956f95 100644 --- a/arch/x86/include/intel64/kernel_arch_data.h +++ b/arch/x86/include/intel64/kernel_arch_data.h @@ -83,6 +83,7 @@ typedef struct x86_tss64 x86_tss64_t; */ struct x86_cpuboot { + volatile int ready; /* CPU has started */ u16_t tr; /* selector for task register */ u16_t gs; /* selector for GS */ u64_t sp; /* initial stack pointer */