aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include
diff options
context:
space:
mode:
Diffstat (limited to 'os/rt/include')
-rw-r--r--os/rt/include/chsys.h34
1 files changed, 30 insertions, 4 deletions
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_ */
/** @} */