score: Add _ISR_Is_enabled()

In contrast to _ISR_Get_level() the _ISR_Is_enabled() function evaluates
a level parameter and returns a boolean value.

Update #2811.
This commit is contained in:
Sebastian Huber
2016-11-10 15:17:28 +01:00
parent 537f00ebe8
commit 408609f6b9
20 changed files with 126 additions and 2 deletions

View File

@@ -350,8 +350,6 @@ static inline uint32_t arm_interrupt_disable( void )
: [level] "=&r" (level) : [level] "=&r" (level)
: [basepri] "r" (basepri) : [basepri] "r" (basepri)
); );
#else
level = 0;
#endif #endif
return level; return level;
@@ -416,6 +414,15 @@ static inline void arm_interrupt_flash( uint32_t level )
#define _CPU_ISR_Flash( _isr_cookie ) \ #define _CPU_ISR_Flash( _isr_cookie ) \
arm_interrupt_flash( _isr_cookie ) arm_interrupt_flash( _isr_cookie )
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
#if defined(ARM_MULTILIB_ARCH_V4)
return ( level & 0x80 ) == 0;
#elif defined(ARM_MULTILIB_ARCH_V7M)
return level > 0x80;
#endif
}
void _CPU_ISR_Set_level( uint32_t level ); void _CPU_ISR_Set_level( uint32_t level );
uint32_t _CPU_ISR_Get_level( void ); uint32_t _CPU_ISR_Get_level( void );

View File

