1 /*
2  * Copyright (c) 2019-2020 Cobham Gaisler AB
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 SPARC processor architecture.
13  */
14 
15 #ifndef ZEPHYR_ARCH_SPARC_INCLUDE_KERNEL_ARCH_FUNC_H_
16 #define ZEPHYR_ARCH_SPARC_INCLUDE_KERNEL_ARCH_FUNC_H_
17 
18 #include <kernel_arch_data.h>
19 
20 #include <zephyr/platform/hooks.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifndef _ASMLANGUAGE
arch_kernel_init(void)27 static ALWAYS_INLINE void arch_kernel_init(void)
28 {
29 #ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
30 	soc_per_core_init_hook();
31 #endif /* CONFIG_SOC_PER_CORE_INIT_HOOK */
32 }
33 
34 void z_sparc_context_switch(struct k_thread *newt, struct k_thread *oldt);
35 
36 /*
37  * In this implementation, the thread->switch_handle is the thread itself, so
38  * the parameter "switched_from" is assumed to be the address of
39  * thread->switch_handle.
40  */
arch_switch(void * switch_to,void ** switched_from)41 static inline void arch_switch(void *switch_to, void **switched_from)
42 {
43 	struct k_thread *newt = switch_to;
44 	struct k_thread *oldt = CONTAINER_OF(switched_from, struct k_thread,
45 					     switch_handle);
46 
47 	z_sparc_context_switch(newt, oldt);
48 }
49 
50 FUNC_NORETURN void z_sparc_fatal_error(unsigned int reason,
51 				       const struct arch_esf *esf);
52 
arch_is_in_isr(void)53 static inline bool arch_is_in_isr(void)
54 {
55 	return _current_cpu->nested != 0U;
56 }
57 
58 #ifdef CONFIG_IRQ_OFFLOAD
59 void z_irq_do_offload(void);
60 #endif
61 
62 #endif /* _ASMLANGUAGE */
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* ZEPHYR_ARCH_SPARC_INCLUDE_KERNEL_ARCH_FUNC_H_ */
69