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