@@ -667,6 +667,11 @@ typedef struct {
: : "d"(_level) : "R0" ); \ : : "d"(_level) : "R0" ); \
} }
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return level != 0;
}
/** /**
* This routine and @ref _CPU_ISR_Get_level * This routine and @ref _CPU_ISR_Get_level
* Map the interrupt level in task mode onto the hardware that the CPU * Map the interrupt level in task mode onto the hardware that the CPU

View File

@@ -525,6 +525,11 @@ static inline void epiphany_interrupt_enable(uint32_t level)
epiphany_interrupt_disable(); \ epiphany_interrupt_disable(); \
} while(0) } while(0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & 0x2 ) != 0;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -403,6 +403,11 @@ extern Context_Control_fp _CPU_Null_fp_context;
#define _CPU_ISR_Set_level( _new_level ) i386_set_interrupt_level(_new_level) #define _CPU_ISR_Set_level( _new_level ) i386_set_interrupt_level(_new_level)
#endif #endif
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & EFLAGS_INTR_ENABLE ) != 0;
}
uint32_t _CPU_ISR_Get_level( void ); uint32_t _CPU_ISR_Get_level( void );
/* Make sure interrupt stack has space for ISR /* Make sure interrupt stack has space for ISR

View File

@@ -679,6 +679,11 @@ extern Context_Control_fp _CPU_Null_fp_context;
#define _CPU_ISR_Flash( _isr_cookie ) \ #define _CPU_ISR_Flash( _isr_cookie ) \
lm32_flash_interrupts( _isr_cookie ); lm32_flash_interrupts( _isr_cookie );
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & 0x0001 ) != 0;
}
/** /**
* This routine and @ref _CPU_ISR_Get_level * This routine and @ref _CPU_ISR_Get_level
* Map the interrupt level in task mode onto the hardware that the CPU * Map the interrupt level in task mode onto the hardware that the CPU

View File

@@ -669,6 +669,11 @@ typedef struct {
__asm__ volatile( "fclr I" ); \ __asm__ volatile( "fclr I" ); \
} while(0) } while(0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & 0x40 ) != 0;
}
/** /**
* @ingroup CPUInterrupt * @ingroup CPUInterrupt
* *

View File

@@ -399,6 +399,11 @@ extern void* _VBR;
#define _CPU_ISR_Flash( _level ) \ #define _CPU_ISR_Flash( _level ) \
m68k_flash_interrupts( _level ) m68k_flash_interrupts( _level )
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & 0x0700 ) == 0;
}
#define _CPU_ISR_Set_level( _newlevel ) \ #define _CPU_ISR_Set_level( _newlevel ) \
m68k_set_interrupt_level( _newlevel ) m68k_set_interrupt_level( _newlevel )

View File

@@ -699,6 +699,11 @@ uint32_t mips_interrupt_mask( void );
_xlevel = _scratch2; \ _xlevel = _scratch2; \
} while(0) } while(0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & SR_INTERRUPT_ENABLE_BITS ) != 0;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -522,6 +522,11 @@ typedef struct {
_CPU_ISR_Disable( _isr_cookie ); \ _CPU_ISR_Disable( _isr_cookie ); \
} while (0) } while (0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return true;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -19,6 +19,18 @@
#include <rtems/score/interr.h> #include <rtems/score/interr.h>
#include <rtems/score/nios2-utility.h> #include <rtems/score/nios2-utility.h>
bool _CPU_ISR_Is_enabled( uint32_t level )
{
switch ( _Nios2_ISR_Get_status_mask() ) {
case NIOS2_ISR_STATUS_MASK_EIC_IL:
return ((status & NIOS2_STATUS_IL_MASK) >> NIOS2_STATUS_IL_OFFSET) == 0;
case NIOS2_ISR_STATUS_MASK_EIC_RSIE:
return (status & NIOS2_STATUS_RSIE) != 0;
default:
return (status & NIOS2_STATUS_PIE) != 0;
}
}
uint32_t _CPU_ISR_Get_level( void ) uint32_t _CPU_ISR_Get_level( void )
{ {
uint32_t status = _Nios2_Get_ctlreg_status(); uint32_t status = _Nios2_Get_ctlreg_status();

View File

@@ -241,6 +241,8 @@ typedef struct {
__builtin_wrctl( 0, _status ); \ __builtin_wrctl( 0, _status ); \
} while ( 0 ) } while ( 0 )
bool _CPU_ISR_Is_enabled( uint32_t level );
/** /**
* @brief Sets the interrupt level for the executing thread. * @brief Sets the interrupt level for the executing thread.
* *

View File

@@ -790,6 +790,20 @@ extern Context_Control_fp _CPU_Null_fp_context;
{ \ { \
} }
/**
* @brief Returns true if interrupts are enabled in the specified ISR level,
* otherwise returns false.
*
* @param[in] level The ISR level.
*
* @retval true Interrupts are enabled in the ISR level.
* @retval false Otherwise.
*/
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return false;
}
/** /**
* @ingroup CPUInterrupt * @ingroup CPUInterrupt
* *

View File

@@ -528,6 +528,11 @@ static inline void or1k_interrupt_enable(uint32_t level)
_OR1K_mtspr(CPU_OR1K_SPR_SR, (_level & ~CPU_OR1K_SPR_SR_IEE)); \ _OR1K_mtspr(CPU_OR1K_SPR_SR, (_level & ~CPU_OR1K_SPR_SR_IEE)); \
} while(0) } while(0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & CPU_OR1K_SPR_SR ) != 0;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -633,6 +633,11 @@ typedef struct {
#ifndef ASM #ifndef ASM
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & MSR_EE ) != 0;
}
static inline uint32_t _CPU_ISR_Get_level( void ) static inline uint32_t _CPU_ISR_Get_level( void )
{ {
register unsigned int msr; register unsigned int msr;

View File

@@ -491,6 +491,12 @@ void CPU_delay( uint32_t microseconds );
#define _CPU_ISR_Flash( _level) \ #define _CPU_ISR_Flash( _level) \
sh_flash_interrupts( _level) sh_flash_interrupts( _level)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
sh_get_interrupt_level( level );
return level == 0;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -889,6 +889,14 @@ extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
#define _CPU_ISR_Flash( _level ) \ #define _CPU_ISR_Flash( _level ) \
sparc_flash_interrupts( _level ) sparc_flash_interrupts( _level )
#define _CPU_ISR_Is_enabled( _isr_cookie ) \
sparc_interrupt_is_enabled( _isr_cookie )
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & SPARC_PSR_PIL_MASK ) == 0;
}
/** /**
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -754,6 +754,11 @@ extern const CPU_Trap_table_entry _CPU_Trap_slot_template;
#define _CPU_ISR_Flash( _level ) \ #define _CPU_ISR_Flash( _level ) \
sparc_flash_interrupts( _level ) sparc_flash_interrupts( _level )
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( psr & SPARC_PSTATE_IE_MASK ) != 0;
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
* actually provides. Currently, interrupt levels which do not * actually provides. Currently, interrupt levels which do not

View File

@@ -627,6 +627,12 @@ typedef struct {
__asm__ __volatile__( "di" ); \ __asm__ __volatile__( "di" ); \
} while (0) } while (0)
RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
{
return ( level & V850_PSW_INTERRUPT_DISABLE_MASK )
!= V850_PSW_INTERRUPT_DISABLE;
}
/** /**
* This routine and @ref _CPU_ISR_Get_level * This routine and @ref _CPU_ISR_Get_level
* Map the interrupt level in task mode onto the hardware that the CPU * Map the interrupt level in task mode onto the hardware that the CPU

View File

@@ -104,6 +104,18 @@ typedef uint32_t ISR_Level;
RTEMS_COMPILER_MEMORY_BARRIER(); \ RTEMS_COMPILER_MEMORY_BARRIER(); \
} while (0) } while (0)
/**
* @brief Returns true if interrupts are enabled in the specified interrupt
* level, otherwise returns false.
*
* @param[in] _level The ISR level.
*
* @retval true Interrupts are enabled in the interrupt level.
* @retval false Otherwise.
*/
#define _ISR_Is_enabled( _level ) \
_CPU_ISR_Is_enabled( _level )
/** /**
* @brief Return current interrupt level. * @brief Return current interrupt level.
* *

View File

@@ -339,10 +339,12 @@ void test_interrupt_inline(void)
rtems_interrupt_local_disable( level ); rtems_interrupt_local_disable( level );
isr_level_1 = _ISR_Get_level(); isr_level_1 = _ISR_Get_level();
rtems_test_assert( isr_level_1 != isr_level_0 ); rtems_test_assert( isr_level_1 != isr_level_0 );
rtems_test_assert( _ISR_Is_enabled( level ) );
rtems_interrupt_local_disable( level_1 ); rtems_interrupt_local_disable( level_1 );
isr_level_2 = _ISR_Get_level(); isr_level_2 = _ISR_Get_level();
rtems_test_assert( isr_level_2 == isr_level_1 ); rtems_test_assert( isr_level_2 == isr_level_1 );
rtems_test_assert( !_ISR_Is_enabled( level_1 ) );
rtems_interrupt_local_enable( level_1 ); rtems_interrupt_local_enable( level_1 );
rtems_test_assert( _ISR_Get_level() == isr_level_1 ); rtems_test_assert( _ISR_Get_level() == isr_level_1 );