rtai-core/include/rtai_mbx.h

Go to the documentation of this file.
00001 
00024 #ifndef _RTAI_MBX_H
00025 #define _RTAI_MBX_H
00026 
00027 #include <rtai_sem.h>
00028 
00029 struct rt_task_struct;
00030 struct rt_mailbox;
00031 
00032 #ifdef __KERNEL__
00033 
00034 #ifndef __cplusplus
00035 
00036 typedef struct rt_mailbox {
00037 
00038     int magic;
00039     SEM sndsem, rcvsem;
00040     struct rt_task_struct *waiting_task, *owndby;
00041     char *bufadr;
00042     int size, fbyte, lbyte, avbs, frbs;
00043     spinlock_t lock;
00044 
00045 } MBX;
00046 
00047 #else /* __cplusplus */
00048 extern "C" {
00049 #endif /* !__cplusplus */
00050 
00051 int __rtai_mbx_init(void);
00052 
00053 void __rtai_mbx_exit(void);
00054 
00055 int rt_typed_mbx_init(struct rt_mailbox *mbx, int size, int qtype);
00056 
00057 int rt_mbx_init(struct rt_mailbox *mbx, int size);
00058 
00059 int rt_mbx_delete(struct rt_mailbox *mbx);
00060 
00061 int _rt_mbx_send(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00062 static inline int rt_mbx_send(struct rt_mailbox *mbx, void *msg, int msg_size)
00063 {
00064         return _rt_mbx_send(mbx, msg, msg_size, 1);
00065 }
00066 
00067 int _rt_mbx_send_wp(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00068 static inline int rt_mbx_send_wp(struct rt_mailbox *mbx, void *msg, int msg_size)
00069 {
00070         return _rt_mbx_send_wp(mbx, msg, msg_size, 1);
00071 }
00072 
00073 int _rt_mbx_send_if(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00074 static inline int rt_mbx_send_if(struct rt_mailbox *mbx, void *msg, int msg_size)
00075 {
00076         return _rt_mbx_send_if(mbx, msg, msg_size, 1);
00077 }
00078 
00079 int _rt_mbx_send_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME timei, int space);
00080 static inline int rt_mbx_send_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time)
00081 {
00082         return _rt_mbx_send_until(mbx, msg, msg_size, time, 1);
00083 }
00084 
00085 int _rt_mbx_send_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay, int space);
00086 static inline int rt_mbx_send_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay)
00087 {
00088         return _rt_mbx_send_timed(mbx, msg, msg_size, delay, 1);
00089 }
00090 
00091 int _rt_mbx_ovrwr_send(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00092 static inline int rt_mbx_ovrwr_send(struct rt_mailbox *mbx, void *msg, int msg_size)
00093 {
00094         return _rt_mbx_ovrwr_send(mbx, msg, msg_size, 1);
00095 }
00096 
00097 int _rt_mbx_evdrp(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00098 static inline int rt_mbx_evdrp(struct rt_mailbox *mbx, void *msg, int msg_size)
00099 {
00100         return _rt_mbx_evdrp(mbx, msg, msg_size, 1);
00101 }
00102 
00103 int _rt_mbx_receive(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00104 static inline int rt_mbx_receive(struct rt_mailbox *mbx, void *msg, int msg_size)
00105 {
00106         return _rt_mbx_receive(mbx, msg, msg_size, 1);
00107 }
00108 
00109 int _rt_mbx_receive_wp(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00110 static inline int rt_mbx_receive_wp(struct rt_mailbox *mbx, void *msg, int msg_size)
00111 {
00112         return _rt_mbx_receive_wp(mbx, msg, msg_size, 1);
00113 }
00114 
00115 int _rt_mbx_receive_if(struct rt_mailbox *mbx, void *msg, int msg_size, int space);
00116 static inline int rt_mbx_receive_if(struct rt_mailbox *mbx, void *msg, int msg_size)
00117 {
00118         return _rt_mbx_receive_if(mbx, msg, msg_size, 1);
00119 }
00120 
00121 int _rt_mbx_receive_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time, int space);
00122 static inline int rt_mbx_receive_until(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time)
00123 {
00124         return _rt_mbx_receive_until(mbx, msg, msg_size, time, 1);
00125 }
00126 
00127 int _rt_mbx_receive_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay, int space);
00128 static inline int rt_mbx_receive_timed(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay)
00129 {
00130         return _rt_mbx_receive_timed(mbx, msg, msg_size, delay, 1);
00131 }
00132 
00133 struct rt_mailbox *_rt_typed_named_mbx_init(unsigned long mbx_name,
00134                                            int size,
00135                                            int qtype);
00136 static inline struct rt_mailbox *rt_typed_named_mbx_init(const char *mbx_name, int size, int qtype)
00137 {
00138         return _rt_typed_named_mbx_init(nam2num(mbx_name), size, qtype);
00139 }
00140 
00141 int rt_named_mbx_delete(struct rt_mailbox *mbx);
00142 
00143 #define rt_named_mbx_init(mbx_name, size)  rt_typed_named_mbx_init(mbx_name, size, FIFO_Q)
00144      
00145 #ifdef __cplusplus
00146 }
00147 #endif /* __cplusplus */
00148 
00149 #else /* !__KERNEL__ */
00150 
00151 #include <rtai_lxrt.h>
00152 
00153 #ifdef __cplusplus
00154 extern "C" {
00155 #endif /* __cplusplus */
00156 
00157 RTAI_PROTO(void *,rt_typed_mbx_init,(int name, int size, int qtype))
00158 {
00159         struct { int name; int size; int qtype; } arg = { name, size, qtype };
00160         return rtai_lxrt(BIDX, SIZARG, LXRT_MBX_INIT, &arg).v[LOW];
00161 }
00162 
00177 #define rt_mbx_init(name, size) rt_typed_mbx_init(name, size, FIFO_Q)
00178 
00179 RTAI_PROTO(int, rt_mbx_delete,(struct rt_mailbox *mbx))
00180 {
00181         void *arg = mbx;
00182         return rtai_lxrt(BIDX, SIZARG, LXRT_MBX_DELETE, &arg).i[LOW];
00183 }
00184 
00185 RTAI_PROTO(struct rt_mailbox *, rt_typed_named_mbx_init,(const char *name, int size, int type))
00186 {
00187         struct { unsigned long name; int size, type; } arg = { nam2num(name), size, type };
00188         return (struct rt_mailbox *)rtai_lxrt(BIDX, SIZARG, NAMED_MBX_INIT, &arg).v[LOW];
00189 }
00190 
00191 RTAI_PROTO(int, rt_named_mbx_delete,(struct rt_mailbox *mbx))
00192 {
00193         struct { struct rt_mailbox *mbx; } arg = { mbx };
00194         return rtai_lxrt(BIDX, SIZARG, NAMED_MBX_DELETE, &arg).i[LOW];
00195 }
00196 
00197 #define rt_named_mbx_init(mbx_name, size) \
00198         rt_typed_named_mbx_init(mbx_name, size, FIFO_Q)
00199 
00200 RTAI_PROTO(int, rt_mbx_send,(struct rt_mailbox *mbx, void *msg, int msg_size))
00201 {
00202         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00203         return (int)rtai_lxrt(BIDX, SIZARG, MBX_SEND, &arg).i[LOW];
00204 }
00205 
00206 RTAI_PROTO(int, rt_mbx_send_wp,(struct rt_mailbox *mbx, void *msg, int msg_size))
00207 {
00208         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00209         return (int)rtai_lxrt(BIDX, SIZARG, MBX_SEND_WP, &arg).i[LOW];
00210 }
00211 
00212 RTAI_PROTO(int, rt_mbx_send_if,(struct rt_mailbox *mbx, void *msg, int msg_size))
00213 {
00214         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00215         return (int)rtai_lxrt(BIDX, SIZARG, MBX_SEND_IF, &arg).i[LOW];
00216 }
00217 
00218 RTAI_PROTO(int, rt_mbx_send_until,(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time))
00219 {
00220         struct { struct rt_mailbox *mbx; char *msg; int msg_size; RTIME time; int space; } arg = { mbx, (char *)msg, msg_size, time, 0 };
00221         return (int)rtai_lxrt(BIDX, SIZARG, MBX_SEND_UNTIL, &arg).i[LOW];
00222 }
00223 
00224 RTAI_PROTO(int, rt_mbx_send_timed,(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay))
00225 {
00226         struct { struct rt_mailbox *mbx; char *msg; int msg_size; RTIME delay; int space; } arg = { mbx, (char *)msg, msg_size, delay, 0 };
00227         return (int)rtai_lxrt(BIDX, SIZARG, MBX_SEND_TIMED, &arg).i[LOW];
00228 }
00229 
00230 RTAI_PROTO(int, rt_mbx_ovrwr_send,(struct rt_mailbox *mbx, void *msg, int msg_size))
00231 {
00232         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00233         return (int)rtai_lxrt(BIDX, SIZARG, MBX_OVRWR_SEND, &arg).i[LOW];
00234 }
00235 
00236 RTAI_PROTO(int, rt_mbx_evdrp,(struct rt_mailbox *mbx, void *msg, int msg_size))
00237 {
00238         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00239         return (int)rtai_lxrt(BIDX, SIZARG, MBX_EVDRP, &arg).i[LOW];
00240 }
00241 
00242 RTAI_PROTO(int, rt_mbx_receive,(struct rt_mailbox *mbx, void *msg, int msg_size))
00243 {
00244         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00245         return (int)rtai_lxrt(BIDX, SIZARG, MBX_RECEIVE, &arg).i[LOW];
00246 }
00247 
00248 RTAI_PROTO(int, rt_mbx_receive_wp,(struct rt_mailbox *mbx, void *msg, int msg_size))
00249 {
00250         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00251         return (int)rtai_lxrt(BIDX, SIZARG, MBX_RECEIVE_WP, &arg).i[LOW];
00252 }
00253 
00254 RTAI_PROTO(int, rt_mbx_receive_if,(struct rt_mailbox *mbx, void *msg, int msg_size))
00255 {
00256         struct { struct rt_mailbox *mbx; char *msg; int msg_size; int space; } arg = { mbx, (char *)msg, msg_size, 0 };
00257         return (int)rtai_lxrt(BIDX, SIZARG, MBX_RECEIVE_IF, &arg).i[LOW];
00258 }
00259 
00260 RTAI_PROTO(int, rt_mbx_receive_until,(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME time))
00261 {
00262         struct { struct rt_mailbox *mbx; void *msg; int msg_size; RTIME time; int space; } arg = { mbx, (char *)msg, msg_size, time, 0 };
00263         return (int)rtai_lxrt(BIDX, SIZARG, MBX_RECEIVE_UNTIL, &arg).i[LOW];
00264 }
00265 
00266 RTAI_PROTO(int, rt_mbx_receive_timed,(struct rt_mailbox *mbx, void *msg, int msg_size, RTIME delay))
00267 {
00268         struct { struct rt_mailbox *mbx; char *msg; int msg_size; RTIME delay; int space; } arg = { mbx, (char *)msg, msg_size, delay, 0 };
00269         return (int)rtai_lxrt(BIDX, SIZARG, MBX_RECEIVE_TIMED, &arg).i[LOW];
00270 }
00271 
00272 #ifdef __cplusplus
00273 }
00274 #endif /* __cplusplus */
00275 
00276 #endif /* __KERNEL__ */
00277 
00278 #if !defined(__KERNEL__) || defined(__cplusplus)
00279 
00280 typedef struct rt_mailbox {
00281     int opaque;
00282 } MBX;
00283 
00284 #endif /* !__KERNEL__ || __cplusplus */
00285 
00286 #endif /* !_RTAI_MBX_H */

Generated on Sat Jul 24 19:36:03 2004 for RTAI API by doxygen 1.3.4