diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-03-06 09:46:31 -0800 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-03-06 09:52:41 -0800 |
commit | d3843a5afb317bac91880f14a8a306a78ca4f577 (patch) | |
tree | 7808af0fa8464b5625214fcbfa28124e1b7bba04 /core | |
parent | 7e508c0d34a2c67b6b83bcddcd2b8c06ad41f1ab (diff) | |
download | chrome-ec-d3843a5afb317bac91880f14a8a306a78ca4f577.tar.gz |
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
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/switch.S | 2 | ||||
-rw-r--r-- | core/cortex-m/task.c | 30 |
2 files changed, 21 insertions, 11 deletions
diff --git a/core/cortex-m/switch.S b/core/cortex-m/switch.S index 4d974251cd..1e4108b173 100644 --- a/core/cortex-m/switch.S +++ b/core/cortex-m/switch.S @@ -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 */ diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index c053c027db..aed0a6b13c 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -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) { |