diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-03-19 18:19:39 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-03-19 18:19:39 +0000 |
commit | 9d812b5db3c21ff09e30a115c7643f7fec5492a3 (patch) | |
tree | b669498cee843fc6130b3530a145a73c1e2c70a0 /os/ports/RVCT | |
parent | 84cc66dce9b5c8d0cfee1dcb5126f66a60c3f226 (diff) | |
download | ChibiOS-9d812b5db3c21ff09e30a115c7643f7fec5492a3.tar.gz ChibiOS-9d812b5db3c21ff09e30a115c7643f7fec5492a3.tar.bz2 ChibiOS-9d812b5db3c21ff09e30a115c7643f7fec5492a3.zip |
Added stack checking to the RVCT Cortex-Mx port.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2835 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports/RVCT')
-rw-r--r-- | os/ports/RVCT/ARMCMx/chcore_v6m.h | 9 | ||||
-rw-r--r-- | os/ports/RVCT/ARMCMx/chcore_v7m.h | 11 |
2 files changed, 19 insertions, 1 deletions
diff --git a/os/ports/RVCT/ARMCMx/chcore_v6m.h b/os/ports/RVCT/ARMCMx/chcore_v6m.h index 970fc3b8d..9c5e35b33 100644 --- a/os/ports/RVCT/ARMCMx/chcore_v6m.h +++ b/os/ports/RVCT/ARMCMx/chcore_v6m.h @@ -208,7 +208,16 @@ struct intctx { * @param[in] ntp the thread to be switched in
* @param[in] otp the thread to be switched out
*/
+#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#else
+#define port_switch(ntp, otp) { \
+ struct intctx *r13 = (struct intctx *)__current_sp(); \
+ if ((void *)(r13 - 1) < (void *)(otp + 1)) \
+ chDbgPanic("stack overflow"); \
+ _port_switch(ntp, otp); \
+}
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/os/ports/RVCT/ARMCMx/chcore_v7m.h b/os/ports/RVCT/ARMCMx/chcore_v7m.h index 45f9843e3..3a4cbe381 100644 --- a/os/ports/RVCT/ARMCMx/chcore_v7m.h +++ b/os/ports/RVCT/ARMCMx/chcore_v7m.h @@ -234,7 +234,16 @@ struct intctx { * @param[in] ntp the thread to be switched in
* @param[in] otp the thread to be switched out
*/
-#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
+#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#else
+#define port_switch(ntp, otp) { \
+ struct intctx *r13 = (struct intctx *)__current_sp(); \
+ if ((void *)(r13 - 1) < (void *)(otp + 1)) \
+ chDbgPanic("stack overflow"); \
+ _port_switch(ntp, otp); \
+}
+#endif
#ifdef __cplusplus
extern "C" {
|