zephyr/arch/x86/core/prep_c.c
Andrew Boie 80a0d9d16b kernel: interrupt/idle stacks/threads as array
The set of interrupt stacks is now expressed as an array. We
also define the idle threads and their associated stacks this
way. This allows for iteration in cases where we have multiple
CPUs.

There is now a centralized declaration in kernel_internal.h.

On uniprocessor systems, z_interrupt_stacks has one element
and can be used in the same way as _interrupt_stack.

The IRQ stack for CPU 0 is now set in init.c instead of in
arch code.

The extern definition of the main thread stack is now removed,
this doesn't need to be in a header.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-16 23:17:36 +02:00

53 lines
957 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);
/* 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_MULTIBOOT_INFO
z_multiboot_init(info);
#else
ARG_UNUSED(info);
#endif
#ifdef CONFIG_ACPI
z_acpi_init();
#endif
#ifdef CONFIG_X86_MMU
z_x86_paging_init();
#endif
#if CONFIG_X86_STACK_PROTECTION
z_x86_mmu_set_flags(&z_x86_kernel_ptables, z_interrupt_stacks[0],
MMU_PAGE_SIZE, MMU_ENTRY_READ, Z_X86_MMU_RW,
true);
#endif
#if defined(CONFIG_SMP)
z_x86_ipi_setup();
#endif
z_cstart();
}