mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-16 10:01:27 +00:00
Add a trap for tasks which exit their task functions
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8350 TEST=manual Hack a task function to return. Then see that it prints an error to the debug console and the EC continues running, instead of seeing a hard-fault. Change-Id: Iacd2b83c4d4845bb8e6c61e07c3150df8edc7e49
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
*
|
||||
* must be called from interrupt context
|
||||
*
|
||||
* the structure of tje saved context on the stack is :
|
||||
* the structure of the saved context on the stack is :
|
||||
* r0, r1, r2, r3, r12, lr, pc, psr, r4, r5, r6, r7, r8, r9, r10, r11
|
||||
* exception frame <|> additional registers
|
||||
*/
|
||||
|
||||
@@ -39,15 +39,34 @@ void __idle(void);
|
||||
CONFIG_TASK_LIST
|
||||
#undef TASK
|
||||
|
||||
/* store the task names for easier debugging */
|
||||
#define TASK(n, r, d) #n,
|
||||
#include TASK_LIST
|
||||
static const char * const task_names[] = {
|
||||
"<< idle >>",
|
||||
CONFIG_TASK_LIST
|
||||
};
|
||||
#undef TASK
|
||||
|
||||
extern void __switchto(task_ *from, task_ *to);
|
||||
|
||||
|
||||
static void task_exit_trap(void)
|
||||
{
|
||||
int i = task_get_current();
|
||||
uart_printf("[Task %d (%s) exited!]\n", i, task_names[i]);
|
||||
/* Exited tasks simply sleep forever */
|
||||
while (1)
|
||||
task_wait_msg(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* declare and fill the contexts for all the tasks */
|
||||
#define TASK(n, r, d) { \
|
||||
.context[0] = (uint32_t)(tasks + TASK_ID_##n + 1) - 64, \
|
||||
.context[TASK_SIZE/4 - 8/*r0*/] = (uint32_t)d, \
|
||||
/* TODO set a LR to a trap */ \
|
||||
.context[TASK_SIZE/4 - 3/*lr*/] = (uint32_t)task_exit_trap, \
|
||||
.context[TASK_SIZE/4 - 2/*pc*/] = (uint32_t)r, \
|
||||
.context[TASK_SIZE/4 - 1/*psr*/] = 0x01000000 },
|
||||
#include TASK_LIST
|
||||
@@ -353,15 +372,6 @@ void mutex_unlock(struct mutex *mtx)
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
||||
/* store the task names for easier debugging */
|
||||
#define TASK(n, r, d) #n,
|
||||
#include TASK_LIST
|
||||
static const char * const task_names[] = {
|
||||
"<< idle >>",
|
||||
CONFIG_TASK_LIST
|
||||
};
|
||||
#undef TASK
|
||||
|
||||
|
||||
int command_task_info(int argc, char **argv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user