TNeo
v1.06
|
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 system interrupts. More... | |
void | tn_arch_int_en (void) |
Unconditionally enable interrupts. More... | |
TN_UWord | tn_arch_sr_save_int_dis (void) |
Disable system interrupts and return previous value of status register, atomically. More... | |
void | tn_arch_sr_restore (TN_UWord sr) |
Restore previously saved status register. More... | |
TN_UWord * | _tn_arch_stack_top_get (TN_UWord *stack_low_address, int stack_size) |
Should return top of the stack. More... | |
TN_UWord * | _tn_arch_stack_bottom_empty_get (TN_UWord *stack_top, int stack_size) |
This function should return address of bottom empty element of stack, it is needed for software stack overflow control (see TN_STACK_OVERFLOW_CHECK ). More... | |
TN_UWord * | _tn_arch_stack_init (TN_TaskBody *task_func, TN_UWord *stack_top, int stack_size, void *param) |
Should put initial CPU context to the provided stack pointer for new task and return current stack pointer. More... | |
int | _tn_arch_inside_isr (void) |
Should return 1 if system ISR is currently running, 0 otherwise. More... | |
int | _tn_arch_is_int_disabled (void) |
Should return 1 if system interrupts are currently disabled, 0 otherwise. More... | |
void | _tn_arch_context_switch_pend (void) |
Called whenever we need to switch context from one task to another. More... | |
void | _tn_arch_context_switch_now_nosave (void) |
Called whenever we need to switch context to new task, but don't save current context. More... | |
void | _tn_arch_sys_start (TN_UWord *int_stack, unsigned int int_stack_size) |
Performs first context switch to the first task (_tn_next_task_to_run is already set to needed task). More... | |
void tn_arch_int_dis | ( | void | ) |
Unconditionally disable system interrupts.
Refer to the section Interrupt types for details on what is system interrupt.
void tn_arch_int_en | ( | void | ) |
Unconditionally enable interrupts.
Refer to the section Interrupt types for details on what is system interrupt.
TN_UWord tn_arch_sr_save_int_dis | ( | void | ) |
Disable system interrupts and return previous value of status register, atomically.
Refer to the section Interrupt types for details on what is system interrupt.
tn_arch_sr_restore()
void tn_arch_sr_restore | ( | TN_UWord | sr | ) |
Restore previously saved status register.
sr | status register value previously from tn_arch_sr_save_int_dis() |
tn_arch_sr_save_int_dis()
Should return top of the stack.
A stack implementation is characterized by two attributes:
So, depending on the stack implementation used in the particular architecture, the value returned from this function can be one of the following:
(stack_low_address - 1)
(Full ascending stack)(stack_low_address + stack_size)
(Full descending stack)(stack_low_address)
(Empty ascending stack)(stack_low_address + stack_size - 1)
(Empty descending stack)stack_low_address | Start address of the stack array. |
stack_size | Size of the stack in TN_UWord -s, not in bytes. |
This function should return address of bottom empty element of stack, it is needed for software stack overflow control (see TN_STACK_OVERFLOW_CHECK
).
For details on various hardware stack implementations, refer to _tn_arch_stack_top_get()
.
Depending on the stack implementation used in the particular architecture, the value returned from this function can be one of the following:
(stack_top - stack_size)
(Full descending stack)(stack_top + stack_size)
(Full ascending stack)(stack_top - stack_size + 1)
(Empty descending stack)(stack_top + stack_size - 1)
(Empty ascending stack)stack_top | Top of the stack, returned by _tn_arch_stack_top_get() . |
stack_size | Size of the stack in TN_UWord -s, not in bytes. |
TN_UWord* _tn_arch_stack_init | ( | TN_TaskBody * | task_func, |
TN_UWord * | stack_top, | ||
int | stack_size, | ||
void * | param | ||
) |
Should put initial CPU context to the provided stack pointer for new task and return current stack pointer.
When resulting context gets restored by _tn_arch_context_switch_now_nosave()
or _tn_arch_context_switch_pend()
, the following conditions should be met:
tn_task_exit()
, so that when task body function returns, tn_task_exit()
gets automatially called;param
pointertask_func | Pointer to task body function. |
stack_top | Top of the stack, returned by _tn_arch_stack_top_get() . |
stack_size | Size of the stack in TN_UWord -s, not in bytes. |
param | User-provided parameter for task body function. |
int _tn_arch_inside_isr | ( | void | ) |
Should return 1 if system ISR is currently running, 0 otherwise.
Refer to the section Interrupt types for details on what is system ISR.
int _tn_arch_is_int_disabled | ( | void | ) |
Should return 1 if system interrupts are currently disabled, 0 otherwise.
Refer to the section Interrupt types for details on what is system interrupt.
void _tn_arch_context_switch_pend | ( | void | ) |
Called whenever we need to switch context from one task to another.
This function typically does NOT switch context; it merely pends it, that is, it sets appropriate interrupt flag. If current level is an application level, interrupt is fired immediately, and context gets switched. Otherwise (if some ISR is currently running), context switch keeps pending until all ISR return.
Preconditions:
_tn_curr_run_task
points to currently running (preempted) task;_tn_next_task_to_run
points to new task to run.Actions to perform in actual context switching routine:
_TN_ON_CONTEXT_SWITCH_HANDLER
is non-zero, call _tn_sys_on_context_switch(_tn_curr_run_task, _tn_next_task_to_run);
._tn_curr_run_task
to _tn_next_task_to_run
;_tn_curr_run_task
_tn_next_task_to_run
void _tn_arch_context_switch_now_nosave | ( | void | ) |
Called whenever we need to switch context to new task, but don't save current context.
This happens:
tn_sys_start()
(well, it is actually called indirectly but from _tn_arch_sys_start()
);tn_task_exit()
.This function doesn't need to pend context switch, it switches context immediately.
Preconditions:
_tn_next_task_to_run
is already set to needed task.Actions to perform:
_TN_ON_CONTEXT_SWITCH_HANDLER
is non-zero, call _tn_sys_on_context_switch(_tn_curr_run_task, _tn_next_task_to_run);
._tn_curr_run_task
to _tn_next_task_to_run
;_tn_curr_run_task
_tn_next_task_to_run
void _tn_arch_sys_start | ( | TN_UWord * | int_stack, |
unsigned int | int_stack_size | ||
) |
Performs first context switch to the first task (_tn_next_task_to_run
is already set to needed task).
Typically, this function just calls _tn_arch_context_switch_now_nosave()
, but it also can perform any architecture-dependent actions first, if needed.