The context is stored so that it looks like the way the stack would if all the registers were stored by an interrupt function.
Defines | |
| #define | TRPORT_MIN_CTXT_SZ 64 |
Functions | |
| osstkptr_t | hal_stk_init (osword_t *stk, osword_t stacksize, osfnptr_t pc, osptr_t init_arg) |
| static void | hal_retval_set (osstkptr_t ctxt_ptr, osptr_t retval) |
| osstkptr_t | hal_ctxt_switch (void) |
| void | hal_ctxt_load (osstkptr_t ctxt_ptr) |
| void | hal_init (void) |
| #define TRPORT_MIN_CTXT_SZ 64 |
Define the minimum size of the context in oswords.
Definition at line 221 of file template/tr_port.h.
| osstkptr_t hal_stk_init | ( | osword_t * | stk, | |
| osword_t | stacksize, | |||
| osfnptr_t | pc, | |||
| osptr_t | init_arg | |||
| ) |
Initialize a stack and create a new context for a task.
| stk | Pointer to the stack. | |
| stacksize | Size of the stack. | |
| PC | Program counter. | |
| init_arg | Initial argument passed to the task. |
| static void hal_retval_set | ( | osstkptr_t | ctxt_ptr, | |
| osptr_t | retval | |||
| ) | [inline, static] |
Set a return value for a task whose context is stored.
This is only needed if TIROS_REGISTER_PASSING is defined for your port. This injects a return value into the context of a task that is currently frozen.
| ctxt_ptr | Pointer to the context of the task. | |
| retval | The return value to be injected into the task context |
Definition at line 239 of file template/tr_port.h.
| osstkptr_t hal_ctxt_switch | ( | void | ) |
Context switch from user level (non-ISR) This function is called from within an OS call, to switch the running process.
It also provides a return value. This is a pseudo return-value, This function does not actually determine the value returned. The return value is set by hal_retval_set which is often invoked when waking the process up from a blocked state. This function may have to be implemented in assembly based on the port. The function takes the following form
osstkptr_t hal_ctxt_switch(void) { osstkptr_t new_ctxtptr, current_ctxtptr; current_ctxtptr = save_current_context(); new_ctxtptr = osint_taskswitcher(current_ctxtptr); load_new_context(new_ctxtptr); // The code should not reach this far. When // new context is loaded, it will jump out of the // hal_ctxt_switch function. return 0; }
The function may also take the following form when there is no easy access to the current stack value.
osstkptr_t hal_ctxt_switch(void) { osstkptr_t ctxt_ptr, new_ctxt_ptr; ctxt_ptr = osint_running_task_ctxt(); if (stkptr != ILLEGAL_STACK) { save_current_context(ctxt_ptr); new_ctxt_ptr = osint_taskswitcher(ctxt_ptr); load_new_context(new_ctxt_ptr); } else { new_ctxt_ptr = osint_taskswitcher(ctxt_ptr); load_new_context(new_ctxt_ptr); } // The code should not reach this far. When // new context is loaded, it will jump out of the // hal_ctxt_switch function. return 0; }
| void hal_ctxt_load | ( | osstkptr_t | ctxt_ptr | ) |
Load the given context.
| ctxt_ptr | Pointer to task context |
| void hal_init | ( | void | ) |
Initialize the hardware.
Any hardware specific initialization can be performed her. Timer and kernel trap initialization can also be performed within this function.