From 73a6c86af1bb7f4c16f5aaf8d170176adc609fc8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Feb 2009 11:14:24 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@798 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- ports/ARM7/chcore.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ports') diff --git a/ports/ARM7/chcore.h b/ports/ARM7/chcore.h index e2c6481b5..5cc6fc276 100644 --- a/ports/ARM7/chcore.h +++ b/ports/ARM7/chcore.h @@ -277,9 +277,34 @@ struct context { * @param ntp the thread to be switched in */ #ifdef THUMB +#if CH_DBG_ENABLE_STACK_CHECK +#define port_switch(otp, ntp) { \ + register Thread *_otp asm ("r0") = (otp); \ + register Thread *_ntp asm ("r1") = (ntp); \ + register char *sp asm ("sp"); \ + if (sp - sizeof(struct intctx) - sizeof(Thread) < (char *)_otp) \ + asm volatile ("mov r0, #0 \n\t" \ + "ldr r1, =chDbgPanic \n\t" \ + "bx r1"); \ + _port_switch_thumb(_otp, _ntp); \ +} +#else /* !CH_DBG_ENABLE_STACK_CHECK */ #define port_switch(otp, ntp) _port_switch_thumb(otp, ntp) +#endif /* !CH_DBG_ENABLE_STACK_CHECK */ #else /* !THUMB */ +#if CH_DBG_ENABLE_STACK_CHECK +#define port_switch(otp, ntp) { \ + register Thread *_otp asm ("r0") = (otp); \ + register Thread *_ntp asm ("r1") = (ntp); \ + register char *sp asm ("sp"); \ + if (sp - sizeof(struct intctx) - sizeof(Thread) < (char *)_otp) \ + asm volatile ("mov r0, #0 \n\t" \ + "b chDbgPanic"); \ + _port_switch_arm(_otp, _ntp); \ +} +#else /* !CH_DBG_ENABLE_STACK_CHECK */ #define port_switch(otp, ntp) _port_switch_arm(otp, ntp) +#endif /* !CH_DBG_ENABLE_STACK_CHECK */ #endif /* !THUMB */ #ifdef __cplusplus -- cgit v1.2.3