00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <linux/kernel.h>
00020 #include <linux/module.h>
00021 #include <linux/init.h>
00022 #include <linux/sched.h>
00023 #include <linux/slab.h>
00024
00025 MODULE_LICENSE("GPL");
00026
00027 #if 0
00028
00029 #include <rtai.h>
00030 #include <rtai_sched.h>
00031 #include <rtai_malloc.h>
00032 #include <rtai_lxrt.h>
00033 #include <rtai_tasklets.h>
00034 #include <rtai_usi.h>
00035 #include <rtai_sem.h>
00036
00037 #define MODULE_NAME "RTAI_USI"
00038
00039 static void *rt_spin_lock_init(void)
00040 {
00041 spinlock_t *lock;
00042
00043 if ((lock = rt_malloc(sizeof(spinlock_t)))) {
00044 spin_lock_init(lock);
00045 return lock;
00046 }
00047 return 0;
00048 }
00049
00050 static inline int rt_spin_lock_delete(void *lock)
00051 {
00052 rt_free(lock);
00053 return 0;
00054 }
00055
00056 static void usi_spin_lock(spinlock_t *lock)
00057 {
00058 rt_spin_lock(lock);
00059 }
00060
00061 static void usi_spin_unlock(spinlock_t *lock)
00062 {
00063 rt_spin_unlock(lock);
00064 }
00065
00066 static void usi_spin_lock_irq(spinlock_t *lock)
00067 {
00068 rt_spin_lock_irq(lock);
00069 }
00070
00071 static void usi_spin_unlock_irq(spinlock_t *lock)
00072 {
00073 rt_spin_unlock_irq(lock);
00074 }
00075
00076 static unsigned long usi_spin_lock_irqsave(spinlock_t *lock)
00077 {
00078 return rt_spin_lock_irqsave(lock);
00079 }
00080
00081 static void usi_spin_unlock_irqrestore(unsigned long flags, spinlock_t *lock)
00082 {
00083 rt_spin_unlock_irqrestore(flags, lock);
00084 }
00085
00086 static void usi_global_cli(void)
00087 {
00088 rt_global_cli();
00089 }
00090
00091 static void usi_global_sti(void)
00092 {
00093 rt_global_sti();
00094 }
00095
00096 static unsigned long usi_global_save_flags_and_cli(void)
00097 {
00098 return rt_global_save_flags_and_cli();
00099 }
00100
00101 static unsigned long usi_global_save_flags(void)
00102 {
00103 unsigned long flags;
00104 rt_global_save_flags(&flags);
00105 return flags;
00106 }
00107
00108 static void usi_global_restore_flags(unsigned long flags)
00109 {
00110 rt_global_restore_flags(flags);
00111 }
00112
00113 static void usi_cli(void)
00114 {
00115 rtai_cli();
00116 }
00117
00118 static void usi_sti(void)
00119 {
00120 rtai_sti();
00121 }
00122
00123 static unsigned long usi_save_flags_and_cli(void)
00124 {
00125 unsigned long flags;
00126 rtai_save_flags_and_cli(flags);
00127 return flags;
00128 }
00129
00130 static unsigned long usi_save_flags(void)
00131 {
00132 unsigned long flags;
00133 rtai_save_flags(flags);
00134 return flags;
00135 }
00136
00137 static void usi_restore_flags(unsigned long flags)
00138 {
00139 rtai_restore_flags(flags);
00140 }
00141
00142 static struct rt_fun_entry rtai_usi_fun[] = {
00143 [_STARTUP_IRQ] = { 0, rt_startup_irq },
00144 [_SHUTDOWN_IRQ] = { 0, rt_shutdown_irq },
00145 [_ENABLE_IRQ] = { 0, rt_enable_irq },
00146 [_DISABLE_IRQ] = { 0, rt_disable_irq },
00147 [_MASK_AND_ACK_IRQ] = { 0, rt_mask_and_ack_irq },
00148 [_ACK_IRQ] = { 0, rt_ack_irq },
00149 [_UNMASK_IRQ ] = { 0, rt_unmask_irq },
00150 [_INIT_SPIN_LOCK] = { 0, rt_spin_lock_init },
00151 [_SPIN_LOCK] = { 0, usi_spin_lock },
00152 [_SPIN_UNLOCK] = { 0, usi_spin_unlock },
00153 [_SPIN_LOCK_IRQ] = { 0, usi_spin_lock_irq },
00154 [_SPIN_UNLOCK_IRQ] = { 0, usi_spin_unlock_irq },
00155 [_SPIN_LOCK_IRQSV] = { 0, usi_spin_lock_irqsave },
00156 [_SPIN_UNLOCK_IRQRST] = { 0, usi_spin_unlock_irqrestore },
00157 [_GLB_CLI] = { 0, usi_global_cli },
00158 [_GLB_STI] = { 0, usi_global_sti},
00159 [_GLB_SVFLAGS_CLI] = { 0, usi_global_save_flags_and_cli },
00160 [_GLB_SVFLAGS] = { 0, usi_global_save_flags },
00161 [_GLB_RSTFLAGS] = { 0, usi_global_restore_flags },
00162 [_CLI] = { 0, usi_cli },
00163 [_STI] = { 0, usi_sti},
00164 [_SVFLAGS_CLI] = { 0, usi_save_flags_and_cli },
00165 [_SVFLAGS] = { 0, usi_save_flags },
00166 [_RSTFLAGS] = { 0, usi_restore_flags }
00167 };
00168
00169 static int register_lxrt_usi_support(void)
00170 {
00171 if(set_rt_fun_ext_index(rtai_usi_fun, FUN_USI_LXRT_INDX)) {
00172 printk("LXRT EXTENSION SLOT FOR USI (%d) ALREADY USED\n", FUN_USI_LXRT_INDX);
00173 return -EACCES;
00174 }
00175 return 0;
00176 }
00177
00178 static void unregister_lxrt_usi_support(void)
00179 {
00180 reset_rt_fun_ext_index(rtai_usi_fun, FUN_USI_LXRT_INDX);
00181 }
00182
00183 int __rtai_usi_init(void)
00184 {
00185 if (!register_lxrt_usi_support()) {
00186 printk(KERN_INFO "RTAI[usi]: loaded.\n");
00187 return 0;
00188 }
00189 return -EACCES;
00190 }
00191
00192 void __rtai_usi_exit(void)
00193 {
00194 unregister_lxrt_usi_support();
00195 printk(KERN_INFO "RTAI[usi]: unloaded.\n");
00196 }
00197
00198 #endif
00199
00200 int __rtai_usi_init(void)
00201 {
00202 printk(KERN_INFO "RTAI[usi]: loaded.\n");
00203 return 0;
00204 }
00205
00206 void __rtai_usi_exit(void)
00207 {
00208 printk(KERN_INFO "RTAI[usi]: unloaded.\n");
00209 }
00210
00211 #ifndef CONFIG_RTAI_USI_BUILTIN
00212 module_init(__rtai_usi_init);
00213 module_exit(__rtai_usi_exit);
00214 #endif