45 #ifndef _TN_ARCH_CORTEX_M_H
46 #define _TN_ARCH_CORTEX_M_H
53 #include "../tn_arch_detect.h"
54 #include "../../core/tn_cfg_dispatch.h"
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
76 #define _TN_PIC32_INTSAVE_DATA_INVALID 0xffffffff
79 # define _TN_PIC32_INTSAVE_CHECK() \
81 if (tn_save_status_reg == _TN_PIC32_INTSAVE_DATA_INVALID){ \
82 _TN_FATAL_ERROR(""); \
86 # define _TN_PIC32_INTSAVE_CHECK()
89 #if defined(__TN_ARCHFEAT_CORTEX_M_ARMv7M_ISA__)
96 #define _TN_FFS(x) ffs_asm(x)
108 #if defined(__TN_COMPILER_IAR__)
109 # define _TN_FATAL_ERROR(error_msg, ...) \
112 # define _TN_FATAL_ERROR(error_msg, ...) \
113 {__asm__ volatile("bkpt #0");}
140 #if defined(__TN_COMPILER_ARMCC__)
142 # define TN_ARCH_STK_ATTR_BEFORE __align(8)
143 # define TN_ARCH_STK_ATTR_AFTER
145 #elif defined(__TN_COMPILER_GCC__) || defined(__TN_COMPILER_CLANG__)
147 # define TN_ARCH_STK_ATTR_BEFORE
148 # define TN_ARCH_STK_ATTR_AFTER __attribute__((aligned(0x08)))
150 #elif defined(__TN_COMPILER_IAR__)
152 # define TN_ARCH_STK_ATTR_BEFORE
153 # define TN_ARCH_STK_ATTR_AFTER
158 #if defined(__TN_ARCHFEAT_CORTEX_M_FPU__)
159 # define _TN_CORTEX_FPU_CONTEXT_SIZE 32
161 # define _TN_CORTEX_FPU_CONTEXT_SIZE 0
169 #define TN_MIN_STACK_SIZE (17 \
170 + _TN_STACK_OVERFLOW_SIZE_ADD \
171 + _TN_CORTEX_FPU_CONTEXT_SIZE \
177 #define TN_INT_WIDTH 32
198 #define TN_PRIORITIES_MAX_CNT TN_INT_WIDTH
204 #define TN_WAIT_INFINITE (TN_TickCnt)0xFFFFFFFF
209 #define TN_FILL_STACK_VAL 0xFEEDFACE
226 #define TN_INTSAVE_DATA \
227 int tn_save_status_reg = _TN_PIC32_INTSAVE_DATA_INVALID;
236 #define TN_INTSAVE_DATA_INT TN_INTSAVE_DATA
264 #define TN_INT_DIS_SAVE() tn_save_status_reg = tn_arch_sr_save_int_dis()
265 #define TN_INT_RESTORE() _TN_PIC32_INTSAVE_CHECK(); \
266 tn_arch_sr_restore(tn_save_status_reg)
275 #define TN_INT_IDIS_SAVE() TN_INT_DIS_SAVE()
284 #define TN_INT_IRESTORE() TN_INT_RESTORE()
289 #define TN_IS_INT_DISABLED() (_tn_arch_is_int_disabled())
294 #define _TN_CONTEXT_SWITCH_IPEND_IF_NEEDED() \
295 _tn_context_switch_pend_if_needed()
302 #define _TN_SIZE_BYTES_TO_UWORDS(size_in_bytes) ((size_in_bytes) >> 2)
304 #if defined(__TN_COMPILER_ARMCC__)
305 # define _TN_INLINE __inline
306 # define _TN_VOLATILE_WORKAROUND
307 #elif defined(__TN_COMPILER_GCC__) || defined(__TN_COMPILER_CLANG__)
308 # define _TN_INLINE inline
309 # define _TN_VOLATILE_WORKAROUND
310 #elif defined(__TN_COMPILER_IAR__)
311 # define _TN_INLINE inline
312 # define _TN_VOLATILE_WORKAROUND volatile
314 # error unknown Cortex compiler
318 #endif //-- DOXYGEN_SHOULD_SKIP_THIS
334 #endif // _TN_ARCH_CORTEX_M_H
unsigned int TN_UIntPtr
Unsigned integer type that is able to store pointers.
unsigned int TN_UWord
Unsigned integer type whose size is equal to the size of CPU register.