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 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #ifndef _ASMLANGUAGE
arch_kernel_init(void)25 static ALWAYS_INLINE void arch_kernel_init(void)
26 {
27 }
28 
29 void z_sparc_context_switch(struct k_thread *newt, struct k_thread *oldt);
30 
31 /*
32  * In this implementation, the thread->switch_handle is the thread itself, so
33  * the parameter "switched_from" is assumed to be the address of
34  * thread->switch_handle.
35  */
arch_switch(void * switch_to,void ** switched_from)36 static inline void arch_switch(void *switch_to, void **switched_from)
37 {
38 	struct k_thread *newt = switch_to;
39 	struct k_thread *oldt = CONTAINER_OF(switched_from, struct k_thread,
40 					     switch_handle);
41 
42 	z_sparc_context_switch(newt, oldt);
43 }
44 
45 FUNC_NORETURN void z_sparc_fatal_error(unsigned int reason,
46 				       const struct arch_esf *esf);
47 
arch_is_in_isr(void)48 static inline bool arch_is_in_isr(void)
49 {
50 	return _current_cpu->nested != 0U;
51 }
52 
53 #ifdef CONFIG_IRQ_OFFLOAD
54 void z_irq_do_offload(void);
55 #endif
56 
57 #endif /* _ASMLANGUAGE */
58 
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif /* ZEPHYR_ARCH_SPARC_INCLUDE_KERNEL_ARCH_FUNC_H_ */
64