aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-12 16:05:36 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-08-12 16:05:36 +0000
commit46c0e6255e9d3013ce6308cd1fa494d6550fa80e (patch)
tree510f5b71e8d02cff493dff4215364dc9517be918 /os
parent80284bf64ae30d7c28adc1ff550c7423db53d418 (diff)
downloadChibiOS-46c0e6255e9d3013ce6308cd1fa494d6550fa80e.tar.gz
ChibiOS-46c0e6255e9d3013ce6308cd1fa494d6550fa80e.tar.bz2
ChibiOS-46c0e6255e9d3013ce6308cd1fa494d6550fa80e.zip
Added chSysConditionalLock() and chSysConditionalUnlock() functions to RT and NIL. Improved debug documentation.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7166 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/nil/include/nil.h10
-rw-r--r--os/nil/src/nil.c26
-rw-r--r--os/rt/include/chsys.h34
-rw-r--r--os/rt/src/chdebug.c32
4 files changed, 94 insertions, 8 deletions
diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h
index 109f99533..47f93af0b 100644
--- a/os/nil/include/nil.h
+++ b/os/nil/include/nil.h
@@ -587,21 +587,21 @@ typedef struct {
#define chSysEnable() port_enable()
/**
- * @brief Enters the kernel lock mode.
+ * @brief Enters the kernel lock state.
*
* @special
*/
#define chSysLock() port_lock()
/**
- * @brief Leaves the kernel lock mode.
+ * @brief Leaves the kernel lock state.
*
* @special
*/
#define chSysUnlock() port_unlock()
/**
- * @brief Enters the kernel lock mode from within an interrupt handler.
+ * @brief Enters the kernel lock state from within an interrupt handler.
* @note This API may do nothing on some architectures, it is required
* because on ports that support preemptable interrupt handlers
* it is required to raise the interrupt mask to the same level of
@@ -615,7 +615,7 @@ typedef struct {
#define chSysLockFromISR() port_lock_from_isr()
/**
- * @brief Leaves the kernel lock mode from within an interrupt handler.
+ * @brief Leaves the kernel lock state from within an interrupt handler.
*
* @note This API may do nothing on some architectures, it is required
* because on ports that support preemptable interrupt handlers
@@ -835,6 +835,8 @@ extern "C" {
void chSysInit(void);
void chSysHalt(const char *reason);
void chSysTimerHandlerI(void);
+ void chSysConditionalLock(void);
+ void chSysConditionalUnlock(void);
syssts_t chSysGetStatusAndLockX(void);
void chSysRestoreStatusX(syssts_t sts);
thread_t *chSchReadyI(thread_t *tp, msg_t msg);
diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c
index 3462b735a..48f640b09 100644
--- a/os/nil/src/nil.c
+++ b/os/nil/src/nil.c
@@ -219,6 +219,32 @@ void chSysTimerHandlerI(void) {
}
/**
+ * @brief Conditionally enters the kernel lock state.
+ * @note Can be called without previous knowledge of the current lock state.
+ * The final state is "s-locked".
+ *
+ * @special
+ */
+void chSysConditionalLock(void) {
+
+ if (port_irq_enabled(port_get_irq_status()))
+ chSysLock();
+}
+
+/**
+ * @brief Conditionally leaves the kernel lock state.
+ * @note Can be called without previous knowledge of the current lock state.
+ * The final state is "normal".
+ *
+ * @special
+ */
+void chSysConditionalUnlock(void) {
+
+ if (!port_irq_enabled(port_get_irq_status()))
+ chSysUnlock();
+}
+
+/**
* @brief Returns the execution status and enters a critical zone.
* @details This functions enters into a critical zone and can be called
* from any context. Because its flexibility it is less efficient
diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h
index bd2d0dffa..5b7355ade 100644
--- a/os/rt/include/chsys.h
+++ b/os/rt/include/chsys.h
@@ -291,7 +291,7 @@ static inline void chSysEnable(void) {
}
/**
- * @brief Enters the kernel lock mode.
+ * @brief Enters the kernel lock state.
*
* @special
*/
@@ -303,7 +303,7 @@ static inline void chSysLock(void) {
}
/**
- * @brief Leaves the kernel lock mode.
+ * @brief Leaves the kernel lock state.
*
* @special
*/
@@ -323,7 +323,7 @@ static inline void chSysUnlock(void) {
}
/**
- * @brief Enters the kernel lock mode from within an interrupt handler.
+ * @brief Enters the kernel lock state from within an interrupt handler.
* @note This API may do nothing on some architectures, it is required
* because on ports that support preemptable interrupt handlers
* it is required to raise the interrupt mask to the same level of
@@ -342,7 +342,7 @@ static inline void chSysLockFromISR(void) {
}
/**
- * @brief Leaves the kernel lock mode from within an interrupt handler.
+ * @brief Leaves the kernel lock state from within an interrupt handler.
*
* @note This API may do nothing on some architectures, it is required
* because on ports that support preemptable interrupt handlers
@@ -361,6 +361,32 @@ static inline void chSysUnlockFromISR(void) {
port_unlock_from_isr();
}
+/**
+ * @brief Conditionally enters the kernel lock state.
+ * @note Can be called without previous knowledge of the current lock state.
+ * The final state is "s-locked".
+ *
+ * @special
+ */
+static inline void chSysConditionalLock(void) {
+
+ if (port_irq_enabled(port_get_irq_status()))
+ chSysLock();
+}
+
+/**
+ * @brief Conditionally leaves the kernel lock state.
+ * @note Can be called without previous knowledge of the current lock state.
+ * The final state is "normal".
+ *
+ * @special
+ */
+static inline void chSysConditionalUnlock(void) {
+
+ if (!port_irq_enabled(port_get_irq_status()))
+ chSysUnlock();
+}
+
#endif /* _CHSYS_H_ */
/** @} */
diff --git a/os/rt/src/chdebug.c b/os/rt/src/chdebug.c
index c18788454..d1b792921 100644
--- a/os/rt/src/chdebug.c
+++ b/os/rt/src/chdebug.c
@@ -27,16 +27,48 @@
* - Runtime system state and call protocol check. The following
* panic messages can be generated:
* - SV#1, misplaced @p chSysDisable().
+ * - Called from an ISR.
+ * - Called from a critical zone.
+ * .
* - SV#2, misplaced @p chSysSuspend()
+ * - Called from an ISR.
+ * - Called from a critical zone.
+ * .
* - SV#3, misplaced @p chSysEnable().
+ * - Called from an ISR.
+ * - Called from a critical zone.
+ * .
* - SV#4, misplaced @p chSysLock().
+ * - Called from an ISR.
+ * - Called from a critical zone.
+ * .
* - SV#5, misplaced @p chSysUnlock().
+ * - Called from an ISR.
+ * - Not called from a critical zone.
+ * .
* - SV#6, misplaced @p chSysLockFromIsr().
+ * - Not called from an ISR.
+ * - Called from a critical zone.
+ * .
* - SV#7, misplaced @p chSysUnlockFromIsr().
+ * - Not called from an ISR.
+ * - Not called from a critical zone.
+ * .
* - SV#8, misplaced @p CH_IRQ_PROLOGUE().
+ * - Not called at ISR begin.
+ * - Called from a critical zone.
+ * .
* - SV#9, misplaced @p CH_IRQ_EPILOGUE().
+ * - @p CH_IRQ_PROLOGUE() missing.
+ * - Not called at ISR end.
+ * - Called from a critical zone.
+ * .
* - SV#10, misplaced I-class function.
+ * - I-class function not called from within a critical zone.
+ * .
* - SV#11, misplaced S-class function.
+ * - S-class function not called from within a critical zone.
+ * - Called from an ISR.
* .
* - Trace buffer.
* - Parameters check.