diff --git a/arch/x86/core/ia32.cmake b/arch/x86/core/ia32.cmake index 419edb8e56a..99b57ef4a6c 100644 --- a/arch/x86/core/ia32.cmake +++ b/arch/x86/core/ia32.cmake @@ -19,6 +19,7 @@ zephyr_library_sources( ia32/swap.S ia32/thread.c ia32/spec_ctrl.c + ia32/prep_c.c ) zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD ia32/irq_offload.c) diff --git a/arch/x86/core/ia32/crt0.S b/arch/x86/core/ia32/crt0.S index 8535587f5f8..fb65654e184 100644 --- a/arch/x86/core/ia32/crt0.S +++ b/arch/x86/core/ia32/crt0.S @@ -23,7 +23,7 @@ GTEXT(z_x86_enable_paging) /* externs */ - GTEXT(z_cstart) + GTEXT(z_x86_prep_c) GDATA(_idt_base_address) GDATA(_interrupt_stack) @@ -308,10 +308,8 @@ __csSet: outb %al, $0xA1 /* set i8259 slave mask (IRQs 8-15) */ #endif - /* Jump to C portion of kernel initialization and never return */ - - jmp z_cstart - + /* call C portion of kernel initialization and never return */ + call z_x86_prep_c _x86_bss_zero: /* ECX = size, EDI = starting address */ diff --git a/arch/x86/core/ia32/prep_c.c b/arch/x86/core/ia32/prep_c.c new file mode 100644 index 00000000000..b63c2778cc8 --- /dev/null +++ b/arch/x86/core/ia32/prep_c.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +FUNC_NORETURN void z_x86_prep_c(void) +{ + _kernel.nested = 0; + _kernel.irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) + + CONFIG_ISR_STACK_SIZE; + +#ifdef CONFIG_X86_VERY_EARLY_CONSOLE + z_x86_early_serial_init(); +#endif +#ifdef CONFIG_X86_MMU + z_x86_paging_init(); +#endif +#if CONFIG_X86_STACK_PROTECTION + z_x86_mmu_set_flags(&z_x86_kernel_pdpt, _interrupt_stack, MMU_PAGE_SIZE, + MMU_ENTRY_READ, MMU_PTE_RW_MASK, true); +#endif + + z_cstart(); +} diff --git a/arch/x86/include/ia32/kernel_arch_func.h b/arch/x86/include/ia32/kernel_arch_func.h index b49d2adff74..574c441fdb9 100644 --- a/arch/x86/include/ia32/kernel_arch_func.h +++ b/arch/x86/include/ia32/kernel_arch_func.h @@ -43,20 +43,7 @@ void z_x86_paging_init(void); */ static inline void kernel_arch_init(void) { - _kernel.nested = 0; - _kernel.irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) + - CONFIG_ISR_STACK_SIZE; - -#ifdef CONFIG_X86_VERY_EARLY_CONSOLE - z_x86_early_serial_init(); -#endif -#ifdef CONFIG_X86_MMU - z_x86_paging_init(); -#endif -#if CONFIG_X86_STACK_PROTECTION - z_x86_mmu_set_flags(&z_x86_kernel_pdpt, _interrupt_stack, MMU_PAGE_SIZE, - MMU_ENTRY_READ, MMU_PTE_RW_MASK, true); -#endif + /* No-op on this arch */ } /**