diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-29 20:58:35 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-03-29 20:58:35 +0000 |
commit | e475309b5c1e6ccb76c59e19b04085526a6e8e5e (patch) | |
tree | 387c365df5e9a6b593fa41e0cca2e54a598a6d4f | |
parent | 97436c3443db58bc802dc33e5d1a02763f5a48da (diff) | |
download | ChibiOS-e475309b5c1e6ccb76c59e19b04085526a6e8e5e.tar.gz ChibiOS-e475309b5c1e6ccb76c59e19b04085526a6e8e5e.tar.bz2 ChibiOS-e475309b5c1e6ccb76c59e19b04085526a6e8e5e.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1806 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/ports/GCC/ARMCMx/chcore.c | 5 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/chcore.h | 15 |
2 files changed, 15 insertions, 5 deletions
diff --git a/os/ports/GCC/ARMCMx/chcore.c b/os/ports/GCC/ARMCMx/chcore.c index 9d0f6b060..f547ea60c 100644 --- a/os/ports/GCC/ARMCMx/chcore.c +++ b/os/ports/GCC/ARMCMx/chcore.c @@ -34,6 +34,11 @@ regarm_t _port_saved_pc;
/**
+ * @brief IRQ nesting counter. + */
+unsigned _port_irq_nesting;
+
+/**
* @brief Halts the system.
* @note The function is declared as a weak symbol, it is possible
* to redefine it in your application code.
diff --git a/os/ports/GCC/ARMCMx/chcore.h b/os/ports/GCC/ARMCMx/chcore.h index 5a8d3c9ad..80266c79b 100644 --- a/os/ports/GCC/ARMCMx/chcore.h +++ b/os/ports/GCC/ARMCMx/chcore.h @@ -202,7 +202,11 @@ struct context { * @details This macro must be inserted at the start of all IRQ handlers
* enabled to invoke system APIs.
*/
-#define PORT_IRQ_PROLOGUE()
+#define PORT_IRQ_PROLOGUE() { \
+ chSysLockFromIsr(); \
+ _port_irq_nesting++; \
+ chSysUnlockFromIsr(); \
+}
/**
* @brief IRQ epilogue code.
@@ -211,8 +215,7 @@ struct context { */
#define PORT_IRQ_EPILOGUE() { \
chSysLockFromIsr(); \
- if (((SCB_ICSR & ICSR_VECTPENDING_MASK) == 0) && \
- chSchIsRescRequiredExI()) { \
+ if ((--_port_irq_nesting == 0) && chSchIsRescRequiredExI()) { \
register struct cmxctx *ctxp asm ("r3"); \
\
asm volatile ("mrs %0, PSP" : "=r" (ctxp) : "r" (ctxp)); \
@@ -232,9 +235,10 @@ struct context { /**
* @brief Port-related initialization code.
- * @note This function is empty in this port.
*/
-#define port_init()
+#define port_init() { \
+ _port_irq_nesting = 0; \
+}
/**
* @brief Kernel-lock action.
@@ -306,6 +310,7 @@ struct context { #if !defined(__DOXYGEN__)
extern regarm_t _port_saved_pc;
+extern unsigned _port_irq_nesting;
#endif
#ifdef __cplusplus
|