00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RTAI_USI_H
00020 #define _RTAI_USI_H
00021
00022 #include <rtai_types.h>
00023
00024 #define FUN_USI_LXRT_INDX 3
00025
00026 #define USI_SEM 0
00027 #define USI_TASKLET 1
00028
00029 #define _REQ_GLB_IRQ 0
00030 #define _FREE_GLB_IRQ 1
00031 #define _STARTUP_IRQ 2
00032 #define _SHUTDOWN_IRQ 3
00033 #define _ENABLE_IRQ 4
00034 #define _DISABLE_IRQ 5
00035 #define _MASK_AND_ACK_IRQ 6
00036 #define _ACK_IRQ 7
00037 #define _UNMASK_IRQ 8
00038 #define _PEND_LINUX_IRQ 9
00039 #define _INIT_SPIN_LOCK 10
00040 #define _SPIN_LOCK 11
00041 #define _SPIN_UNLOCK 12
00042 #define _SPIN_LOCK_IRQ 13
00043 #define _SPIN_UNLOCK_IRQ 14
00044 #define _SPIN_LOCK_IRQSV 15
00045 #define _SPIN_UNLOCK_IRQRST 16
00046 #define _GLB_CLI 17
00047 #define _GLB_STI 18
00048 #define _GLB_SVFLAGS_CLI 19
00049 #define _GLB_SVFLAGS 20
00050 #define _GLB_RSTFLAGS 21
00051 #define _CLI 22
00052 #define _STI 23
00053 #define _SVFLAGS_CLI 24
00054 #define _SVFLAGS 25
00055 #define _RSTFLAGS 26
00056 #define _WAIT_INTR 27
00057 #define _WAIT_INTR_IF 28
00058 #define _WAIT_INTR_UNTIL 29
00059 #define _WAIT_INTR_TIMED 30
00060
00061 #ifdef __KERNEL__
00062
00063 #ifdef __cplusplus
00064 extern "C" {
00065 #endif
00066
00067 int __rtai_usi_init(void);
00068
00069 void __rtai_usi_exit(void);
00070
00071 #ifdef __cplusplus
00072 }
00073 #endif
00074
00075 #else
00076
00077 #include <rtai_lxrt.h>
00078
00079 #ifdef __cplusplus
00080 extern "C" {
00081 #endif
00082
00083 RTAI_PROTO(int, rt_expand_handler_data,(unsigned long data, int *irq))
00084 {
00085 *irq = data & 0xFFFF;
00086 return (data & 0xFFFF0000) >> 16;
00087 }
00088
00089 RTAI_PROTO(int, rt_request_global_irq,(unsigned int irq, void *hook, int hooktype))
00090 {
00091 struct { unsigned int irq; void *hook; int hooktype; } arg = { irq, hook, hooktype };
00092 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _REQ_GLB_IRQ, &arg).i[LOW];
00093 }
00094
00095 RTAI_PROTO(int, rt_free_global_irq,(unsigned int irq))
00096 {
00097 struct { unsigned int irq; } arg = { irq };
00098 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _FREE_GLB_IRQ, &arg).i[LOW];
00099 }
00100
00101 RTAI_PROTO(int, rt_startup_irq,(unsigned int irq))
00102 {
00103 struct { unsigned int irq; } arg = { irq };
00104 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _STARTUP_IRQ, &arg).i[LOW];
00105 }
00106
00107 RTAI_PROTO(void, rt_shutdown_irq,(unsigned int irq))
00108 {
00109 struct { unsigned int irq; } arg = { irq };
00110 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SHUTDOWN_IRQ, &arg);
00111 }
00112
00113 RTAI_PROTO(void, rt_enable_irq,(unsigned int irq))
00114 {
00115 struct { unsigned int irq; } arg = { irq };
00116 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _ENABLE_IRQ, &arg);
00117 }
00118
00119 RTAI_PROTO(void, rt_disable_irq,(unsigned int irq))
00120 {
00121 struct { unsigned int irq; } arg = { irq };
00122 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _DISABLE_IRQ, &arg);
00123 }
00124
00125 RTAI_PROTO(void, rt_mask_and_ack_irq,(unsigned int irq))
00126 {
00127 struct { unsigned int irq; } arg = { irq };
00128 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _MASK_AND_ACK_IRQ, &arg);
00129 }
00130
00131 RTAI_PROTO(void, rt_ack_irq,(unsigned int irq))
00132 {
00133 struct { unsigned int irq; } arg = { irq };
00134 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _ACK_IRQ, &arg);
00135 }
00136
00137 RTAI_PROTO(void, rt_unmask_irq,(unsigned int irq))
00138 {
00139 struct { unsigned int irq; } arg = { irq };
00140 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _UNMASK_IRQ, &arg);
00141 }
00142
00143 RTAI_PROTO(void, rt_pend_linux_irq,(unsigned int irq))
00144 {
00145 struct { unsigned int irq; } arg = { irq };
00146 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _PEND_LINUX_IRQ, &arg);
00147 }
00148
00149 RTAI_PROTO(void *, rt_spin_lock_init,(void))
00150 {
00151 struct { int dummy; } arg = { 0 };
00152 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _INIT_SPIN_LOCK, &arg).v[LOW];
00153 }
00154
00155 RTAI_PROTO(void, rt_spin_lock,(void *lock))
00156 {
00157 struct { void *lock; } arg = { lock };
00158 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK, &arg);
00159 }
00160
00161 RTAI_PROTO(void, rt_spin_unlock,(void *lock))
00162 {
00163 struct { void *lock; } arg = { lock };
00164 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK, &arg);
00165 }
00166
00167 RTAI_PROTO(void, rt_spin_lock_irq,(void *lock))
00168 {
00169 struct { void *lock; } arg = { lock };
00170 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK_IRQ, &arg);
00171 }
00172
00173 RTAI_PROTO(void, rt_spin_unlock_irq,(void *lock))
00174 {
00175 struct { void *lock; } arg = { lock };
00176 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK_IRQ, &arg);
00177 }
00178
00179 RTAI_PROTO(unsigned long, rt_spin_lock_irqsave,(void *lock))
00180 {
00181 struct { void *lock; } arg = { lock };
00182 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK_IRQSV, &arg).i[LOW];
00183 }
00184
00185 RTAI_PROTO(void, rt_spin_unlock_irqrestore,(unsigned long flags, void *lock))
00186 {
00187 struct { unsigned long flags; void *lock; } arg = { flags, lock };
00188 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK_IRQRST, &arg);
00189 }
00190
00191
00192 RTAI_PROTO(void, rt_global_cli,(void))
00193 {
00194 struct { int dummy; } arg = { 0 };
00195 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_CLI, &arg);
00196 }
00197
00198 RTAI_PROTO(void, rt_global_sti,(void))
00199 {
00200 struct { int dummy; } arg = { 0 };
00201 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_STI, &arg);
00202 }
00203
00204 RTAI_PROTO(unsigned long, rt_global_save_flags_and_cli,(void))
00205 {
00206 struct { int dummy; } arg = { 0 };
00207 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_SVFLAGS_CLI, &arg).i[LOW];
00208 }
00209
00210 RTAI_PROTO(unsigned long, rt_global_save_flags,(void))
00211 {
00212 struct { int dummy; } arg = { 0 };
00213 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_SVFLAGS, &arg).i[LOW];
00214 }
00215
00216 RTAI_PROTO(void, rt_global_restore_flags,(unsigned long flags))
00217 {
00218 struct { unsigned long flags; } arg = { flags };
00219 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_RSTFLAGS, &arg);
00220 }
00221
00222 RTAI_PROTO(void, hard_cli,(void))
00223 {
00224 struct { int dummy; } arg = { 0 };
00225 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _CLI, &arg);
00226 }
00227
00228 RTAI_PROTO(void, hard_sti,(void))
00229 {
00230 struct { int dummy; } arg = { 0 };
00231 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _STI, &arg);
00232 }
00233
00234 RTAI_PROTO(unsigned long, hard_save_flags_and_cli,(void))
00235 {
00236 struct { int dummy; } arg = { 0 };
00237 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SVFLAGS_CLI, &arg).i[LOW];
00238 }
00239
00240 RTAI_PROTO(unsigned long, hard_save_flags,(void))
00241 {
00242 struct { int dummy; } arg = { 0 };
00243 return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SVFLAGS, &arg).i[LOW];
00244 }
00245
00246 RTAI_PROTO(void, hard_restore_flags,(unsigned long flags))
00247 {
00248 struct { unsigned long flags; } arg = { flags };
00249 rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _RSTFLAGS, &arg);
00250 }
00251
00252 RTAI_PROTO(int, rt_wait_intr,(void *sem, unsigned long *irq))
00253 {
00254 unsigned long lirq;
00255 int retval;
00256 struct { void *sem; unsigned long *lirq; int size; } arg = { sem, &lirq, sizeof(unsigned long *) };
00257 retval = rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _WAIT_INTR, &arg).i[LOW];
00258 if (irq) {
00259 *irq = lirq;
00260 }
00261 return retval;
00262 }
00263
00264 RTAI_PROTO(int, rt_wait_intr_if,(void *sem, unsigned long *irq))
00265 {
00266 unsigned long lirq;
00267 int retval;
00268 struct { void *sem; unsigned long *lirq; int size; } arg = { sem, &lirq, sizeof(unsigned long *) };
00269 retval = rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _WAIT_INTR_IF, &arg).i[LOW];
00270 if (irq) {
00271 *irq = lirq;
00272 }
00273 return retval;
00274 }
00275
00276 RTAI_PROTO(int, rt_wait_intr_until,(void *sem, RTIME until, unsigned long *irq))
00277 {
00278 unsigned long lirq;
00279 int retval;
00280 struct { void *sem; RTIME until; unsigned long *lirq; int size; } arg = { sem, until, &lirq, sizeof(unsigned long *) };
00281 retval = rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _WAIT_INTR_UNTIL, &arg).i[LOW];
00282 if (irq) {
00283 *irq = lirq;
00284 }
00285 return retval;
00286 }
00287
00288 RTAI_PROTO(int, rt_wait_intr_timed,(void *sem, RTIME delay, unsigned long *irq))
00289 {
00290 unsigned long lirq;
00291 int retval;
00292 struct { void *sem; RTIME delay; unsigned long *lirq; int size; } arg = { sem, delay, &lirq, sizeof(unsigned long *) };
00293 retval = rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _WAIT_INTR_TIMED, &arg).i[LOW];
00294 if (irq) {
00295 *irq = lirq;
00296 }
00297 return retval;
00298 }
00299
00300 #ifdef __cplusplus
00301 }
00302 #endif
00303
00304 #endif
00305
00306 #endif