From 8279af76c81b69585aaf67d03d2c801b62e3355e Mon Sep 17 00:00:00 2001 From: "Charles E. Youse" Date: Sat, 28 Sep 2019 14:25:13 -0400 Subject: [PATCH] arch/x86: elevate prep_c.c to common code Elevate the previously 32-bit-only z_x86_prep_c() function to common code, so both 32-bit and 64-bit arches now enter the kernel this way. Minor changes to prep_c.c to make it build with the SMP scheduler on. Signed-off-by: Charles E. Youse --- arch/x86/core/CMakeLists.txt | 1 + arch/x86/core/ia32.cmake | 1 - arch/x86/core/intel64/locore.S | 17 ++--------------- arch/x86/core/offsets/offsets.c | 4 ---- arch/x86/core/{ia32 => }/prep_c.c | 8 +++++--- 5 files changed, 8 insertions(+), 23 deletions(-) rename arch/x86/core/{ia32 => }/prep_c.c (79%) diff --git a/arch/x86/core/CMakeLists.txt b/arch/x86/core/CMakeLists.txt index 95ae9eb30a7..97e360c4b24 100644 --- a/arch/x86/core/CMakeLists.txt +++ b/arch/x86/core/CMakeLists.txt @@ -9,6 +9,7 @@ endif () zephyr_library_sources(cpuhalt.c) zephyr_library_sources(memmap.c) +zephyr_library_sources(prep_c.c) zephyr_library_sources_if_kconfig(pcie.c) zephyr_library_sources_if_kconfig(reboot_rst_cnt.c) diff --git a/arch/x86/core/ia32.cmake b/arch/x86/core/ia32.cmake index c95e37ba4c3..4954a1d0df0 100644 --- a/arch/x86/core/ia32.cmake +++ b/arch/x86/core/ia32.cmake @@ -18,7 +18,6 @@ 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/intel64/locore.S b/arch/x86/core/intel64/locore.S index 42e1136a722..7440d7cc2df 100644 --- a/arch/x86/core/intel64/locore.S +++ b/arch/x86/core/intel64/locore.S @@ -108,20 +108,6 @@ __start: rep stosq #endif -#ifdef CONFIG_MULTIBOOT_INFO - /* If EBX isn't 0, then we have a valid multiboot info struct. */ - - testl %ebx, %ebx - jz 1f - movl %ebx, %esi - - movl $__MULTIBOOT_INFO_SIZEOF, %ecx - movq $multiboot_info, %rdi - rep - movsb -1: -#endif /* CONFIG_MULTIBOOT_INFO */ - /* * set up SSE in case something uses the floating-point unit during * early initialization (either directly, or if GCC gets clever) @@ -132,7 +118,8 @@ __start: /* don't replace CALL with JMP; honor the ABI stack alignment! */ - call z_cstart + movl %ebx, %edi /* multiboot pointer (or NULL) */ + call z_x86_prep_c /* enter kernel; never returns */ stop: jmp stop diff --git a/arch/x86/core/offsets/offsets.c b/arch/x86/core/offsets/offsets.c index 42f683687a7..0cd81ac7f0c 100644 --- a/arch/x86/core/offsets/offsets.c +++ b/arch/x86/core/offsets/offsets.c @@ -16,8 +16,4 @@ GEN_OFFSET_SYM(_thread_arch_t, flags); -/* size of struct multiboot_info, used by crt0.S/locore.S */ - -GEN_ABSOLUTE_SYM(__MULTIBOOT_INFO_SIZEOF, sizeof(struct multiboot_info)); - GEN_ABS_SYM_END diff --git a/arch/x86/core/ia32/prep_c.c b/arch/x86/core/prep_c.c similarity index 79% rename from arch/x86/core/ia32/prep_c.c rename to arch/x86/core/prep_c.c index 3e5093fc0fe..6c3b22e5f46 100644 --- a/arch/x86/core/ia32/prep_c.c +++ b/arch/x86/core/prep_c.c @@ -8,11 +8,13 @@ #include #include +extern FUNC_NORETURN void z_cstart(void); + FUNC_NORETURN void z_x86_prep_c(struct multiboot_info *info) { - _kernel.nested = 0; - _kernel.irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) + - CONFIG_ISR_STACK_SIZE; + _kernel.cpus[0].nested = 0; + _kernel.cpus[0].irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) + + CONFIG_ISR_STACK_SIZE; #ifdef CONFIG_X86_VERY_EARLY_CONSOLE z_x86_early_serial_init();