From bb5acac94d079e107f8faa4bb6b2e5d1389c40d4 Mon Sep 17 00:00:00 2001
From: gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>
Date: Mon, 5 Jan 2009 11:45:26 +0000
Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@579
 35acf78f-673a-0410-8e92-d51de3d6d3f4

---
 src/chinit.c           | 27 +++++++++++++++++++++++++++
 src/templates/chconf.h |  9 +++++++++
 2 files changed, 36 insertions(+)

(limited to 'src')

diff --git a/src/chinit.c b/src/chinit.c
index a675d6910..613e7bfeb 100644
--- a/src/chinit.c
+++ b/src/chinit.c
@@ -76,4 +76,31 @@ void chSysTimerHandlerI(void) {
   chVTDoTickI();
 }
 
+#if !defined(CH_OPTIMIZE_SPEED)
+/**
+ * Enters the ChibiOS/RT system mutual exclusion zone.
+ * @note The use of system mutual exclusion zone is not recommended in
+ *       the user code, it is a better idea to use the semaphores or mutexes
+ *       instead.
+ * @see CH_USE_NESTED_LOCKS
+ */
+void chSysLock(void) {
+
+  chSysLockInline();
+}
+
+/**
+ * Leaves the ChibiOS/RT system mutual exclusion zone.
+ * @note The use of system mutual exclusion zone is not recommended in
+ *       the user code, it is a better idea to use the semaphores or mutexes
+ *       instead.
+ * @see CH_USE_NESTED_LOCKS
+ */
+void chSysUnlock(void) {
+
+  chDbgAssert(currp->p_locks > 0, "chinit.c, chSysUnlock()");
+  chSysUnlockInline();
+}
+#endif /* !CH_OPTIMIZE_SPEED */
+
 /** @} */
diff --git a/src/templates/chconf.h b/src/templates/chconf.h
index a6071493b..005748b83 100644
--- a/src/templates/chconf.h
+++ b/src/templates/chconf.h
@@ -35,6 +35,15 @@
  *  that this is not related to the compiler optimization options.*/
 #define CH_OPTIMIZE_SPEED
 
+/** Configuration option: If enabled then the used of nested @p chSysLock() /
+ *  @p chSysUnlock() operations is allowed.<br>
+ *  For performance and code size reasons the recommended setting is leave
+ *  this option disabled.<br>
+ *  You can use this option if you need to merge with ChibiOS/RT external
+ *  libraries that require nested lock/unlock operations.
+ */
+#define CH_USE_NESTED_LOCKS
+
 /** Configuration option: if specified then the kernel performs the round
  *  robin scheduling algorithm on threads of equal priority.*/
 #define CH_USE_ROUNDROBIN
-- 
cgit v1.2.3