[rtems commit] score: ISR lock API changes

Sebastian Huber sebh at rtems.org
Thu Aug 1 14:41:52 UTC 2013


Module:    rtems
Branch:    master
Commit:    8d640134ba72eecddf324c7e7496be8dd3d909ef
Changeset: http://git.rtems.org/rtems/commit/?id=8d640134ba72eecddf324c7e7496be8dd3d909ef

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Aug  1 10:11:46 2013 +0200

score: ISR lock API changes

---

 cpukit/rtems/include/rtems/rtems/intr.h    |   26 +++----------
 cpukit/score/include/rtems/score/isrlock.h |   56 +++++++++++++++++++++++++---
 testsuites/sptests/sp37/init.c             |   12 +++++-
 3 files changed, 66 insertions(+), 28 deletions(-)

diff --git a/cpukit/rtems/include/rtems/rtems/intr.h b/cpukit/rtems/include/rtems/rtems/intr.h
index ae6dfcc..2f5b9ba 100644
--- a/cpukit/rtems/include/rtems/rtems/intr.h
+++ b/cpukit/rtems/include/rtems/rtems/intr.h
@@ -186,7 +186,7 @@ typedef ISR_lock_Control rtems_interrupt_lock;
  * @see rtems_interrupt_lock_release().
  */
 #define rtems_interrupt_lock_acquire( _lock, _isr_cookie ) \
-  _ISR_lock_Acquire( _lock, _isr_cookie )
+  _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie )
 
 /**
  * @brief Releases an interrupt lock.
@@ -202,7 +202,7 @@ typedef ISR_lock_Control rtems_interrupt_lock;
  * @see rtems_interrupt_lock_acquire().
  */
 #define rtems_interrupt_lock_release( _lock, _isr_cookie ) \
-  _ISR_lock_Release( _lock, _isr_cookie )
+  _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie )
 
 /**
  * @brief Acquires an interrupt lock in the corresponding interrupt service
@@ -219,15 +219,8 @@ typedef ISR_lock_Control rtems_interrupt_lock;
  *
  * @see rtems_interrupt_lock_release_isr().
  */
-#if defined( RTEMS_SMP )
-  #define rtems_interrupt_lock_acquire_isr( _lock ) \
-    _SMP_lock_Acquire( &( _lock )->lock )
-#else
-  #define rtems_interrupt_lock_acquire_isr( _lock ) \
-    do { \
-      (void) _lock; \
-    } while (0)
-#endif
+#define rtems_interrupt_lock_acquire_isr( _lock ) \
+  _ISR_lock_Acquire( _lock )
 
 /**
  * @brief Releases an interrupt lock in the corresponding interrupt service
@@ -240,15 +233,8 @@ typedef ISR_lock_Control rtems_interrupt_lock;
  *
  * @see rtems_interrupt_lock_acquire_isr().
  */
-#if defined( RTEMS_SMP )
-  #define rtems_interrupt_lock_release_isr( _lock ) \
-    _SMP_lock_Release( &( _lock )->lock )
-#else
-  #define rtems_interrupt_lock_release_isr( _lock ) \
-    do { \
-      (void) _lock; \
-    } while (0)
-#endif
+#define rtems_interrupt_lock_release_isr( _lock ) \
+  _ISR_lock_Release( _lock )
 
 /** @} */
 
diff --git a/cpukit/score/include/rtems/score/isrlock.h b/cpukit/score/include/rtems/score/isrlock.h
index fb20a8e..56ff19b 100644
--- a/cpukit/score/include/rtems/score/isrlock.h
+++ b/cpukit/score/include/rtems/score/isrlock.h
@@ -95,13 +95,13 @@ typedef struct {
  * @param[in,out] _lock The ISR lock control.
  * @param[out] _isr_cookie The interrupt status to restore will be returned.
  *
- * @see _ISR_lock_Release().
+ * @see _ISR_lock_Release_and_ISR_enable().
  */
 #if defined( RTEMS_SMP )
-  #define _ISR_lock_Acquire( _lock, _isr_cookie ) \
+  #define _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie ) \
     _SMP_lock_ISR_disable_and_acquire( &( _lock )->lock, _isr_cookie )
 #else
-  #define _ISR_lock_Acquire( _lock, _isr_cookie ) \
+  #define _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie ) \
     do { \
       (void) _lock; \
       _ISR_Disable( _isr_cookie ); \
@@ -119,19 +119,63 @@ typedef struct {
  * @param[in,out] _lock The ISR lock control.
  * @param[in] _isr_cookie The interrupt status to restore.
  *
- * @see _ISR_lock_Acquire().
+ * @see _ISR_lock_ISR_disable_and_acquire().
  */
 #if defined( RTEMS_SMP )
-  #define _ISR_lock_Release( _lock, _isr_cookie ) \
+  #define _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie ) \
     _SMP_lock_Release_and_ISR_enable( &( _lock )->lock, _isr_cookie )
 #else
-  #define _ISR_lock_Release( _lock, _isr_cookie ) \
+  #define _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie ) \
     do { \
       (void) _lock; \
       _ISR_Enable( _isr_cookie ); \
     } while (0)
 #endif
 
+/**
+ * @brief Acquires an ISR lock inside an ISR disabled section.
+ *
+ * The interrupt status will remain unchanged.  On SMP configurations this
+ * function acquires an SMP lock.
+ *
+ * In case the executing context can be interrupted by higher priority
+ * interrupts and these interrupts enter the critical section protected by this
+ * lock, then the result is unpredictable.
+ *
+ * @param[in,out] _lock The ISR lock control.
+ *
+ * @see _ISR_lock_Release().
+ */
+#if defined( RTEMS_SMP )
+  #define _ISR_lock_Acquire( _lock ) \
+    _SMP_lock_Acquire( &( _lock )->lock )
+#else
+  #define _ISR_lock_Acquire( _lock ) \
+    do { \
+      (void) _lock; \
+    } while (0)
+#endif
+
+/**
+ * @brief Releases an ISR lock inside an ISR disabled section.
+ *
+ * The interrupt status will remain unchanged.  On SMP configurations this
+ * function releases an SMP lock.
+ *
+ * @param[in,out] _lock The ISR lock control.
+ *
+ * @see _ISR_lock_Acquire().
+ */
+#if defined( RTEMS_SMP )
+  #define _ISR_lock_Release( _lock ) \
+    _SMP_lock_Release( &( _lock )->lock )
+#else
+  #define _ISR_lock_Release( _lock ) \
+    do { \
+      (void) _lock; \
+    } while (0)
+#endif
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index 6f85c76..4ffebbb 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -54,9 +54,15 @@ static void test_isr_locks( void )
   _ISR_lock_Initialize( &lock );
   rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 );
 
-  _ISR_lock_Acquire( &lock, level );
+  _ISR_lock_ISR_disable_and_acquire( &lock, level );
   rtems_test_assert( normal_interrupt_level != _ISR_Get_level() );
-  _ISR_lock_Release( &lock, level );
+  _ISR_lock_Release_and_ISR_enable( &lock, level );
+
+  rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
+
+  _ISR_lock_Acquire( &lock );
+  rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
+  _ISR_lock_Release( &lock );
 
   rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
 }
@@ -91,6 +97,8 @@ static void test_interrupt_locks( void )
   rtems_interrupt_lock_acquire_isr( &lock );
   rtems_test_assert( normal_interrupt_level == get_interrupt_level() );
   rtems_interrupt_lock_release_isr( &lock );
+
+  rtems_test_assert( normal_interrupt_level == get_interrupt_level() );
 }
 
 void test_interrupt_inline(void)




More information about the vc mailing list