|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 Carlo Caione <[email protected]> |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | +/** |
| 7 | + * @file |
| 8 | + * @brief Private kernel definitions (ARM) |
| 9 | + * |
| 10 | + * This file contains private kernel function definitions and various |
| 11 | + * other definitions for the 32-bit ARM Cortex-M processor architecture |
| 12 | + * 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_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_ |
| 21 | +#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_ |
| 22 | + |
| 23 | +#ifdef __cplusplus |
| 24 | +extern "C" { |
| 25 | +#endif |
| 26 | + |
| 27 | +#ifndef _ASMLANGUAGE |
| 28 | +extern void z_arm_fault_init(void); |
| 29 | +extern void z_arm_cpu_idle_init(void); |
| 30 | +#ifdef CONFIG_ARM_MPU |
| 31 | +extern void z_arm_configure_static_mpu_regions(void); |
| 32 | +extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread); |
| 33 | +extern int z_arm_mpu_init(void); |
| 34 | +#endif /* CONFIG_ARM_MPU */ |
| 35 | +#ifdef CONFIG_ARM_AARCH32_MMU |
| 36 | +extern int z_arm_mmu_init(void); |
| 37 | +#endif /* CONFIG_ARM_AARCH32_MMU */ |
| 38 | + |
| 39 | +static ALWAYS_INLINE void arch_kernel_init(void) |
| 40 | +{ |
| 41 | + z_arm_interrupt_stack_setup(); |
| 42 | + z_arm_exc_setup(); |
| 43 | + z_arm_fault_init(); |
| 44 | + z_arm_cpu_idle_init(); |
| 45 | + z_arm_clear_faults(); |
| 46 | +#if defined(CONFIG_ARM_MPU) |
| 47 | + z_arm_mpu_init(); |
| 48 | + /* Configure static memory map. This will program MPU regions, |
| 49 | + * to set up access permissions for fixed memory sections, such |
| 50 | + * as Application Memory or No-Cacheable SRAM area. |
| 51 | + * |
| 52 | + * This function is invoked once, upon system initialization. |
| 53 | + */ |
| 54 | + z_arm_configure_static_mpu_regions(); |
| 55 | +#endif /* CONFIG_ARM_MPU */ |
| 56 | +} |
| 57 | + |
| 58 | +static ALWAYS_INLINE void |
| 59 | +arch_thread_return_value_set(struct k_thread *thread, unsigned int value) |
| 60 | +{ |
| 61 | + thread->arch.swap_return_value = value; |
| 62 | +} |
| 63 | + |
| 64 | +#if !defined(CONFIG_MULTITHREADING) |
| 65 | +extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading( |
| 66 | + k_thread_entry_t main_func, |
| 67 | + void *p1, void *p2, void *p3); |
| 68 | + |
| 69 | +#define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \ |
| 70 | + z_arm_switch_to_main_no_multithreading |
| 71 | + |
| 72 | +#endif /* !CONFIG_MULTITHREADING */ |
| 73 | + |
| 74 | +extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry, |
| 75 | + void *p1, void *p2, void *p3, |
| 76 | + uint32_t stack_end, |
| 77 | + uint32_t stack_start); |
| 78 | + |
| 79 | +extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf); |
| 80 | + |
| 81 | +#endif /* _ASMLANGUAGE */ |
| 82 | + |
| 83 | +#ifdef __cplusplus |
| 84 | +} |
| 85 | +#endif |
| 86 | + |
| 87 | +#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_KERNEL_ARCH_FUNC_H_ */ |
0 commit comments