From 0bbd8fdce2106ecb63953444fc3da38aa348fb34 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 18 Jul 2013 09:02:53 +0200 Subject: score: Add and use _ISR_Get_nest_level() --- cpukit/score/include/rtems/score/isr.h | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'cpukit/score/include') diff --git a/cpukit/score/include/rtems/score/isr.h b/cpukit/score/include/rtems/score/isr.h index d17491261c..0c2abe65bc 100644 --- a/cpukit/score/include/rtems/score/isr.h +++ b/cpukit/score/include/rtems/score/isr.h @@ -21,8 +21,8 @@ #ifndef _RTEMS_SCORE_ISR_H #define _RTEMS_SCORE_ISR_H -#include #include +#include /** * @defgroup ScoreISR ISR Handler @@ -177,6 +177,34 @@ void _ISR_Handler( void ); */ void _ISR_Dispatch( void ); +/** + * @brief Returns the current ISR nest level + * + * This function can be called in any context. On SMP configurations + * interrupts are disabled to ensure that the processor index is used + * consistently. + * + * @return The current ISR nest level. + */ +RTEMS_INLINE_ROUTINE uint32_t _ISR_Get_nest_level( void ) +{ + uint32_t isr_nest_level; + + #if defined( RTEMS_SMP ) + ISR_Level level; + + _ISR_Disable( level ); + #endif + + isr_nest_level = _ISR_Nest_level; + + #if defined( RTEMS_SMP ) + _ISR_Enable( level ); + #endif + + return isr_nest_level; +} + /** * @brief Checks if an ISR in progress. * @@ -190,7 +218,7 @@ void _ISR_Dispatch( void ); bool _ISR_Is_in_progress( void ); #else #define _ISR_Is_in_progress() \ - (_ISR_Nest_level != 0) + (_ISR_Get_nest_level() != 0) #endif #ifdef __cplusplus -- cgit v1.2.3