1 /*
2  * Copyright (c) 2020 Antony Pavlov <antonynpavlov@gmail.com>
3  *
4  * based on arch/riscv/include/kernel_arch_func.h
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 /**
10  * @file
11  * @brief Private kernel definitions
12  *
13  * This file contains private kernel function/macro definitions and various
14  * other definitions for the MIPS processor architecture.
15  */
16 
17 #ifndef ZEPHYR_ARCH_MIPS_INCLUDE_KERNEL_ARCH_FUNC_H_
18 #define ZEPHYR_ARCH_MIPS_INCLUDE_KERNEL_ARCH_FUNC_H_
19 
20 #include <kernel_arch_data.h>
21 
22 #include <zephyr/platform/hooks.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #ifndef _ASMLANGUAGE
arch_kernel_init(void)29 static ALWAYS_INLINE void arch_kernel_init(void)
30 {
31 #ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
32 	soc_per_core_init_hook();
33 #endif /* CONFIG_SOC_PER_CORE_INIT_HOOK */
34 }
35 
36 static ALWAYS_INLINE void
arch_thread_return_value_set(struct k_thread * thread,unsigned int value)37 arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
38 {
39 	thread->arch.swap_return_value = value;
40 }
41 
42 FUNC_NORETURN void z_mips_fatal_error(unsigned int reason,
43 				       const struct arch_esf *esf);
44 
arch_is_in_isr(void)45 static inline bool arch_is_in_isr(void)
46 {
47 	return _current_cpu->nested != 0U;
48 }
49 
50 int arch_swap(unsigned int key);
51 
52 #ifdef CONFIG_IRQ_OFFLOAD
53 void z_irq_do_offload(void);
54 #endif
55 
56 #endif /* _ASMLANGUAGE */
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif /* ZEPHYR_ARCH_MIPS_INCLUDE_KERNEL_ARCH_FUNC_H_ */
63