From 4b13d3c659240e5a8347b1ba7ab0bf1d8355eba3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 24 Oct 2012 22:46:55 -0700 Subject: altos: Add stack-guard code. Uses STM MPU to trap stack overflow. This marks the lowest portion of the stack as inaccessible to the CPU, causing the processor to fault when it reaches it. The fault then generates a panic message so that the user can know what happened. Signed-off-by: Keith Packard --- src/core/ao_task.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core/ao_task.c') diff --git a/src/core/ao_task.c b/src/core/ao_task.c index c2b1b270..df70b906 100644 --- a/src/core/ao_task.c +++ b/src/core/ao_task.c @@ -20,6 +20,9 @@ #if HAS_SAMPLE_PROFILE #include #endif +#if HAS_STACK_GUARD +#include +#endif #define AO_NO_TASK_INDEX 0xff @@ -127,6 +130,9 @@ ao_yield(void) ao_arch_naked_define ao_cur_task->start = ao_sample_profile_timer_value(); #endif } +#if HAS_STACK_GUARD + ao_mpu_stack_guard(ao_cur_task->stack); +#endif #if AO_CHECK_STACK cli(); in_yield = 0; -- cgit v1.2.3