Go to the documentation of this file.
54 #include "../arch/tn_arch.h"
87 #define TN_STACK_ARR_DEF(name, size) \
88 TN_ARCH_STK_ATTR_BEFORE \
89 TN_UWord name[ (size) ] \
90 TN_ARCH_STK_ATTR_AFTER
93 #if TN_CHECK_BUILD_CFG
99 #if defined (__TN_ARCH_PIC24_DSPIC__)
101 # define _TN_BUILD_CFG_ARCH_STRUCT_FILL(_p_struct) \
103 (_p_struct)->arch.p24.p24_sys_ipl = TN_P24_SYS_IPL; \
107 # define _TN_BUILD_CFG_ARCH_STRUCT_FILL(_p_struct)
119 #define _TN_BUILD_CFG_STRUCT_FILL(_p_struct) \
121 memset((_p_struct), 0x00, sizeof(*(_p_struct))); \
123 (_p_struct)->priorities_cnt = TN_PRIORITIES_CNT; \
124 (_p_struct)->check_param = TN_CHECK_PARAM; \
125 (_p_struct)->debug = TN_DEBUG; \
126 (_p_struct)->use_mutexes = TN_USE_MUTEXES; \
127 (_p_struct)->mutex_rec = TN_MUTEX_REC; \
128 (_p_struct)->mutex_deadlock_detect = TN_MUTEX_DEADLOCK_DETECT; \
129 (_p_struct)->tick_lists_cnt_minus_one = (TN_TICK_LISTS_CNT - 1); \
130 (_p_struct)->api_make_alig_arg = TN_API_MAKE_ALIG_ARG; \
131 (_p_struct)->profiler = TN_PROFILER; \
132 (_p_struct)->profiler_wait_time = TN_PROFILER_WAIT_TIME; \
133 (_p_struct)->stack_overflow_check = TN_STACK_OVERFLOW_CHECK; \
134 (_p_struct)->dynamic_tick = TN_DYNAMIC_TICK; \
135 (_p_struct)->old_events_api = TN_OLD_EVENT_API; \
137 _TN_BUILD_CFG_ARCH_STRUCT_FILL(_p_struct); \
143 #define _TN_BUILD_CFG_STRUCT_FILL(_p_struct)
145 #endif // TN_CHECK_BUILD_CFG
153 # define _TN_MAX_INLINED_FUNC _TN_STATIC_INLINE
155 # define _TN_MAX_INLINED_FUNC
366 #define TN_NO_TIME_SLICE 0
371 #define TN_MAX_TIME_SLICE 0xFFFE
413 unsigned int idle_task_stack_size,
415 unsigned int int_stack_size,
617 #if TN_DYNAMIC_TICK || defined(DOXYGEN_ACTIVE)
unsigned tick_lists_cnt_minus_one
Value of #TN_TICK_LISTS_CNT minus one.
TN_StateFlag
System state flags.
void tn_callback_deadlock_set(TN_CBDeadlock *cb)
Set callback function that should be called whenever deadlock occurs or becomes inactive (say,...
TN_Context
System context.
unsigned check_param
Value of #TN_CHECK_PARAM
void tn_arch_sched_restore(TN_UWord sched_state)
Restore state of the kernel scheduler.
void() TN_TaskBody(void *param)
Prototype for task body function.
unsigned int TN_UWord
Unsigned integer type whose size is equal to the size of CPU register.
unsigned mutex_rec
Value of #TN_MUTEX_REC
unsigned old_events_api
Value of #TN_OLD_EVENT_API
@ TN_CONTEXT_NONE
None: this code is possible if only system is not running (flag (#TN_STATE_FLAG__SYS_RUNNING is not s...
void() TN_CBUserTaskCreate(void)
User-provided callback function that is called directly from tn_sys_start() as a part of system start...
unsigned priorities_cnt
Value of #TN_PRIORITIES_CNT
unsigned api_make_alig_arg
Value of #TN_API_MAKE_ALIG_ARG
unsigned mutex_deadlock_detect
Value of #TN_MUTEX_DEADLOCK_DETECT
unsigned dynamic_tick
Value of #TN_DYNAMIC_TICK
TN_TaskBody * tn_cur_task_body_get(void)
Returns pointer to the body function of the currently running task.
#define _TN_STATIC_INLINE
For some compilers, order of these qualifiers matters (at least when _TN_INLINE expands to some compi...
enum TN_StateFlag tn_sys_state_flags_get(void)
Returns current system state flags.
unsigned p24_sys_ipl
Value of #TN_P24_SYS_IPL
_TN_STATIC_INLINE TN_BOOL tn_is_isr_context(void)
Returns whether current system context is #TN_CONTEXT_ISR
_TN_STATIC_INLINE void tn_sched_restore(TN_UWord sched_state)
Restore state of the kernel scheduler.
_TN_STATIC_INLINE TN_UWord tn_sched_dis_save(void)
Disable kernel scheduler and return previous scheduler state.
void tn_sys_start(TN_UWord *idle_task_stack, unsigned int idle_task_stack_size, TN_UWord *int_stack, unsigned int int_stack_size, TN_CBUserTaskCreate *cb_user_task_create, TN_CBIdle *cb_idle)
Initial TNeo system start function, never returns.
TN_RCode
Result code returned by kernel services.
@ TN_STATE_FLAG__SYS_RUNNING
system is running
Structure with build-time configurations values; it is needed for run-time check which ensures that b...
@ TN_STATE_FLAG__DEADLOCK
deadlock is active Note: this feature works if only #TN_MUTEX_DEADLOCK_DETECT is non-zero.
void tn_callback_stack_overflow_set(TN_CBStackOverflow *cb)
Set callback function that is called when the kernel detects stack overflow (see #TN_STACK_OVERFLOW_C...
struct TN_Task * tn_cur_task_get(void)
Returns pointer to the currently running task.
void tn_callback_dyn_tick_set(TN_CBTickSchedule *cb_tick_schedule, TN_CBTickCntGet *cb_tick_cnt_get)
Available if only TN_DYNAMIC_TICK is set.
TN_UWord dummy
On some architectures, we don't have any arch-dependent build-time options, but we need this "dummy" ...
unsigned debug
Value of #TN_DEBUG
enum TN_Context tn_sys_context_get(void)
Returns system context: task or ISR.
enum TN_RCode tn_sys_tslice_set(int priority, int ticks)
Set time slice ticks value for specified priority (see Round-robin scheduling).
void() TN_CBDeadlock(TN_BOOL active, struct TN_Mutex *mutex, struct TN_Task *task)
User-provided callback function that is called whenever deadlock becomes active or inactive.
_TN_STATIC_INLINE TN_BOOL tn_is_task_context(void)
Returns whether current system context is #TN_CONTEXT_TASK
#define TN_BOOL
boolean type definition
union _TN_BuildCfg::@0 arch
Architecture-dependent values.
unsigned stack_overflow_check
Value of #TN_STACK_OVERFLOW_CHECK
unsigned long TN_TickCnt
Type for system tick count, it is used by the kernel to represent absolute tick count value as well a...
void() TN_CBTickSchedule(TN_TickCnt timeout)
Available if only TN_DYNAMIC_TICK is set.
unsigned profiler_wait_time
Value of #TN_PROFILER_WAIT_TIME
void() TN_CBStackOverflow(struct TN_Task *task)
User-provided callback function that is called when the kernel detects stack overflow (see #TN_STACK_...
TN_TickCnt tn_sys_time_get(void)
Get current system ticks count.
TN_TickCnt() TN_CBTickCntGet(void)
Available if only TN_DYNAMIC_TICK is set.
void() TN_CBIdle(void)
User-provided callback function which is called repeatedly from the idle task loop.
unsigned use_mutexes
Value of #TN_USE_MUTEXES
void tn_tick_int_processing(void)
Process system tick; should be called periodically, typically from some kind of timer ISR.
@ TN_CONTEXT_TASK
Task context.
TN_UWord tn_arch_sched_dis_save(void)
Disable kernel scheduler and return previous state.
int priority
current task priority
struct _TN_BuildCfg::@0::@1 p24
PIC24/dsPIC-dependent values.
@ TN_CONTEXT_ISR
ISR context.
unsigned profiler
Value of #TN_PROFILER