zephyr/arch/x86/core/prep_c.c
Andrew Boie 8ce260d8df kernel: introduce supervisor-only stacks
These stacks are appropriate for threads that run purely in
supervisor mode, and also as stacks for interrupt and exception
handling.

Two new arch defines are introduced:

- ARCH_KERNEL_STACK_GUARD_SIZE
- ARCH_KERNEL_STACK_OBJ_ALIGN

New public declaration macros:

- K_KERNEL_STACK_RESERVED
- K_KERNEL_STACK_EXTERN
- K_KERNEL_STACK_DEFINE
- K_KERNEL_STACK_ARRAY_DEFINE
- K_KERNEL_STACK_MEMBER
- K_KERNEL_STACK_SIZEOF

If user mode is not enabled, K_KERNEL_STACK_* and K_THREAD_STACK_*
are equivalent.

Separately generated privilege elevation stacks are now declared
like kernel stacks, removing the need for K_PRIVILEGE_STACK_ALIGN.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-30 21:11:14 -04:00

54 lines
964 B
C

/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <kernel_internal.h>
#include <arch/x86/acpi.h>
#include <arch/x86/multiboot.h>
extern FUNC_NORETURN void z_cstart(void);
extern void x86_64_irq_init(void);
/* Early global initialization functions, C domain. This runs only on the first
* CPU for SMP systems.
*/
FUNC_NORETURN void z_x86_prep_c(void *arg)
{
struct multiboot_info *info = arg;
_kernel.cpus[0].nested = 0;
#ifdef CONFIG_X86_VERY_EARLY_CONSOLE
z_x86_early_serial_init();
#endif
#ifdef CONFIG_X86_64
x86_64_irq_init();
#endif
#ifdef CONFIG_MULTIBOOT_INFO
z_multiboot_init(info);
#else
ARG_UNUSED(info);
#endif
#ifdef CONFIG_X86_MMU
z_x86_paging_init();
#endif
#if CONFIG_X86_STACK_PROTECTION
for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) {
z_x86_set_stack_guard(z_interrupt_stacks[i]);
}
#endif
#if defined(CONFIG_SMP)
z_x86_ipi_setup();
#endif
z_cstart();
}