# rtai_usi.h

    00001 /*
    00002  * Copyright (C) 1999-2003 Paolo Mantegazza <mantegazza@aero.polimi.it>
    00003  *
    00004  * This program is free software; you can redistribute it and/or
    00005  * modify it under the terms of the GNU General Public License as
    00006  * published by the Free Software Foundation; either version 2 of the
    00007  * License, or (at your option) any later version.
    00008  *
    00009  * This program is distributed in the hope that it will be useful,
    00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  * GNU General Public License for more details.
    00013  *
    00014  * You should have received a copy of the GNU General Public License
    00015  * along with this program; if not, write to the Free Software
    00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    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 _STARTUP_IRQ             1
    00027 #define _SHUTDOWN_IRQ            2
    00028 #define _ENABLE_IRQ              3
    00029 #define _DISABLE_IRQ             4
    00030 #define _MASK_AND_ACK_IRQ        5
    00031 #define _ACK_IRQ                 6
    00032 #define _UNMASK_IRQ              7
    00033 #define _INIT_SPIN_LOCK          8
    00034 #define _SPIN_LOCK               9
    00035 #define _SPIN_UNLOCK            10
    00036 #define _SPIN_LOCK_IRQ          11
    00037 #define _SPIN_UNLOCK_IRQ        12
    00038 #define _SPIN_LOCK_IRQSV        13
    00039 #define _SPIN_UNLOCK_IRQRST     14
    00040 #define _GLB_CLI                15
    00041 #define _GLB_STI                16
    00042 #define _GLB_SVFLAGS_CLI        17
    00043 #define _GLB_SVFLAGS            18
    00044 #define _GLB_RSTFLAGS           19
    00045 #define _CLI                    20
    00046 #define _STI                    21
    00047 #define _SVFLAGS_CLI            22
    00048 #define _SVFLAGS                23
    00049 #define _RSTFLAGS               24
    00050
    00051 #ifdef __KERNEL__
    00052
    00053 #ifdef __cplusplus
    00054 extern "C" {
    00055 #endif /* __cplusplus */
    00056
    00057 int __rtai_usi_init(void);
    00058
    00059 void __rtai_usi_exit(void);
    00060
    00061 #ifdef __cplusplus
    00062 }
    00063 #endif /* __cplusplus */
    00064
    00065 #else /* !__KERNEL__ */
    00066
    00067 #include <rtai_lxrt.h>
    00068
    00069 #ifdef __cplusplus
    00070 extern "C" {
    00071 #endif /* __cplusplus */
    00072
    00073
    00074 RTAI_PROTO(int, rt_startup_irq,(unsigned int irq))
    00075 {
    00076         struct { unsigned int irq; } arg = { irq };
    00077         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _STARTUP_IRQ, &arg).i[LOW];
    00078 }
    00079
    00080 RTAI_PROTO(void, rt_shutdown_irq,(unsigned int irq))
    00081 {
    00082         struct { unsigned int irq; } arg = { irq };
    00083         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SHUTDOWN_IRQ, &arg);
    00084 }
    00085
    00086 RTAI_PROTO(void, rt_enable_irq,(unsigned int irq))
    00087 {
    00088         struct { unsigned int irq; } arg = { irq };
    00089         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _ENABLE_IRQ, &arg);
    00090 }
    00091
    00092 RTAI_PROTO(void, rt_disable_irq,(unsigned int irq))
    00093 {
    00094         struct { unsigned int irq; } arg = { irq };
    00095         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _DISABLE_IRQ, &arg);
    00096 }
    00097
    00098 RTAI_PROTO(void, rt_mask_and_ack_irq,(unsigned int irq))
    00099 {
    00100         struct { unsigned int irq; } arg = { irq };
    00101         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _MASK_AND_ACK_IRQ, &arg);
    00102 }
    00103
    00104 RTAI_PROTO(void, rt_ack_irq,(unsigned int irq))
    00105 {
    00106         struct { unsigned int irq; } arg = { irq };
    00107         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _ACK_IRQ, &arg);
    00108 }
    00109
    00110 RTAI_PROTO(void, rt_unmask_irq,(unsigned int irq))
    00111 {
    00112         struct { unsigned int irq; } arg = { irq };
    00113         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _UNMASK_IRQ, &arg);
    00114 }
    00115
    00116 RTAI_PROTO(void *, rt_spin_lock_init,(void))
    00117 {
    00118         struct { int dummy; } arg = { 0 };
    00119         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _INIT_SPIN_LOCK, &arg).v[LOW];
    00120 }
    00121
    00122 RTAI_PROTO(void, rt_spin_lock,(void *lock))
    00123 {
    00124         struct { void *lock; } arg = { lock };
    00125         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK, &arg);
    00126 }
    00127
    00128 RTAI_PROTO(void, rt_spin_unlock,(void *lock))
    00129 {
    00130         struct { void *lock; } arg = { lock };
    00131         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK, &arg);
    00132 }
    00133
    00134 RTAI_PROTO(void, rt_spin_lock_irq,(void *lock))
    00135 {
    00136         struct { void *lock; } arg = { lock };
    00137         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK_IRQ, &arg);
    00138 }
    00139
    00140 RTAI_PROTO(void, rt_spin_unlock_irq,(void *lock))
    00141 {
    00142         struct { void *lock; } arg = { lock };
    00143         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK_IRQ, &arg);
    00144 }
    00145
    00146 RTAI_PROTO(unsigned long, rt_spin_lock_irqsave,(void *lock))
    00147 {
    00148         struct { void *lock; } arg = { lock };
    00149         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_LOCK_IRQSV, &arg).i[LOW];
    00150 }
    00151
    00152 RTAI_PROTO(void, rt_spin_unlock_irqrestore,(unsigned long flags, void *lock))
    00153 {
    00154         struct { unsigned long flags; void *lock; } arg = { flags, lock };
    00155         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SPIN_UNLOCK_IRQRST, &arg);
    00156 }
    00157
    00158
    00159 RTAI_PROTO(void, rt_global_cli,(void))
    00160 {
    00161         struct { int dummy; } arg = { 0 };
    00162         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_CLI, &arg);
    00163 }
    00164
    00165 RTAI_PROTO(void, rt_global_sti,(void))
    00166 {
    00167         struct { int dummy; } arg = { 0 };
    00168         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_STI, &arg);
    00169 }
    00170
    00171 RTAI_PROTO(unsigned long, rt_global_save_flags_and_cli,(void))
    00172 {
    00173         struct { int dummy; } arg = { 0 };
    00174         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_SVFLAGS_CLI, &arg).i[LOW];
    00175 }
    00176
    00177 RTAI_PROTO(unsigned long, rt_global_save_flags,(void))
    00178 {
    00179         struct { int dummy; } arg = { 0 };
    00180         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_SVFLAGS, &arg).i[LOW];
    00181 }
    00182
    00183 RTAI_PROTO(void, rt_global_restore_flags,(unsigned long flags))
    00184 {
    00185         struct { unsigned long flags; } arg = { flags };
    00186         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _GLB_RSTFLAGS, &arg);
    00187 }
    00188
    00189 RTAI_PROTO(void, rtai_cli,(void))
    00190 {
    00191         struct { int dummy; } arg = { 0 };
    00192         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _CLI, &arg);
    00193 }
    00194
    00195 RTAI_PROTO(void, rtai_sti,(void))
    00196 {
    00197         struct { int dummy; } arg = { 0 };
    00198         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _STI, &arg);
    00199 }
    00200
    00201 RTAI_PROTO(unsigned long, rtai_save_flags_and_cli,(void))
    00202 {
    00203         struct { int dummy; } arg = { 0 };
    00204         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SVFLAGS_CLI, &arg).i[LOW];
    00205 }
    00206
    00207 RTAI_PROTO(unsigned long, rtai_save_flags,(void))
    00208 {
    00209         struct { int dummy; } arg = { 0 };
    00210         return rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _SVFLAGS, &arg).i[LOW];
    00211 }
    00212
    00213 RTAI_PROTO(void, rtai_restore_flags,(unsigned long flags))
    00214 {
    00215         struct { unsigned long flags; } arg = { flags };
    00216         rtai_lxrt(FUN_USI_LXRT_INDX, SIZARG, _RSTFLAGS, &arg);
    00217 }
    00218
    00219 #ifdef __cplusplus
    00220 }
    00221 #endif /* __cplusplus */
    00222
    00223 #endif /* __KERNEL__ */
    00224
    00225 #endif /* !_RTAI_USI_H */