1 /*
2 * Copyright (c) 2014-2016 Wind River Systems, Inc.
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 structures definitions and various
12 * other definitions for the ARCv2 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_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_
21 #define ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_
22
23 #if !defined(_ASMLANGUAGE)
24
25 #include <kernel_arch_data.h>
26
27 #include <v2/irq.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
arch_kernel_init(void)33 static ALWAYS_INLINE void arch_kernel_init(void)
34 {
35 z_irq_setup();
36 }
37
38
39 /**
40 *
41 * @brief Indicates the interrupt number of the highest priority
42 * active interrupt
43 *
44 * @return IRQ number
45 */
Z_INTERRUPT_CAUSE(void)46 static ALWAYS_INLINE int Z_INTERRUPT_CAUSE(void)
47 {
48 uint32_t irq_num = z_arc_v2_aux_reg_read(_ARC_V2_ICAUSE);
49
50 return irq_num;
51 }
52
arch_is_in_isr(void)53 static inline bool arch_is_in_isr(void)
54 {
55 return z_arc_v2_irq_unit_is_in_isr();
56 }
57
58 extern void z_thread_entry_wrapper(void);
59 extern void z_user_thread_entry_wrapper(void);
60
61 extern void z_arc_userspace_enter(k_thread_entry_t user_entry, void *p1,
62 void *p2, void *p3, uint32_t stack, uint32_t size,
63 struct k_thread *thread);
64
65 extern void z_arc_fatal_error(unsigned int reason, const struct arch_esf *esf);
66
67 extern void z_arc_switch(void *switch_to, void **switched_from);
68
arch_switch(void * switch_to,void ** switched_from)69 static inline void arch_switch(void *switch_to, void **switched_from)
70 {
71 z_arc_switch(switch_to, switched_from);
72 }
73
74 #if !defined(CONFIG_MULTITHREADING)
75 extern FUNC_NORETURN void z_arc_switch_to_main_no_multithreading(
76 k_thread_entry_t main_func, void *p1, void *p2, void *p3);
77
78 #define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
79 z_arc_switch_to_main_no_multithreading
80
81 #endif /* !CONFIG_MULTITHREADING */
82
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* _ASMLANGUAGE */
89
90 #endif /* ZEPHYR_ARCH_ARC_INCLUDE_KERNEL_ARCH_FUNC_H_ */
91