diff options
Diffstat (limited to 'cpukit/score/include/rtems/score/isrlock.h')
-rw-r--r-- | cpukit/score/include/rtems/score/isrlock.h | 110 |
1 files changed, 68 insertions, 42 deletions
diff --git a/cpukit/score/include/rtems/score/isrlock.h b/cpukit/score/include/rtems/score/isrlock.h index 56ff19b803..e118475968 100644 --- a/cpukit/score/include/rtems/score/isrlock.h +++ b/cpukit/score/include/rtems/score/isrlock.h @@ -51,12 +51,23 @@ extern "C" { * @brief ISR lock control. */ typedef struct { - #if defined( RTEMS_SMP ) - SMP_lock_Control lock; - #endif +#if defined( RTEMS_SMP ) + SMP_lock_Control lock; +#endif } ISR_lock_Control; /** + * @brief Local ISR lock context for acquire and release pairs. + */ +typedef struct { +#if defined( RTEMS_SMP ) + SMP_lock_Context lock_context; +#else + ISR_Level isr_level; +#endif +} ISR_lock_Context; + +/** * @brief Initializer for static initialization of ISR locks. */ #if defined( RTEMS_SMP ) @@ -72,17 +83,16 @@ typedef struct { * * Concurrent initialization leads to unpredictable results. * - * @param[in,out] _lock The ISR lock control. + * @param[in,out] lock The ISR lock control. */ +static inline void _ISR_lock_Initialize( ISR_lock_Control *lock ) +{ #if defined( RTEMS_SMP ) - #define _ISR_lock_Initialize( _lock ) \ - _SMP_lock_Initialize( &( _lock )->lock ) + _SMP_lock_Initialize( &lock->lock ); #else - #define _ISR_lock_Initialize( _lock ) \ - do { \ - (void) _lock; \ - } while (0) + (void) lock; #endif +} /** * @brief Acquires an ISR lock. @@ -92,21 +102,24 @@ typedef struct { * * This function can be used in thread and interrupt context. * - * @param[in,out] _lock The ISR lock control. - * @param[out] _isr_cookie The interrupt status to restore will be returned. + * @param[in,out] lock The ISR lock control. + * @param[in,out] context The local ISR lock context for an acquire and release + * pair. * * @see _ISR_lock_Release_and_ISR_enable(). */ +static inline void _ISR_lock_ISR_disable_and_acquire( + ISR_lock_Control *lock, + ISR_lock_Context *context +) +{ #if defined( RTEMS_SMP ) - #define _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie ) \ - _SMP_lock_ISR_disable_and_acquire( &( _lock )->lock, _isr_cookie ) + _SMP_lock_ISR_disable_and_acquire( &lock->lock, &context->lock_context ); #else - #define _ISR_lock_ISR_disable_and_acquire( _lock, _isr_cookie ) \ - do { \ - (void) _lock; \ - _ISR_Disable( _isr_cookie ); \ - } while (0) + (void) lock; + _ISR_Disable( context->isr_level ); #endif +} /** * @brief Releases an ISR lock. @@ -116,21 +129,24 @@ typedef struct { * * This function can be used in thread and interrupt context. * - * @param[in,out] _lock The ISR lock control. - * @param[in] _isr_cookie The interrupt status to restore. + * @param[in,out] lock The ISR lock control. + * @param[in,out] context The local ISR lock context for an acquire and release + * pair. * * @see _ISR_lock_ISR_disable_and_acquire(). */ +static inline void _ISR_lock_Release_and_ISR_enable( + ISR_lock_Control *lock, + ISR_lock_Context *context +) +{ #if defined( RTEMS_SMP ) - #define _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie ) \ - _SMP_lock_Release_and_ISR_enable( &( _lock )->lock, _isr_cookie ) + _SMP_lock_Release_and_ISR_enable( &lock->lock, &context->lock_context ); #else - #define _ISR_lock_Release_and_ISR_enable( _lock, _isr_cookie ) \ - do { \ - (void) _lock; \ - _ISR_Enable( _isr_cookie ); \ - } while (0) + (void) lock; + _ISR_Enable( context->isr_level ); #endif +} /** * @brief Acquires an ISR lock inside an ISR disabled section. @@ -142,19 +158,24 @@ typedef struct { * 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. + * @param[in,out] lock The ISR lock control. + * @param[in,out] context The local ISR lock context for an acquire and release + * pair. * * @see _ISR_lock_Release(). */ +static inline void _ISR_lock_Acquire( + ISR_lock_Control *lock, + ISR_lock_Context *context +) +{ #if defined( RTEMS_SMP ) - #define _ISR_lock_Acquire( _lock ) \ - _SMP_lock_Acquire( &( _lock )->lock ) + _SMP_lock_Acquire( &lock->lock, &context->lock_context ); #else - #define _ISR_lock_Acquire( _lock ) \ - do { \ - (void) _lock; \ - } while (0) + (void) lock; + (void) context; #endif +} /** * @brief Releases an ISR lock inside an ISR disabled section. @@ -162,19 +183,24 @@ typedef struct { * The interrupt status will remain unchanged. On SMP configurations this * function releases an SMP lock. * - * @param[in,out] _lock The ISR lock control. + * @param[in,out] lock The ISR lock control. + * @param[in,out] context The local ISR lock context for an acquire and release + * pair. * * @see _ISR_lock_Acquire(). */ +static inline void _ISR_lock_Release( + ISR_lock_Control *lock, + ISR_lock_Context *context +) +{ #if defined( RTEMS_SMP ) - #define _ISR_lock_Release( _lock ) \ - _SMP_lock_Release( &( _lock )->lock ) + _SMP_lock_Release( &lock->lock, &context->lock_context ); #else - #define _ISR_lock_Release( _lock ) \ - do { \ - (void) _lock; \ - } while (0) + (void) lock; + (void) context; #endif +} /** @} */ |