TNeoKernel  v1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
tn_arch.h File Reference

Detailed Description

Architecture-dependent routines declaration.

Definition in file tn_arch.h.

Go to the source code of this file.

Functions

void tn_arch_int_dis (void)
 Unconditionally disable interrupts.
 
void tn_arch_int_en (void)
 Unconditionally enable interrupts.
 
unsigned int tn_arch_sr_save_int_dis (void)
 Disable interrupts and return previous value of status register, atomically. More...
 
void tn_arch_sr_restore (unsigned int sr)
 Restore previously saved status register. More...
 
TN_UWord_tn_arch_stack_start_get (TN_UWord *stack_low_address, int stack_size)
 Should return start stack address, which may be either the lowest address of the stack array or the highest one, depending on the architecture. More...
 
unsigned int * _tn_arch_stack_init (TN_TaskBody *task_func, TN_UWord *stack_start, void *param)
 Should initialize stack for new task and return current stack pointer. More...
 
int _tn_arch_inside_isr (void)
 Should return 1 if ISR is currently running, 0 otherwise.
 
void _tn_arch_context_switch (void)
 Called whenever we need to switch context to other task. More...
 
void _tn_arch_context_switch_exit (void)
 Called when some task calls tn_task_exit(). More...
 
void _tn_arch_system_start (void)
 Should perform first context switch (to the task pointed to by tn_next_task_to_run). More...
 

Function Documentation

unsigned int tn_arch_sr_save_int_dis ( void  )

Disable interrupts and return previous value of status register, atomically.

See also
tn_arch_sr_restore()
void tn_arch_sr_restore ( unsigned int  sr)

Restore previously saved status register.

Parameters
srstatus register value previously from tn_arch_sr_save_int_dis()
See also
tn_arch_sr_save_int_dis()
TN_UWord* _tn_arch_stack_start_get ( TN_UWord stack_low_address,
int  stack_size 
)

Should return start stack address, which may be either the lowest address of the stack array or the highest one, depending on the architecture.

Parameters
stack_low_addressstart address of the stack array.
stack_sizesize of the stack in int-s, not in bytes.
unsigned int* _tn_arch_stack_init ( TN_TaskBody task_func,
TN_UWord stack_start,
void *  param 
)

Should initialize stack for new task and return current stack pointer.

Parameters
task_funcPointer to task body function.
stack_startStart address of the stack, returned by _tn_arch_stack_start_get().
paramUser-provided parameter for task body function.
Returns
current stack pointer (top of the stack)
void _tn_arch_context_switch ( void  )

Called whenever we need to switch context to other task.

Preconditions:

  • interrupts are enabled;
  • tn_curr_run_task points to currently running (preempted) task;
  • tn_next_task_to_run points to new task to run.

Actions to perform:

  • save context of the preempted task to its stack;
  • set tn_curr_run_task to tn_next_task_to_run;
  • switch context to it.
See also
tn_curr_run_task
tn_next_task_to_run
void _tn_arch_context_switch_exit ( void  )

Called when some task calls tn_task_exit().

Preconditions:

  • interrupts are disabled;
  • tn_next_task_to_run is already set to other task.

Actions to perform:

  • set tn_curr_run_task to tn_next_task_to_run;
  • switch context to it.
See also
tn_curr_run_task
tn_next_task_to_run
void _tn_arch_system_start ( void  )

Should perform first context switch (to the task pointed to by tn_next_task_to_run).

Preconditions:

  • no interrupts are set up yet, so, it's like interrupts disabled
  • tn_next_task_to_run is already set to idle task.

Actions to perform:

  • set TN_STATE_FLAG__SYS_RUNNING flag in the tn_sys_state variable;
  • set tn_curr_run_task to tn_next_task_to_run;
  • switch context to it.
See also
TN_STATE_FLAG__SYS_RUNNING
tn_sys_state
tn_curr_run_task
tn_next_task_to_run