forked from Imagelibrary/rtems
score: Improve debug support for ISR locks
Ensure that interrupts are disabled while acquiring an ISR lock.
This commit is contained in:
@@ -342,8 +342,16 @@ typedef ISR_lock_Context rtems_interrupt_lock_context;
|
|||||||
*
|
*
|
||||||
* @see rtems_interrupt_lock_release_isr().
|
* @see rtems_interrupt_lock_release_isr().
|
||||||
*/
|
*/
|
||||||
#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
|
#if defined(RTEMS_SMP)
|
||||||
_ISR_lock_Acquire( _lock, _lock_context )
|
#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
|
||||||
|
_SMP_lock_Acquire( \
|
||||||
|
&( _lock )->Lock, \
|
||||||
|
&( _lock_context )->Lock_context \
|
||||||
|
)
|
||||||
|
#else
|
||||||
|
#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \
|
||||||
|
do { (void) _lock_context; } while ( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Releases an interrupt lock in the corresponding interrupt service
|
* @brief Releases an interrupt lock in the corresponding interrupt service
|
||||||
@@ -358,8 +366,16 @@ typedef ISR_lock_Context rtems_interrupt_lock_context;
|
|||||||
*
|
*
|
||||||
* @see rtems_interrupt_lock_acquire_isr().
|
* @see rtems_interrupt_lock_acquire_isr().
|
||||||
*/
|
*/
|
||||||
#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
|
#if defined(RTEMS_SMP)
|
||||||
_ISR_lock_Release( _lock, _lock_context )
|
#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
|
||||||
|
_SMP_lock_Release( \
|
||||||
|
&( _lock )->Lock, \
|
||||||
|
&( _lock_context )->Lock_context \
|
||||||
|
)
|
||||||
|
#else
|
||||||
|
#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \
|
||||||
|
do { (void) _lock_context; } while ( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved.
|
* Copyright (c) 2013, 2019 embedded brains GmbH. All rights reserved.
|
||||||
*
|
*
|
||||||
* embedded brains GmbH
|
* embedded brains GmbH
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
@@ -267,13 +267,16 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
|
|||||||
*/
|
*/
|
||||||
#if defined( RTEMS_SMP )
|
#if defined( RTEMS_SMP )
|
||||||
#define _ISR_lock_Acquire( _lock, _context ) \
|
#define _ISR_lock_Acquire( _lock, _context ) \
|
||||||
|
do { \
|
||||||
|
_Assert( _ISR_Get_level() != 0 ); \
|
||||||
_SMP_lock_Acquire( \
|
_SMP_lock_Acquire( \
|
||||||
&( _lock )->Lock, \
|
&( _lock )->Lock, \
|
||||||
&( _context )->Lock_context \
|
&( _context )->Lock_context \
|
||||||
)
|
); \
|
||||||
|
} while ( 0 )
|
||||||
#else
|
#else
|
||||||
#define _ISR_lock_Acquire( _lock, _context ) \
|
#define _ISR_lock_Acquire( _lock, _context ) \
|
||||||
(void) _context;
|
do { (void) _context; } while ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -296,7 +299,7 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
|
|||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
#define _ISR_lock_Release( _lock, _context ) \
|
#define _ISR_lock_Release( _lock, _context ) \
|
||||||
(void) _context;
|
do { (void) _context; } while ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,13 +309,16 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
|
|||||||
*/
|
*/
|
||||||
#if defined( RTEMS_SMP )
|
#if defined( RTEMS_SMP )
|
||||||
#define _ISR_lock_Acquire_inline( _lock, _context ) \
|
#define _ISR_lock_Acquire_inline( _lock, _context ) \
|
||||||
|
do { \
|
||||||
|
_Assert( _ISR_Get_level() != 0 ); \
|
||||||
_SMP_lock_Acquire_inline( \
|
_SMP_lock_Acquire_inline( \
|
||||||
&( _lock )->Lock, \
|
&( _lock )->Lock, \
|
||||||
&( _context )->Lock_context \
|
&( _context )->Lock_context \
|
||||||
)
|
); \
|
||||||
|
} while ( 0 )
|
||||||
#else
|
#else
|
||||||
#define _ISR_lock_Acquire_inline( _lock, _context ) \
|
#define _ISR_lock_Acquire_inline( _lock, _context ) \
|
||||||
(void) _context;
|
do { (void) _context; } while ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,7 +334,7 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
|
|||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
#define _ISR_lock_Release_inline( _lock, _context ) \
|
#define _ISR_lock_Release_inline( _lock, _context ) \
|
||||||
(void) _context;
|
do { (void) _context; } while ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( RTEMS_DEBUG )
|
#if defined( RTEMS_DEBUG )
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ static void test_isr_locks( void )
|
|||||||
ISR_lock_Context lock_context;
|
ISR_lock_Context lock_context;
|
||||||
size_t i;
|
size_t i;
|
||||||
const uint8_t *initialized_bytes;
|
const uint8_t *initialized_bytes;
|
||||||
|
ISR_Level interrupt_level;
|
||||||
|
|
||||||
memset( &container, 0xff, sizeof( container ) );
|
memset( &container, 0xff, sizeof( container ) );
|
||||||
_ISR_lock_Initialize( &container.lock, "test" );
|
_ISR_lock_Initialize( &container.lock, "test" );
|
||||||
@@ -203,9 +204,20 @@ static void test_isr_locks( void )
|
|||||||
|
|
||||||
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
||||||
|
|
||||||
|
#if defined(RTEMS_DEBUG)
|
||||||
|
_ISR_lock_ISR_disable( &lock_context );
|
||||||
|
#endif
|
||||||
|
interrupt_level = _ISR_Get_level();
|
||||||
_ISR_lock_Acquire( &container.lock, &lock_context );
|
_ISR_lock_Acquire( &container.lock, &lock_context );
|
||||||
|
rtems_test_assert( interrupt_level == _ISR_Get_level() );
|
||||||
|
#if !defined(RTEMS_DEBUG)
|
||||||
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
||||||
|
#endif
|
||||||
_ISR_lock_Release( &container.lock, &lock_context );
|
_ISR_lock_Release( &container.lock, &lock_context );
|
||||||
|
rtems_test_assert( interrupt_level == _ISR_Get_level() );
|
||||||
|
#if defined(RTEMS_DEBUG)
|
||||||
|
_ISR_lock_ISR_enable( &lock_context );
|
||||||
|
#endif
|
||||||
|
|
||||||
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
rtems_test_assert( normal_interrupt_level == _ISR_Get_level() );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user