[PATCH 3/4] bsp/leon3: Use interrupt entry for tm27 support

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Dec 10 13:38:33 UTC 2021


Using rtems_interrupt_entry_install() instead of
rtems_interrupt_handler_install() avoids a dependency on the dynamic memory
allocation.

Use Interrupt Manager directives instead of a BSP-specific API.  Use inline
functions.  In SMP configurations, set an affinity to all online processors and
raise the interrupt on the current processor.
---
 bsps/sparc/leon3/include/tm27.h | 75 ++++++++++++++++++++++++---------
 1 file changed, 55 insertions(+), 20 deletions(-)

diff --git a/bsps/sparc/leon3/include/tm27.h b/bsps/sparc/leon3/include/tm27.h
index dda21f558f..7635d9b070 100644
--- a/bsps/sparc/leon3/include/tm27.h
+++ b/bsps/sparc/leon3/include/tm27.h
@@ -21,7 +21,11 @@
 #define __tm27_h
 
 #include <bsp.h>
-#include <leon.h>
+#include <bsp/irq.h>
+
+#if defined(RTEMS_SMP)
+#include <rtems/score/smpimpl.h>
+#endif
 
 /*
  *  Define the interrupt mechanism for Time Test 27
@@ -59,40 +63,71 @@
 
 #else   /* use a regular asynchronous trap */
 
-#define TEST_INTERRUPT_SOURCE LEON_INTERRUPT_EXTERNAL_1
-#define TEST_INTERRUPT_SOURCE2 LEON_INTERRUPT_EXTERNAL_1+1
+#define TEST_INTERRUPT_SOURCE 5
+#define TEST_INTERRUPT_SOURCE2 6
 #define MUST_WAIT_FOR_INTERRUPT 1
 
 static inline void Install_tm27_vector(
   void ( *handler )( rtems_vector_number )
 )
 {
-  (void) rtems_interrupt_handler_install(
+  static rtems_interrupt_entry entry_low;
+  static rtems_interrupt_entry entry_high;
+
+#if defined(RTEMS_SMP)
+  bsp_interrupt_set_affinity(
+    TEST_INTERRUPT_SOURCE,
+    _SMP_Get_online_processors()
+  );
+  bsp_interrupt_set_affinity(
+    TEST_INTERRUPT_SOURCE2,
+    _SMP_Get_online_processors()
+  );
+#endif
+
+  rtems_interrupt_entry_initialize(
+    &entry_low,
+    (rtems_interrupt_handler) handler,
+    NULL,
+    "tm27 low"
+  );
+  (void) rtems_interrupt_entry_install(
     TEST_INTERRUPT_SOURCE,
-    "tm27 low",
     RTEMS_INTERRUPT_SHARED,
+    &entry_low
+  );
+  rtems_interrupt_entry_initialize(
+    &entry_high,
     (rtems_interrupt_handler) handler,
-    NULL
+    NULL,
+    "tm27 high"
   );
-  (void) rtems_interrupt_handler_install(
+  (void) rtems_interrupt_entry_install(
     TEST_INTERRUPT_SOURCE2,
-    "tm27 high",
     RTEMS_INTERRUPT_SHARED,
-    (rtems_interrupt_handler) handler,
-    NULL
+    &entry_high
   );
 }
 
-#define Cause_tm27_intr() \
-  do { \
-    LEON_Force_interrupt( TEST_INTERRUPT_SOURCE+(Interrupt_nest>>1)); \
-    nop(); \
-    nop(); \
-    nop(); \
-  } while (0)
-
-#define Clear_tm27_intr() \
-  LEON_Clear_interrupt( TEST_INTERRUPT_SOURCE )
+static inline void Cause_tm27_intr( void )
+{
+  rtems_vector_number vector;
+
+  vector = TEST_INTERRUPT_SOURCE + ( Interrupt_nest >> 1 );
+#if defined(RTEMS_SMP)
+  (void) rtems_interrupt_raise_on( vector, rtems_scheduler_get_processor() );
+#else
+  (void) rtems_interrupt_raise( vector );
+#endif
+  nop();
+  nop();
+  nop();
+}
+
+static inline void Clear_tm27_intr( void )
+{
+  (void) rtems_interrupt_clear( TEST_INTERRUPT_SOURCE );
+}
 
 #define Lower_tm27_intr() /* empty */
 
-- 
2.26.2



More information about the devel mailing list