2019-08-06 07:17:48 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2019-10-24 23:08:21 +08:00
|
|
|
#include <kernel.h>
|
|
|
|
#include <kernel_internal.h>
|
2019-09-07 03:03:38 +08:00
|
|
|
#include <arch/x86/acpi.h>
|
2019-09-10 02:05:41 +08:00
|
|
|
#include <arch/x86/multiboot.h>
|
2020-07-05 07:23:32 +08:00
|
|
|
#include <x86_mmu.h>
|
2019-08-06 07:17:48 +08:00
|
|
|
|
2019-09-29 02:25:13 +08:00
|
|
|
extern FUNC_NORETURN void z_cstart(void);
|
2020-06-17 03:49:54 +08:00
|
|
|
extern void x86_64_irq_init(void);
|
2019-09-29 02:25:13 +08:00
|
|
|
|
2020-01-11 04:51:38 +08:00
|
|
|
/* 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)
|
2019-08-06 07:17:48 +08:00
|
|
|
{
|
2020-01-11 04:51:38 +08:00
|
|
|
struct multiboot_info *info = arg;
|
2019-09-29 09:26:00 +08:00
|
|
|
|
2019-09-29 02:25:13 +08:00
|
|
|
_kernel.cpus[0].nested = 0;
|
2019-08-06 07:17:48 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_VERY_EARLY_CONSOLE
|
|
|
|
z_x86_early_serial_init();
|
|
|
|
#endif
|
2019-09-10 02:05:41 +08:00
|
|
|
|
2020-06-17 03:49:54 +08:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
x86_64_irq_init();
|
|
|
|
#endif
|
|
|
|
|
2019-09-28 02:53:40 +08:00
|
|
|
#ifdef CONFIG_MULTIBOOT_INFO
|
|
|
|
z_multiboot_init(info);
|
2019-09-10 02:05:41 +08:00
|
|
|
#else
|
|
|
|
ARG_UNUSED(info);
|
|
|
|
#endif
|
|
|
|
|
2019-08-06 07:17:48 +08:00
|
|
|
#if CONFIG_X86_STACK_PROTECTION
|
2020-04-25 07:24:46 +08:00
|
|
|
for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) {
|
|
|
|
z_x86_set_stack_guard(z_interrupt_stacks[i]);
|
|
|
|
}
|
2019-08-06 07:17:48 +08:00
|
|
|
#endif
|
|
|
|
|
2019-10-01 01:28:36 +08:00
|
|
|
#if defined(CONFIG_SMP)
|
|
|
|
z_x86_ipi_setup();
|
|
|
|
#endif
|
|
|
|
|
2019-08-06 07:17:48 +08:00
|
|
|
z_cstart();
|
|
|
|
}
|