Skip to content
Permalink
Browse files

x86: add prep_c function

Assembly language start code will enter here, which sets up
early kernel initialization and then calls z_cstart() when
finished.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information...
andrewboie committed Aug 5, 2019
1 parent c3b3aaf commit 02629b69b5f9481d9bb4c2061adb388d2bcc5ce2
Showing with 32 additions and 19 deletions.
  1. +1 −0 arch/x86/core/ia32.cmake
  2. +3 −5 arch/x86/core/ia32/crt0.S
  3. +27 −0 arch/x86/core/ia32/prep_c.c
  4. +1 −14 arch/x86/include/ia32/kernel_arch_func.h
@@ -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)
@@ -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 */
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <kernel_structs.h>

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();
}
@@ -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 */
}

/**

0 comments on commit 02629b6

Please sign in to comment.
You can’t perform that action at this time.