[rtems commit] score: Add _ISR_lock_ISR_disable/enable()
Sebastian Huber
sebh at rtems.org
Mon Apr 20 06:24:16 UTC 2015
Module: rtems
Branch: master
Commit: 1981b4697e43695397cf01255805d267e0e55ab1
Changeset: http://git.rtems.org/rtems/commit/?id=1981b4697e43695397cf01255805d267e0e55ab1
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Sun Apr 19 10:27:08 2015 +0200
score: Add _ISR_lock_ISR_disable/enable()
---
cpukit/score/include/rtems/score/isrlock.h | 38 ++++++++++++++++++++++++++-
cpukit/score/include/rtems/score/threadimpl.h | 2 +-
testsuites/sptests/sp37/init.c | 6 +++++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/cpukit/score/include/rtems/score/isrlock.h b/cpukit/score/include/rtems/score/isrlock.h
index 8449d5d..5a68937 100644
--- a/cpukit/score/include/rtems/score/isrlock.h
+++ b/cpukit/score/include/rtems/score/isrlock.h
@@ -184,7 +184,7 @@ typedef struct {
* This function can be used in thread and interrupt context.
*
* @param[in] _lock The ISR lock control.
- * @param[in] context The local ISR lock context for an acquire and release
+ * @param[in] _context The local ISR lock context for an acquire and release
* pair.
*
* @see _ISR_lock_Release_and_ISR_enable().
@@ -304,6 +304,42 @@ typedef struct {
_ISR_Flash( ( _context )->isr_level )
#endif
+/**
+ * @brief Disables interrupts and saves the previous interrupt state in the ISR
+ * lock context.
+ *
+ * This function can be used in thread and interrupt context.
+ *
+ * @param[in] _context The local ISR lock context to store the interrupt state.
+ *
+ * @see _ISR_lock_ISR_enable().
+ */
+#if defined( RTEMS_SMP )
+ #define _ISR_lock_ISR_disable( _context ) \
+ _ISR_Disable_without_giant( ( _context )->Lock_context.isr_level )
+#else
+ #define _ISR_lock_ISR_disable( _context ) \
+ _ISR_Disable( ( _context )->isr_level )
+#endif
+
+/**
+ * @brief Restores the saved interrupt state of the ISR lock context.
+ *
+ * This function can be used in thread and interrupt context.
+ *
+ * @param[in] _context The local ISR lock context containing the saved
+ * interrupt state.
+ *
+ * @see _ISR_lock_ISR_disable().
+ */
+#if defined( RTEMS_SMP )
+ #define _ISR_lock_ISR_enable( _context ) \
+ _ISR_Enable_without_giant( ( _context )->Lock_context.isr_level )
+#else
+ #define _ISR_lock_ISR_enable( _context ) \
+ _ISR_Enable( ( _context )->isr_level )
+#endif
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index a13a0de..1ccc4d6 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -898,7 +898,7 @@ RTEMS_INLINE_ROUTINE ISR_lock_Control *_Thread_Lock_acquire(
while ( true ) {
uint32_t my_generation;
- _ISR_Disable_without_giant( lock_context->Lock_context.isr_level );
+ _ISR_lock_ISR_disable( lock_context );
my_generation = the_thread->Lock.generation;
/*
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index e8c415d..aaaf684 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -185,6 +185,12 @@ static void test_isr_locks( void )
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
+ _ISR_lock_ISR_disable( &lock_context );
+ rtems_test_assert( normal_interrupt_level != _ISR_Get_level() );
+ _ISR_lock_ISR_enable( &lock_context );
+
+ rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
+
_ISR_lock_Acquire( &lock, &lock_context );
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
_ISR_lock_Release( &lock, &lock_context );
More information about the vc
mailing list