added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / comedi / comedi_rt.h
blob61852bf5adccf9497cbb082430d557adf7ad35c4
1 /*
2 module/comedi_rt.h
3 header file for real-time structures, variables, and constants
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef _COMEDI_RT_H
25 #define _COMEDI_RT_H
27 #ifndef _COMEDIDEV_H
28 #error comedi_rt.h should only be included by comedidev.h
29 #endif
31 #include <linux/version.h>
32 #include <linux/kdev_t.h>
33 #include <linux/slab.h>
34 #include <linux/errno.h>
35 #include <linux/spinlock.h>
36 #include <linux/delay.h>
38 #ifdef CONFIG_COMEDI_RT
40 #ifdef CONFIG_COMEDI_RTAI
41 #include <rtai.h>
42 #include <rtai_sched.h>
43 #include <rtai_version.h>
44 #endif
45 #ifdef CONFIG_COMEDI_RTL
46 #include <rtl_core.h>
47 #include <rtl_time.h>
48 /* #ifdef RTLINUX_VERSION_CODE */
49 #include <rtl_sync.h>
50 /* #endif */
51 #define rt_printk rtl_printf
52 #endif
53 #ifdef CONFIG_COMEDI_FUSION
54 #define rt_printk(format, args...) printk(format , ## args)
55 #endif /* CONFIG_COMEDI_FUSION */
56 #ifdef CONFIG_PRIORITY_IRQ
57 #define rt_printk printk
58 #endif
60 int comedi_request_irq(unsigned int irq, irqreturn_t(*handler) (int,
61 void *PT_REGS_ARG), unsigned long flags, const char *device,
62 comedi_device *dev_id);
63 void comedi_free_irq(unsigned int irq, comedi_device *dev_id);
64 void comedi_rt_init(void);
65 void comedi_rt_cleanup(void);
66 int comedi_switch_to_rt(comedi_device *dev);
67 void comedi_switch_to_non_rt(comedi_device *dev);
68 void comedi_rt_pend_wakeup(wait_queue_head_t *q);
69 extern int rt_pend_call(void (*func) (int arg1, void *arg2), int arg1,
70 void *arg2);
72 #else
74 #define comedi_request_irq(a, b, c, d, e) request_irq(a, b, c, d, e)
75 #define comedi_free_irq(a, b) free_irq(a, b)
76 #define comedi_rt_init() do {} while (0)
77 #define comedi_rt_cleanup() do {} while (0)
78 #define comedi_switch_to_rt(a) (-1)
79 #define comedi_switch_to_non_rt(a) do {} while (0)
80 #define comedi_rt_pend_wakeup(a) do {} while (0)
82 #define rt_printk(format, args...) printk(format, ##args)
84 #endif
86 /* Define a spin_lock_irqsave function that will work with rt or without.
87 * Use inline functions instead of just macros to enforce some type checking.
89 #define comedi_spin_lock_irqsave(lock_ptr, flags) \
90 (flags = __comedi_spin_lock_irqsave(lock_ptr))
92 static inline unsigned long __comedi_spin_lock_irqsave(spinlock_t *lock_ptr)
94 unsigned long flags;
96 #if defined(CONFIG_COMEDI_RTAI)
97 flags = rt_spin_lock_irqsave(lock_ptr);
99 #elif defined(CONFIG_COMEDI_RTL)
100 rtl_spin_lock_irqsave(lock_ptr, flags);
102 #elif defined(CONFIG_COMEDI_RTL_V1)
103 rtl_spin_lock_irqsave(lock_ptr, flags);
105 #elif defined(CONFIG_COMEDI_FUSION)
106 rthal_spin_lock_irqsave(lock_ptr, flags);
107 #else
108 spin_lock_irqsave(lock_ptr, flags);
110 #endif
112 return flags;
115 static inline void comedi_spin_unlock_irqrestore(spinlock_t *lock_ptr,
116 unsigned long flags)
119 #if defined(CONFIG_COMEDI_RTAI)
120 rt_spin_unlock_irqrestore(flags, lock_ptr);
122 #elif defined(CONFIG_COMEDI_RTL)
123 rtl_spin_unlock_irqrestore(lock_ptr, flags);
125 #elif defined(CONFIG_COMEDI_RTL_V1)
126 rtl_spin_unlock_irqrestore(lock_ptr, flags);
127 #elif defined(CONFIG_COMEDI_FUSION)
128 rthal_spin_unlock_irqrestore(lock_ptr, flags);
129 #else
130 spin_unlock_irqrestore(lock_ptr, flags);
132 #endif
136 /* define a RT safe udelay */
137 static inline void comedi_udelay(unsigned int usec)
139 #if defined(CONFIG_COMEDI_RTAI)
140 static const int nanosec_per_usec = 1000;
141 rt_busy_sleep(usec * nanosec_per_usec);
142 #elif defined(CONFIG_COMEDI_RTL)
143 static const int nanosec_per_usec = 1000;
144 rtl_delay(usec * nanosec_per_usec);
145 #else
146 udelay(usec);
147 #endif
150 #endif