rtai fusion support from Alexis Berlemont <berlemont.hauw@free.fr>,
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 13 Jun 2005 02:14:52 +0000 (02:14 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 13 Jun 2005 02:14:52 +0000 (02:14 +0000)
slightly modified by me.  Patch to comedi_rt_timer has not been
applied yet.

comedi/rt.c
comedi/rt_pend_tq.c
include/linux/comedi_rt.h
m4/rtai.m4

index 50721b4bbd695d7b45269eb6c12962dd546e86ad..1cdd606ce14671ae85a03cfb7f9533440baf2925 100644 (file)
 #define RT_spin_unlock_irq(x)  rt_spin_unlock_irq(x)
 #endif
 
+#ifdef CONFIG_COMEDI_FUSION
+#include <nucleus/asm/hal.h>
+#endif
+
 #ifdef CONFIG_COMEDI_RTL
 #include <rtl_core.h>
 #include <rtl_sync.h>
@@ -383,6 +387,43 @@ void comedi_rt_cleanup(void)
 
 #endif
 
+/* Fusion section */
+#ifdef CONFIG_COMEDI_FUSION
+
+static void fusion_handle_irq(unsigned int irq, void *cookie)
+{
+       int i;
+       struct comedi_irq_struct *it = cookie;
+
+       it->handler(irq, it->dev_id, NULL);
+       rthal_irq_enable(irq);
+}
+
+static int comedi_rt_get_irq(struct comedi_irq_struct *it)
+{
+       rthal_irq_request(it->irq, fusion_handle_irq, it);
+       rthal_irq_enable(it->irq);
+       return 0;
+}
+
+static int comedi_rt_release_irq(struct comedi_irq_struct *it)
+{
+       rthal_irq_disable(it->irq);
+       rthal_irq_release(it->irq);
+       return 0;
+}
+
+void comedi_rt_init(void)
+{
+       rt_pend_tq_init();
+}
+
+void comedi_rt_cleanup(void)
+{
+       rt_pend_tq_cleanup();
+}
+
+#endif /*CONFIG_COMEDI_FUSION*/
 
 /* RTLinux section */
 #ifdef CONFIG_COMEDI_RTL
index 9b9271a1fb82341fde79556b30214dc3163270f0..2681ef9d3c44d23fa69020715e9d5679b5d2cafe 100644 (file)
@@ -8,6 +8,9 @@
 #ifdef CONFIG_COMEDI_RTAI
 #include <rtai.h>
 #endif
+#ifdef CONFIG_COMEDI_FUSION
+#include <nucleus/asm/hal.h>
+#endif
 #ifdef CONFIG_COMEDI_RTL
 #include <rtl_core.h>
 #endif
@@ -51,6 +54,9 @@ int rt_pend_call(void (*func)(int arg1, void * arg2), int arg1, void * arg2)
 #ifdef CONFIG_COMEDI_RTAI
        rt_pend_linux_srq(rt_pend_tq_irq);
 #endif
+#ifdef CONFIG_COMEDI_FUSION
+       rthal_apc_schedule(rt_pend_tq_irq);
+#endif
 #ifdef CONFIG_COMEDI_RTL
        rtl_global_pend_irq(rt_pend_tq_irq);
 
@@ -60,8 +66,9 @@ int rt_pend_call(void (*func)(int arg1, void * arg2), int arg1, void * arg2)
 
 #ifdef CONFIG_COMEDI_RTAI
 void rt_pend_irq_handler(void)
-#endif
-#ifdef CONFIG_COMEDI_RTL
+#elif defined(CONFIG_COMEDI_FUSION)
+void rt_pend_irq_handler(void * cookie)
+#elif defined(CONFIG_COMEDI_RTL)
 void rt_pend_irq_handler(int irq, void *dev, struct pt_regs * regs)
 #endif
 {
@@ -77,6 +84,9 @@ int rt_pend_tq_init(void)
 #ifdef CONFIG_COMEDI_RTAI
        rt_pend_tq_irq=rt_request_srq(0,rt_pend_irq_handler,NULL);
 #endif
+#ifdef CONFIG_COMEDI_FUSION
+       rt_pend_tq_irq=rthal_apc_alloc("comedi APC" ,rt_pend_irq_handler, NULL);
+#endif
 #ifdef CONFIG_COMEDI_RTL
        rt_pend_tq_irq=rtl_get_soft_irq(rt_pend_irq_handler,"rt_pend_irq");
 #endif
@@ -93,6 +103,9 @@ void rt_pend_tq_cleanup(void)
 #ifdef CONFIG_COMEDI_RTAI
        rt_free_srq(rt_pend_tq_irq);
 #endif
+#ifdef CONFIG_COMEDI_FUSION
+       rthal_apc_free(rt_pend_tq_irq);
+#endif
 #ifdef CONFIG_COMEDI_RTL
        free_irq(rt_pend_tq_irq,NULL);
 #endif
index d0c0438fad5ce3788546d444933b5a6a2a6a42d0..f54699edd97687cb30479da9d3ce131ee9ee3773 100644 (file)
@@ -51,6 +51,9 @@
 //#endif
 #define rt_printk rtl_printf
 #endif
+#ifdef CONFIG_COMEDI_FUSION
+#define rt_printk(format, args...) printk(format , ## args )
+#endif /* CONFIG_COMEDI_FUSION */
 #ifdef CONFIG_PRIORITY_IRQ
 #define rt_printk printk
 #endif
@@ -100,6 +103,8 @@ static inline unsigned long __comedi_spin_lock_irqsave(spinlock_t *lock_ptr)
 #elif defined(CONFIG_COMEDI_RTL_V1)
        rtl_spin_lock_irqsave(lock_ptr, flags);
 
+#elif defined(CONFIG_COMEDI_FUSION)
+       rthal_spin_lock_irqsave(lock_ptr, flags);
 #else
        spin_lock_irqsave(lock_ptr, flags);
 
@@ -119,7 +124,8 @@ static inline void comedi_spin_unlock_irqrestore(spinlock_t *lock_ptr, unsigned
 
 #elif defined(CONFIG_COMEDI_RTL_V1)
        rtl_spin_unlock_irqrestore(lock_ptr, flags);
-
+#elif defined(CONFIG_COMEDI_FUSION)
+       rthal_spin_unlock_irqrestore(lock_ptr, flags);
 #else
        spin_unlock_irqrestore(lock_ptr, flags);
 
index 17b4da8961873e557194472c728ae638fca7b949..0b23e21a420ded6280db3d71022d2a2da791fe8f 100644 (file)
@@ -23,7 +23,14 @@ AC_DEFUN([DS_RTAI],
                fi
                $1
                AC_MSG_RESULT([found])
-               AC_DEFINE([CONFIG_COMEDI_RTAI],[true],[Define if kernel is RTAI patched])
+               FUSION_TEST=`${RTAI_DIR}/bin/rtai-config --version | cut -d"-" -f2 `
+               if test "${FUSION_TEST}" = "fusion"
+               then
+                       AC_DEFINE([CONFIG_COMEDI_FUSION],[true],[Define if kernel is RTAI patched])
+               else
+                       AC_DEFINE([CONFIG_COMEDI_RTAI],[true],[Define if kernel is RTAI patched])
+               fi
+
        else
                $2
        fi