diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-07-24 14:54:26 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-07-24 14:54:26 +0000 |
commit | 40f413d3c97a7694703938cd031ce15912b29ff7 (patch) | |
tree | 67e9f3bdbefa23aba17e4b78ee92b91daa92197c /os/kernel/src/chsys.c | |
parent | fa64f08fc1ad45d0984828695697f6abde7e8ffd (diff) | |
download | ChibiOS-40f413d3c97a7694703938cd031ce15912b29ff7.tar.gz ChibiOS-40f413d3c97a7694703938cd031ce15912b29ff7.tar.bz2 ChibiOS-40f413d3c97a7694703938cd031ce15912b29ff7.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6025 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src/chsys.c')
-rw-r--r-- | os/kernel/src/chsys.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index 97f01f933..61157b1b9 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -117,7 +117,7 @@ void chSysInit(void) { /* Now this instructions flow becomes the main thread.*/
setcurrp(_thread_init(&mainthread, NORMALPRIO));
- currp->p_state = THD_STATE_CURRENT;
+ currp->p_state = CH_STATE_CURRENT;
#if CH_DBG_ENABLE_STACK_CHECK
/* This is a special case because the main thread thread_t structure is not
adjacent to its stack area.*/
@@ -191,4 +191,47 @@ void chSysTimerHandlerI(void) { #endif
}
+
+/**
+ * @brief Returns the execution context and enters the kernel lock mode.
+ * @details This functions enters into a critical zone and can be called
+ * from any context. Because its flexibility it is less efficient
+ * than @p chSysLock() which is preferable when the calling context
+ * is known.
+ *
+ * @return The previous system status, the encoding of this
+ * status word is architecture-dependent but zero is
+ * assumed to mean not-locked.
+ *
+ * @special
+ */
+syssts_t chSysGetAndLockX(void) {
+
+ syssts_t sts = port_get_status();
+ if (!sts) {
+ if (port_get_context())
+ chSysLockFromISR();
+ else
+ chSysLock();
+ }
+ return sts;
+}
+
+/**
+ * @brief Restores the specified execution status.
+ *
+ * @param[in] sts the system status to be restored.
+ *
+ * @special
+ */
+void chSysRestoreLockX(syssts_t sts) {
+
+ if (!sts) {
+ if (port_get_context())
+ chSysUnlockFromISR();
+ else
+ chSysUnlock();
+ }
+}
+
/** @} */
|