1 /*
2  * Copyright (c) 2016 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief Private kernel definitions
10  *
11  * This file contains private kernel function/macro definitions and various
12  * other definitions for the Nios II processor architecture.
13  *
14  * This file is also included by assembly language files which must #define
15  * _ASMLANGUAGE before including this header file.  Note that kernel
16  * assembly source files obtains structure offset values via "absolute
17  * symbols" in the offsets.o module.
18  */
19 
20 #ifndef ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
21 #define ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_
22 
23 #include <kernel_arch_data.h>
24 
25 #include <zephyr/platform/hooks.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef _ASMLANGUAGE
32 
arch_kernel_init(void)33 static ALWAYS_INLINE void arch_kernel_init(void)
34 {
35 #ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
36 	soc_per_core_init_hook();
37 #endif /* CONFIG_SOC_PER_CORE_INIT_HOOK */
38 }
39 
40 static ALWAYS_INLINE void
arch_thread_return_value_set(struct k_thread * thread,unsigned int value)41 arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
42 {
43 	thread->callee_saved.retval = value;
44 }
45 
46 FUNC_NORETURN void z_nios2_fatal_error(unsigned int reason,
47 				       const struct arch_esf *esf);
48 
arch_is_in_isr(void)49 static inline bool arch_is_in_isr(void)
50 {
51 	return _kernel.cpus[0].nested != 0U;
52 }
53 
54 int arch_swap(unsigned int key);
55 
56 #ifdef CONFIG_IRQ_OFFLOAD
57 void z_irq_do_offload(void);
58 #endif
59 
60 #if ALT_CPU_ICACHE_SIZE > 0
61 void z_nios2_icache_flush_all(void);
62 #else
63 #define z_nios2_icache_flush_all() do { } while (false)
64 #endif
65 
66 #if ALT_CPU_DCACHE_SIZE > 0
67 void z_nios2_dcache_flush_all(void);
68 void z_nios2_dcache_flush_no_writeback(void *start, uint32_t len);
69 #else
70 #define z_nios2_dcache_flush_all() do { } while (false)
71 #define z_nios2_dcache_flush_no_writeback(x, y) do { } while (false)
72 #endif
73 
74 #endif /* _ASMLANGUAGE */
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* ZEPHYR_ARCH_NIOS2_INCLUDE_KERNEL_ARCH_FUNC_H_ */
81