From 46e4a207af4059c1274f11bea865a7473b816923 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 25 Sep 2010 05:53:16 +0000 Subject: [PATCH] Fixed bug 3064274. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.0.x@2190 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/ports/GCC/ARMCMx/old/chcore_v7m.h | 26 ++++++++++++++++---------- readme.txt | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/os/ports/GCC/ARMCMx/old/chcore_v7m.h b/os/ports/GCC/ARMCMx/old/chcore_v7m.h index 4d225985e..d5e3995af 100644 --- a/os/ports/GCC/ARMCMx/old/chcore_v7m.h +++ b/os/ports/GCC/ARMCMx/old/chcore_v7m.h @@ -270,17 +270,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" { diff --git a/readme.txt b/readme.txt index a39e77a4a..b2fd4935a 100644 --- a/readme.txt +++ b/readme.txt @@ -59,6 +59,8 @@ ***************************************************************************** *** 2.0.5 *** +- FIX: Fixed broken CH_DBG_ENABLE_STACK_CHECK option in legacy CM3 port (bug + 3064274). - FIX: Fixed CAN_USE_SLEEP_MODE setting (bug 3064204). *** 2.0.4 ***