[rtems commit] score: Add and use _ISR_Get_nest_level()

Sebastian Huber sebh at rtems.org
Mon Jul 22 14:51:42 UTC 2013


Module:    rtems
Branch:    master
Commit:    0bbd8fdce2106ecb63953444fc3da38aa348fb34
Changeset: http://git.rtems.org/rtems/commit/?id=0bbd8fdce2106ecb63953444fc3da38aa348fb34

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jul 18 09:02:53 2013 +0200

score: Add and use _ISR_Get_nest_level()

---

 cpukit/score/include/rtems/score/isr.h |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/include/rtems/score/isr.h b/cpukit/score/include/rtems/score/isr.h
index d174912..0c2abe6 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 <rtems/score/cpu.h>
 #include <rtems/score/isrlevel.h>
+#include <rtems/score/percpu.h>
 
 /**
  *  @defgroup ScoreISR ISR Handler
@@ -178,6 +178,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.
  *
  *  This function returns true if the processor is currently servicing
@@ -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




More information about the vc mailing list