From fb439b48b91534c3dd00f204b5023d0528d93ad8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 11 Sep 2010 13:49:28 +0000 Subject: Fixed bug Fixed bug 3064274. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2176 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/ports/GCC/ARMCMx/old/chcore_v7m.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'os') diff --git a/os/ports/GCC/ARMCMx/old/chcore_v7m.h b/os/ports/GCC/ARMCMx/old/chcore_v7m.h index 9b92b851a..480542db1 100644 --- a/os/ports/GCC/ARMCMx/old/chcore_v7m.h +++ b/os/ports/GCC/ARMCMx/old/chcore_v7m.h @@ -263,17 +263,23 @@ struct intctx { * @param[in] ntp the thread to be switched in * @param[in] otp the thread to be switched out */ -static INLINE void port_switch(Thread *ntp, Thread *otp) { - register Thread *_ntp asm ("r0") = (ntp); - register Thread *_otp asm ("r1") = (otp); -#if CH_DBG_ENABLE_STACK_CHECK - register char *sp asm ("sp"); - if (sp - sizeof(struct intctx) - sizeof(Thread) < (char *)_otp) - asm volatile ("movs r0, #0 \n\t" - "b chDbgPanic"); -#endif /* CH_DBG_ENABLE_STACK_CHECK */ - asm volatile ("svc #0" : : "r" (_otp), "r" (_ntp) : "memory"); +#if !CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__) +#define port_switch(ntp, otp) { \ + register Thread *_ntp asm ("r0") = (ntp); \ + register Thread *_otp asm ("r1") = (otp); \ + asm volatile ("svc #0" : : "r" (_otp), "r" (_ntp) : "memory"); \ +} +#else /* CH_DBG_ENABLE_STACK_CHECK */ +#define port_switch(ntp, otp) { \ + register Thread *_ntp asm ("r0") = (ntp); \ + register Thread *_otp asm ("r1") = (otp); \ + register struct intctx *r13 asm ("r13"); \ + if ((void *)(r13 - 1) < (void *)(_otp + 1)) \ + asm volatile ("movs r0, #0 \n\t" \ + "b chDbgPanic"); \ + asm volatile ("svc #0" : : "r" (_otp), "r" (_ntp) : "memory"); \ } +#endif /* CH_DBG_ENABLE_STACK_CHECK */ #ifdef __cplusplus extern "C" { -- cgit v1.2.3