aboutsummaryrefslogtreecommitdiffstats
path: root/os/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-09-11 13:49:28 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-09-11 13:49:28 +0000
commitfb439b48b91534c3dd00f204b5023d0528d93ad8 (patch)
treef01bb159292de51667b6e5667a76339a37deee0c /os/ports
parent781b0b129cccbecba160effce8c4ddd68295b8b9 (diff)
downloadChibiOS-fb439b48b91534c3dd00f204b5023d0528d93ad8.tar.gz
ChibiOS-fb439b48b91534c3dd00f204b5023d0528d93ad8.tar.bz2
ChibiOS-fb439b48b91534c3dd00f204b5023d0528d93ad8.zip
Fixed bug Fixed bug 3064274.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2176 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports')
-rw-r--r--os/ports/GCC/ARMCMx/old/chcore_v7m.h26
1 files changed, 16 insertions, 10 deletions
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" {