1 /*
2  * Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com<
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief Private kernel definitions (ARM64)
10  *
11  * This file contains private kernel function definitions and various
12  * other definitions for the ARM Cortex-A processor architecture family.
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 symbols"
17  * in the offsets.o module.
18  */
19 
20 #ifndef ZEPHYR_ARCH_ARM64_INCLUDE_KERNEL_ARCH_FUNC_H_
21 #define ZEPHYR_ARCH_ARM64_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 
36 #ifdef CONFIG_SOC_PER_CORE_INIT_HOOK
37 	soc_per_core_init_hook();
38 #endif /* CONFIG_SOC_PER_CORE_INIT_HOOK */
39 }
40 
arch_switch(void * switch_to,void ** switched_from)41 static inline void arch_switch(void *switch_to, void **switched_from)
42 {
43 	extern void z_arm64_context_switch(struct k_thread *new,
44 					   struct k_thread *old);
45 	struct k_thread *new = switch_to;
46 	struct k_thread *old = CONTAINER_OF(switched_from, struct k_thread,
47 					    switch_handle);
48 
49 	z_arm64_context_switch(new, old);
50 }
51 
52 extern void z_arm64_fatal_error(unsigned int reason, struct arch_esf *esf);
53 extern void z_arm64_set_ttbr0(uint64_t ttbr0);
54 extern void z_arm64_mem_cfg_ipi(void);
55 
56 #ifdef CONFIG_FPU_SHARING
57 void arch_flush_local_fpu(void);
58 void arch_flush_fpu_ipi(unsigned int cpu);
59 #endif
60 
61 #ifdef CONFIG_ARM64_SAFE_EXCEPTION_STACK
62 void z_arm64_safe_exception_stack_init(void);
63 #endif
64 
65 #endif /* _ASMLANGUAGE */
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* ZEPHYR_ARCH_ARM64_INCLUDE_KERNEL_ARCH_FUNC_H_ */
72