kernel_arch_func.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) 2013-2016 Wind River Systems, Inc.
  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-A/R/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. #ifndef ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_
  20. #define ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_
  21. #include <kernel_arch_data.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #ifndef _ASMLANGUAGE
  26. extern void z_arm_fault_init(void);
  27. extern void z_arm_cpu_idle_init(void);
  28. #ifdef CONFIG_ARM_MPU
  29. extern void z_arm_configure_static_mpu_regions(void);
  30. extern void z_arm_configure_dynamic_mpu_regions(struct k_thread *thread);
  31. extern int z_arm_mpu_init(void);
  32. #endif /* CONFIG_ARM_MPU */
  33. static ALWAYS_INLINE void arch_kernel_init(void)
  34. {
  35. z_arm_interrupt_stack_setup();
  36. z_arm_exc_setup();
  37. z_arm_fault_init();
  38. z_arm_cpu_idle_init();
  39. z_arm_clear_faults();
  40. #if defined(CONFIG_ARM_MPU)
  41. z_arm_mpu_init();
  42. /* Configure static memory map. This will program MPU regions,
  43. * to set up access permissions for fixed memory sections, such
  44. * as Application Memory or No-Cacheable SRAM area.
  45. *
  46. * This function is invoked once, upon system initialization.
  47. */
  48. z_arm_configure_static_mpu_regions();
  49. #endif
  50. }
  51. static ALWAYS_INLINE void
  52. arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
  53. {
  54. thread->arch.swap_return_value = value;
  55. }
  56. #if !defined(CONFIG_MULTITHREADING) && defined(CONFIG_CPU_CORTEX_M)
  57. extern FUNC_NORETURN void z_arm_switch_to_main_no_multithreading(
  58. k_thread_entry_t main_func,
  59. void *p1, void *p2, void *p3);
  60. #define ARCH_SWITCH_TO_MAIN_NO_MULTITHREADING \
  61. z_arm_switch_to_main_no_multithreading
  62. #endif /* !CONFIG_MULTITHREADING && CONFIG_CPU_CORTEX_M */
  63. extern FUNC_NORETURN void z_arm_userspace_enter(k_thread_entry_t user_entry,
  64. void *p1, void *p2, void *p3,
  65. uint32_t stack_end,
  66. uint32_t stack_start);
  67. extern void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
  68. #endif /* _ASMLANGUAGE */
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /* ZEPHYR_ARCH_ARM_INCLUDE_AARCH32_KERNEL_ARCH_FUNC_H_ */