From 7af0a41c8d3bbb6b167ad6ce4a75ed8ee66dc8f3 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 13 Jun 2005 02:14:52 +0000 Subject: [PATCH] rtai fusion support from Alexis Berlemont , slightly modified by me. Patch to comedi_rt_timer has not been applied yet. --- comedi/rt.c | 41 +++++++++++++++++++++++++++++++++++++++ comedi/rt_pend_tq.c | 17 ++++++++++++++-- include/linux/comedi_rt.h | 8 +++++++- m4/rtai.m4 | 9 ++++++++- 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/comedi/rt.c b/comedi/rt.c index 50721b4b..1cdd606c 100644 --- a/comedi/rt.c +++ b/comedi/rt.c @@ -47,6 +47,10 @@ #define RT_spin_unlock_irq(x) rt_spin_unlock_irq(x) #endif +#ifdef CONFIG_COMEDI_FUSION +#include +#endif + #ifdef CONFIG_COMEDI_RTL #include #include @@ -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 diff --git a/comedi/rt_pend_tq.c b/comedi/rt_pend_tq.c index 9b9271a1..2681ef9d 100644 --- a/comedi/rt_pend_tq.c +++ b/comedi/rt_pend_tq.c @@ -8,6 +8,9 @@ #ifdef CONFIG_COMEDI_RTAI #include #endif +#ifdef CONFIG_COMEDI_FUSION +#include +#endif #ifdef CONFIG_COMEDI_RTL #include #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 diff --git a/include/linux/comedi_rt.h b/include/linux/comedi_rt.h index d0c0438f..f54699ed 100644 --- a/include/linux/comedi_rt.h +++ b/include/linux/comedi_rt.h @@ -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); diff --git a/m4/rtai.m4 b/m4/rtai.m4 index 17b4da89..0b23e21a 100644 --- a/m4/rtai.m4 +++ b/m4/rtai.m4 @@ -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 -- 2.26.2