2017-01-19 05:46:13 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Wind River Systems, Inc.
|
|
|
|
* Copyright (c) 2016 Cadence Design Systems, Inc.
|
2017-01-25 07:10:39 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-01-19 05:46:13 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* this file is only meant to be included by kernel_structs.h */
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_FUNC_H_
|
|
|
|
#define ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_FUNC_H_
|
2017-01-19 05:46:13 +08:00
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
2020-03-13 06:37:29 +08:00
|
|
|
#include <kernel_internal.h>
|
2019-10-24 23:08:21 +08:00
|
|
|
#include <kernel_arch_data.h>
|
2018-05-17 02:02:29 +08:00
|
|
|
#include <string.h>
|
2017-01-19 05:46:13 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void FatalErrorHandler(void);
|
2017-02-11 04:58:08 +08:00
|
|
|
extern void ReservedInterruptHandler(unsigned int intNo);
|
2019-07-17 06:21:19 +08:00
|
|
|
extern void z_xtensa_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
|
2017-01-19 05:46:13 +08:00
|
|
|
|
|
|
|
/* Defined in xtensa_context.S */
|
2019-03-14 23:20:46 +08:00
|
|
|
extern void z_xt_coproc_init(void);
|
2017-01-19 05:46:13 +08:00
|
|
|
|
2020-04-26 06:19:23 +08:00
|
|
|
extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
|
2020-03-13 06:37:29 +08:00
|
|
|
CONFIG_ISR_STACK_SIZE);
|
2017-12-12 07:11:55 +08:00
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
static ALWAYS_INLINE void arch_kernel_init(void)
|
2017-01-19 05:46:13 +08:00
|
|
|
{
|
2018-01-26 08:39:35 +08:00
|
|
|
_cpu_t *cpu0 = &_kernel.cpus[0];
|
|
|
|
|
|
|
|
cpu0->nested = 0;
|
2017-12-12 07:11:55 +08:00
|
|
|
|
|
|
|
/* The asm2 scheme keeps the kernel pointer in MISC0 for easy
|
|
|
|
* access. That saves 4 bytes of immediate value to store the
|
|
|
|
* address when compared to the legacy scheme. But in SMP
|
|
|
|
* this record is a per-CPU thing and having it stored in a SR
|
|
|
|
* already is a big win.
|
|
|
|
*/
|
2018-10-20 00:22:47 +08:00
|
|
|
WSR(CONFIG_XTENSA_KERNEL_CPU_PTR_SR, cpu0);
|
2018-05-17 02:02:29 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_INIT_STACKS
|
2020-04-26 06:19:23 +08:00
|
|
|
memset(Z_KERNEL_STACK_BUFFER(z_interrupt_stacks[0]), 0xAA,
|
|
|
|
K_KERNEL_STACK_SIZEOF(z_interrupt_stacks[0]));
|
2018-05-17 02:02:29 +08:00
|
|
|
#endif
|
2017-01-19 05:46:13 +08:00
|
|
|
}
|
|
|
|
|
2019-10-04 05:50:46 +08:00
|
|
|
void xtensa_switch(void *switch_to, void **switched_from);
|
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
static inline void arch_switch(void *switch_to, void **switched_from)
|
2019-10-04 05:50:46 +08:00
|
|
|
{
|
|
|
|
return xtensa_switch(switch_to, switched_from);
|
|
|
|
}
|
|
|
|
|
2017-01-19 05:46:13 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
static inline bool arch_is_in_isr(void)
|
2019-10-04 05:32:22 +08:00
|
|
|
{
|
2019-11-08 04:43:29 +08:00
|
|
|
return arch_curr_cpu()->nested != 0U;
|
2019-10-04 05:32:22 +08:00
|
|
|
}
|
2017-01-19 05:46:13 +08:00
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_FUNC_H_ */
|