Branch data Line data Source code
1 : : /* 2 : : * Copyright (c) 2013-2016 Wind River Systems, Inc. 3 : : * 4 : : * SPDX-License-Identifier: Apache-2.0 5 : : */ 6 : : 7 : : /** 8 : : * @file 9 : : * @brief Private kernel definitions (ARM) 10 : : * 11 : : * This file contains private kernel function definitions and various 12 : : * other definitions for the 32-bit ARM Cortex-A/R/M processor architecture 13 : : * family. 14 : : * 15 : : * This file is also included by assembly language files which must #define 16 : : * _ASMLANGUAGE before including this header file. Note that kernel 17 : : * assembly source files obtains structure offset values via "absolute symbols" 18 : : * in the offsets.o module. 19 : : */ 20 : : 21 : : #ifndef ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_ 22 : : #define ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_ 23 : : 24 : : #include <kernel_arch_data.h> 25 : : 26 : : #ifdef __cplusplus 27 : : extern "C" { 28 : : #endif 29 : : 30 : : #ifndef _ASMLANGUAGE 31 : : extern void z_arm_fault_init(void); 32 : : extern void z_arm_cpu_idle_init(void); 33 : : #ifdef CONFIG_ARM_MPU 34 : : extern void z_arm_configure_static_mpu_regions(void); 35 : : extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread); 36 : : extern int z_arm_mpu_init(void); 37 : : #endif /* CONFIG_ARM_MPU */ 38 : : #ifdef CONFIG_ARM_AARCH32_MMU 39 : : extern int z_arm_mmu_init(void); 40 : : #endif /* CONFIG_ARM_AARCH32_MMU */ 41 : : 42 : 1 : static ALWAYS_INLINE void arch_kernel_init(void) 43 : : { 44 : 1 : z_arm_interrupt_stack_setup(); 45 : 1 : z_arm_exc_setup(); 46 : 1 : z_arm_fault_init(); 47 : 1 : z_arm_cpu_idle_init(); 48 : 1 : z_arm_clear_faults(); 49 : : #if defined(CONFIG_ARM_MPU) 50 : 1 : z_arm_mpu_init(); 51 : : /* Configure static memory map. This will program MPU regions, 52 : : * to set up access permissions for fixed memory sections, such 53 : : * as Application Memory or No-Cacheable SRAM area. 54 : : * 55 : : * This function is invoked once, upon system initialization. 56 : : */ 57 : 1 : z_arm_configure_static_mpu_regions(); 58 : : #endif /* CONFIG_ARM_MPU */ 59 : : #if defined(CONFIG_ARM_AARCH32_MMU) 60 : : z_arm_mmu_init(); 61 : : #endif /* CONFIG_ARM_AARCH32_MMU */ 62 : 1 : } 63 : : 64 : : static ALWAYS_INLINE void 65 : 0 : arch_thread_return_value_set(struct k_thread *thread, unsigned int value) 66 : : { 67 : 0 : thread->arch.swap_return_value = value; 68 : 0 : } 69 : : 70 : : #if !defined(CONFIG_MULTITHREADING) && defined(CONFIG_CPU_CORTEX_M) 71 : : extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading( 72 : : k_thread_entry_t main_func, 73 : : void *p1, void *p2, void *p3); 74 : : 75 : : #define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \ 76 : : z_arm_switch_to_main_no_multithreading 77 : : 78 : : #endif /* !CONFIG_MULTITHREADING && CONFIG_CPU_CORTEX_M */ 79 : : 80 : : extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry, 81 : : void *p1, void *p2, void *p3, 82 : : uint32_t stack_end, 83 : : uint32_t stack_start); 84 : : 85 : : extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf); 86 : : 87 : : #endif /* _ASMLANGUAGE */ 88 : : 89 : : #ifdef __cplusplus 90 : : } 91 : : #endif 92 : : 93 : : #endif /* ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_ */