[rtems commit] LEON3: use interrupt layer in clock driver

Daniel Hellstrom danielh at rtems.org
Thu Oct 9 11:12:15 UTC 2014


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

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Fri Jun 13 10:18:01 2014 +0200

LEON3: use interrupt layer in clock driver

Manupilating the interrupt control registers directly instead
of going through the interrupt layer can be deceiving.

---

 c/src/lib/libbsp/shared/include/fatal.h     |    1 +
 c/src/lib/libbsp/sparc/leon3/clock/ckinit.c |   23 ++++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/c/src/lib/libbsp/shared/include/fatal.h b/c/src/lib/libbsp/shared/include/fatal.h
index b57fbaa..5098c6d 100644
--- a/c/src/lib/libbsp/shared/include/fatal.h
+++ b/c/src/lib/libbsp/shared/include/fatal.h
@@ -51,6 +51,7 @@ typedef enum {
   /* LEON3 fatal codes */
   LEON3_FATAL_NO_IRQMP_CONTROLLER = BSP_FATAL_CODE_BLOCK(2),
   LEON3_FATAL_CONSOLE_REGISTER_DEV,
+  LEON3_FATAL_CLOCK_INITIALIZATION,
 
   /* LPC24XX fatal codes */
   LPC24XX_FATAL_PL111_SET_UP = BSP_FATAL_CODE_BLOCK(3),
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
index 5faf72d..f382f1a 100644
--- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
+++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
@@ -20,6 +20,8 @@
 
 #include <bsp.h>
 #include <bspopts.h>
+#include <bsp/fatal.h>
+#include <rtems/rtems/intr.h>
 #include <ambapp.h>
 #include <rtems/score/profiling.h>
 
@@ -34,8 +36,6 @@
 volatile struct gptimer_regs *LEON3_Timer_Regs = 0;
 static int clkirq;
 
-#define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq )
-
 static void leon3_clock_profiling_interrupt_delay(void)
 {
 #ifdef RTEMS_PROFILING
@@ -104,9 +104,26 @@ static void leon3_clock_profiling_interrupt_delay(void)
 
 #define Clock_driver_support_install_isr( _new, _old ) \
   do { \
-    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
+    (_old) = NULL; \
+    bsp_clock_handler_install(_new); \
   } while(0)
 
+static void bsp_clock_handler_install(rtems_isr *new)
+{
+  rtems_status_code sc;
+
+  sc = rtems_interrupt_handler_install(
+    clkirq,
+    "Clock",
+    RTEMS_INTERRUPT_UNIQUE,
+    new,
+    NULL
+  );
+  if (sc != RTEMS_SUCCESSFUL) {
+    rtems_fatal(RTEMS_FATAL_SOURCE_BSP, LEON3_FATAL_CLOCK_INITIALIZATION);
+  }
+}
+
 #define Clock_driver_support_initialize_hardware() \
   do { \
     LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \



More information about the vc mailing list