From 1981b4697e43695397cf01255805d267e0e55ab1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sun, 19 Apr 2015 10:27:08 +0200 Subject: 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 8449d5d64f..5a68937b4d 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 a13a0decc1..1ccc4d6c50 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 e8c415d5a7..aaaf68426b 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 ); -- cgit v1.2.3