# rtai_netrpc.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_NETRPC_H
    00020 #define _RTAI_NETRPC_H
    00021
    00022 #include <rtai_config.h>
    00023
    00024 #ifdef CONFIG_RTAI_INTERNAL_LXRT_SUPPORT
    00025
    00026 #include <rtai_registry.h>
    00027 #include <rtai_lxrt.h>
    00028 #include <rtai_sem.h>
    00029 #include <rtai_mbx.h>
    00030 #include <rtai_msg.h>
    00031
    00032 #define MAX_STUBS     16  // _M_U_S_T___B_E___P_O_W_E_R___O_F___2_
    00033 #define MAX_SOCKS     16
    00034 #define MAX_MSG_SIZE  1500
    00035
    00036 #define NET_RPC_EXT  0
    00037
    00038 // for writes
    00039 #define UW1(bf, sz)  ((((unsigned long long)((((bf) & 0x7F) <<  2) | (((sz) & 0x7F) <<  9))) << 32) | 0x300000001LL)
    00040 #define UW2(bf, sz)  ((((unsigned long long)((((bf) & 0x7F) << 16) | (((sz) & 0x7F) << 23))) << 32) | 0x300000001LL)
    00041 #define UWSZ1LL      (0x4000000300000001LL)
    00042 #define UWSZ2LL      (0x8000000300000001LL)
    00043
    00044 // for reads
    00045 #define UR1(bf, sz)  ((((bf) & 0x7F) <<  2) | (((sz) & 0x7F) <<  9) | 0x300000001LL)
    00046 #define UR2(bf, sz)  ((((bf) & 0x7F) << 16) | (((sz) & 0x7F) << 23) | 0x300000001LL)
    00047 #define URSZ1LL      (0x340000001LL)
    00048 #define URSZ2LL      (0x380000001LL)
    00049
    00050 #define SIZARG sizeof(arg)
    00051
    00052 #define PACKPORT(port, ext, fun, timed) (((port) << 18) | ((timed) << 13) | ((ext) << 8) | (fun))
    00053
    00054 #define PORT(i)   ((i) >> 18)
    00055 #define FUN(i)    ((i) & 0xFF)
    00056 #define EXT(i)    (((i) >> 8) & 0x1F)
    00057 #define TIMED(i)  (((i) >> 13) & 0x1F)
    00058
    00059 /*
    00060  * SYNC_NET_RPC is hard wired here, no need to have it elsewhere. It must
    00061  * have all the bits allowed to the "fun" field, in PACKPORT above, set.
    00062  */
    00063 #define SYNC_NET_RPC  0xFF  // hard wired here, no need to have it elsewhere
    00064
    00065 #define PRT_REQ  1
    00066 #define PRT_SRV  2
    00067 #define PRT_RTR  3
    00068 #define PRT_RCV  4
    00069 #define RPC_REQ  5
    00070 #define RPC_SRV  6
    00071 #define RPC_RTR  7
    00072 #define RPC_RCV  8
    00073
    00074 #define OWNER(node, task) \
    00075         ((((unsigned long long)(node)) << 32) | (unsigned long)(task))
    00076
    00077 #ifdef __KERNEL__
    00078
    00079 #include <rtai_sched.h>
    00080
    00081 #ifdef __cplusplus
    00082 extern "C" {
    00083 #endif /* __cplusplus */
    00084
    00085 int __rtai_netrpc_init(void);
    00086
    00087 void __rtai_netrpc_exit(void);
    00088
    00089 unsigned long long rt_net_rpc(int fun_ext_timed,
    00090                               long long type,
    00091                               void *args,
    00092                               int argsize,
    00093                               int space);
    00094
    00095 int rt_send_req_rel_port(unsigned long node,
    00096                          int port,
    00097                          unsigned long id,
    00098                          MBX *mbx,
    00099                          int hard);
    00100
    00101 unsigned long ddn2nl(const char *ddn);
    00102
    00103 unsigned long rt_set_this_node(const char *ddn,
    00104                                unsigned long node,
    00105                                int hard);
    00106
    00107 RT_TASK *rt_find_asgn_stub(unsigned long long owner,
    00108                            int asgn);
    00109
    00110 int rt_rel_stub(unsigned long long owner);
    00111
    00112 int rt_waiting_return(unsigned long node,
    00113                       int port);
    00114
    00115 int rt_get_net_rpc_ret(MBX *mbx,
    00116                        unsigned long long *retval,
    00117                        void *msg1,
    00118                        int *msglen1,
    00119                        void *msg2,
    00120                        int *msglen2,
    00121                        RTIME timeout,
    00122                        int type);
    00123
    00124 static inline int rt_sync_net_rpc(unsigned long node, int port)
    00125 {
    00126         if (node) {
    00127                 struct { int dummy; } arg = { 0 };
    00128                 return rt_net_rpc(PACKPORT(abs(port), NET_RPC_EXT, SYNC_NET_RPC, 0), 0LL, &arg, SIZARG, 1);
    00129         }
    00130         return 1;
    00131 }
    00132
    00133 static inline void *RT_get_adr(unsigned long node, int port, const char *sname)
    00134 {
    00135         if (node) {
    00136                 struct { int name; } arg = { nam2num(sname) };
    00137                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, GET_ADR, 0), 0LL, &arg, SIZARG, 1);
    00138         }
    00139         return rt_get_adr(nam2num(sname));
    00140 }
    00141
    00142 static inline RT_TASK *RT_named_task_init(unsigned long node, int port, const char *task_name, void (*thread)(int), int data, int stack_size, int prio, int uses_fpu, void(*signal)(void))
    00143 {
    00144         if (node) {
    00145                 struct { const char *task_name; void (*thread)(int); int data; int stack_size; int prio; int uses_fpu; void(*signal)(void); int namelen; } arg = { task_name, thread, data, stack_size, prio, uses_fpu, signal, strlen(task_name) };
    00146                 return (RT_TASK *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_TASK_INIT, 0), UR1(1, 8), &arg, SIZARG, 1);
    00147         }
    00148         return rt_named_task_init(task_name, thread, data, stack_size, prio, uses_fpu, signal);
    00149 }
    00150
    00151 static inline RT_TASK *RT_named_task_init_cpuid(unsigned long node, int port, const char *task_name, void (*thread)(int), int data, int stack_size, int prio, int uses_fpu, void(*signal)(void), unsigned int run_on_cpu)
    00152 {
    00153         if (node) {
    00154                 struct { const char *task_name; void (*thread)(int); int data; int stack_size; int prio; int uses_fpu; void(*signal)(void); unsigned int run_on_cpu; int namelen; } arg = { task_name, thread, data, stack_size, prio, uses_fpu, signal, run_on_cpu, strlen(task_name) };
    00155                 return (RT_TASK *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_TASK_INIT_CPUID, 0), UR1(1, 9), &arg, SIZARG, 1);
    00156         }
    00157         return rt_named_task_init_cpuid(task_name, thread, data, stack_size, prio, uses_fpu, signal, run_on_cpu);
    00158 }
    00159
    00160 static inline int RT_named_task_delete(unsigned long node, int port, RT_TASK *task)
    00161 {
    00162         if (node) {
    00163                 struct { RT_TASK *task; } arg = { task };
    00164                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_TASK_DELETE, 0), 0LL, &arg, SIZARG, 1);
    00165         }
    00166         return rt_named_task_delete(task);
    00167 }
    00168
    00169 static inline RTIME RT_get_time_ns(unsigned long node, int port)
    00170 {
    00171         if (node) {
    00172                 struct { int dummy; } arg = { 0 };
    00173                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, GET_TIME_NS, 0), 0LL, &arg, SIZARG, 1);
    00174         }
    00175         return rt_get_time_ns();
    00176 }
    00177
    00178 static inline RTIME RT_get_time_ns_cpuid(unsigned long node, int port, int cpuid)
    00179 {
    00180         if (node) {
    00181                 struct { int cpuid; } arg = { cpuid };
    00182                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, GET_TIME_NS_CPUID, 0), 0LL, &arg, SIZARG, 1);
    00183         }
    00184         return rt_get_time_ns_cpuid(cpuid);
    00185 }
    00186
    00187 static inline RTIME RT_get_cpu_time_ns(unsigned long node, int port)
    00188 {
    00189         if (node) {
    00190                 struct { int dummy; } arg = { 0 };
    00191                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, GET_CPU_TIME_NS, 0), 0LL, &arg, SIZARG, 1);
    00192         }
    00193         return rt_get_cpu_time_ns();
    00194 }
    00195
    00196 static inline int RT_task_suspend(unsigned long node, int port, RT_TASK *task)
    00197 {
    00198         if (node) {
    00199                 struct { RT_TASK *task; } arg = { task };
    00200                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SUSPEND, 0), 0LL, &arg, SIZARG, 1);
    00201         }
    00202         return rt_task_suspend(task);
    00203 }
    00204
    00205 static inline int RT_task_resume(unsigned long node, int port, RT_TASK *task)
    00206 {
    00207         if (node) {
    00208                 struct { RT_TASK *task; } arg = { task };
    00209                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RESUME, 0), 0LL, &arg, SIZARG, 1);
    00210         }
    00211         return rt_task_resume(task);
    00212 }
    00213
    00214 static inline void RT_sleep(unsigned long node, int port, RTIME delay)
    00215 {
    00216         if (node) {
    00217                 struct { RTIME delay; } arg = { delay };
    00218                 rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SLEEP, 1), 0LL, &arg, SIZARG, 1);
    00219                 return;
    00220         }
    00221         rt_sleep(nano2count(delay));
    00222 }
    00223
    00224 static inline void RT_sleep_until(unsigned long node, int port, RTIME time)
    00225 {
    00226         if (node) {
    00227                 struct { RTIME time; } arg = { time };
    00228                 rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SLEEP_UNTIL, 1), 0LL, &arg, SIZARG, 1);
    00229                 return;
    00230         }
    00231         rt_sleep_until(nano2count(time));
    00232 }
    00233
    00234 #if CONFIG_RTAI_SEM
    00235
    00236 static inline SEM *RT_typed_named_sem_init(unsigned long node, int port, const char *sem_name, int value, int type)
    00237 {
    00238         if (node) {
    00239                 struct { unsigned long sem_name; int value; int type; int namelen; } arg = { nam2num(sem_name), value, type };
    00240                 return (SEM *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_SEM_INIT, 0), 0LL, &arg, SIZARG, 1);
    00241         }
    00242         return rt_typed_named_sem_init(sem_name, value, type);
    00243 }
    00244
    00245 static inline int RT_named_sem_delete(unsigned long node, int port, SEM *sem)
    00246 {
    00247         if (node) {
    00248                 struct { SEM *sem; } arg = { sem };
    00249                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_SEM_DELETE, 0), 0LL, &arg, SIZARG, 1);
    00250         }
    00251         return rt_named_sem_delete(sem);
    00252 }
    00253
    00254 static inline int RT_sem_signal(unsigned long node, int port, SEM *sem)
    00255 {
    00256         if (node) {
    00257                 struct { SEM *sem; } arg = { sem };
    00258                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_SIGNAL, 0), 0LL, &arg, SIZARG, 1);
    00259         }
    00260         return rt_sem_signal(sem);
    00261 }
    00262
    00263 static inline int RT_sem_broadcast(unsigned long node, int port, SEM *sem)
    00264 {
    00265         if (node) {
    00266                 struct { SEM *sem; } arg = { sem };
    00267                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_BROADCAST, 0), 0LL, &arg, SIZARG, 1);
    00268         }
    00269         return rt_sem_broadcast(sem);
    00270 }
    00271
    00272 static inline int RT_sem_wait(unsigned long node, int port, SEM *sem)
    00273 {
    00274         if (node) {
    00275                 struct { SEM *sem; } arg = { sem };
    00276                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_WAIT, 0), 0LL, &arg, SIZARG, 1);
    00277         }
    00278         return rt_sem_wait(sem);
    00279 }
    00280
    00281 static inline int RT_sem_wait_if(unsigned long node, int port, SEM *sem)
    00282 {
    00283         if (node) {
    00284                 struct { SEM *sem; } arg = { sem };
    00285                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_WAIT_IF, 0), 0LL, &arg, SIZARG, 1);
    00286         }
    00287         return rt_sem_wait_if(sem);
    00288 }
    00289
    00290 static inline int RT_sem_wait_until(unsigned long node, int port, SEM *sem, RTIME time)
    00291 {
    00292         if (node) {
    00293                 struct { SEM *sem; RTIME time; } arg = { sem, time };
    00294                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_WAIT_UNTIL, 2), 0LL, &arg, SIZARG, 1);
    00295         }
    00296         return rt_sem_wait_until(sem, nano2count(time));
    00297 }
    00298
    00299 static inline int RT_sem_wait_timed(unsigned long node, int port, SEM *sem, RTIME delay)
    00300 {
    00301         if (node) {
    00302                 struct { SEM *sem; RTIME delay; } arg = { sem, delay };
    00303                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEM_WAIT_TIMED, 2), 0LL, &arg, SIZARG, 1);
    00304         }
    00305         return rt_sem_wait_timed(sem, nano2count(delay));
    00306 }
    00307
    00308 #endif /* CONFIG_RTAI_SEM */
    00309
    00310 #if CONFIG_RTAI_MSG
    00311
    00312 static inline RT_TASK *RT_send(unsigned long node, int port, RT_TASK *task, unsigned int msg)
    00313 {
    00314         if (node) {
    00315                 struct { RT_TASK *task; unsigned int msg; } arg = { task, msg };
    00316                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SENDMSG, 0), 0LL, &arg, SIZARG, 1);
    00317         }
    00318         return rt_send(task, msg);
    00319 }
    00320
    00321 static inline RT_TASK *RT_send_if(unsigned long node, int port, RT_TASK *task, unsigned int msg)
    00322 {
    00323         if (node) {
    00324                 struct { RT_TASK *task; unsigned int msg; } arg = { task, msg };
    00325                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEND_IF, 0), 0LL, &arg, SIZARG, 1);
    00326         }
    00327         return rt_send_if(task, msg);
    00328 }
    00329
    00330 static inline RT_TASK *RT_send_until(unsigned long node, int port, RT_TASK *task, unsigned int msg, RTIME time)
    00331 {
    00332         if (node) {
    00333                 struct { RT_TASK *task; unsigned int msg; RTIME time; } arg = { task, msg, time };
    00334                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEND_UNTIL, 3), 0LL, &arg, SIZARG, 1);
    00335         }
    00336         return rt_send_until(task, msg, nano2count(time));
    00337 }
    00338
    00339 static inline RT_TASK *RT_send_timed(unsigned long node, int port, RT_TASK *task, unsigned int msg, RTIME delay)
    00340 {
    00341         if (node) {
    00342                 struct { RT_TASK *task; unsigned int msg; RTIME delay; } arg = { task, msg, delay };
    00343                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SEND_TIMED, 3), 0LL, &arg, SIZARG, 1);
    00344         }
    00345         return rt_send_timed(task, msg, nano2count(delay));
    00346 }
    00347
    00348 static inline RT_TASK *RT_receive(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00349 {
    00350         if (!task || !node) {
    00351                 return rt_receive(task, msg);
    00352         }
    00353         return rt_receive(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00354 }
    00355
    00356 static inline RT_TASK *RT_receive_if(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00357 {
    00358         if (!task || !node) {
    00359                 return rt_receive_if(task, msg);
    00360         }
    00361         return rt_receive_if(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00362 }
    00363
    00364 static inline RT_TASK *RT_receive_until(unsigned long node, int port, RT_TASK *task, unsigned int *msg, RTIME time)
    00365 {
    00366         if (!task || !node) {
    00367                 return rt_receive_until(task, msg, nano2count(time));
    00368         }
    00369         return rt_receive_until(rt_find_asgn_stub(OWNER(node, task), 1), msg, nano2count(time)) ? task : 0;
    00370 }
    00371
    00372 static inline RT_TASK *RT_receive_timed(unsigned long node, int port, RT_TASK *task, unsigned int *msg, RTIME delay)
    00373 {
    00374         if (!task || !node) {
    00375                 return rt_receive_timed(task, msg, nano2count(delay));
    00376         }
    00377         return rt_receive_timed(rt_find_asgn_stub(OWNER(node, task), 1), msg, nano2count(delay)) ? task : 0;
    00378 }
    00379
    00380 static inline RT_TASK *RT_rpc(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret)
    00381 {
    00382         if (node) {
    00383                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; } arg = { task, msg, ret };
    00384                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPCMSG, 0), UW1(3, 0), &arg, SIZARG, 1);
    00385         }
    00386         return rt_rpc(task, msg, ret);
    00387 }
    00388
    00389 static inline RT_TASK *RT_rpc_if(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret)
    00390 {
    00391         if (node) {
    00392                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; } arg = { task, msg };
    00393                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPC_IF, 0), UW1(3, 0), &arg, SIZARG, 1);
    00394         }
    00395         return rt_rpc_if(task, msg, ret);
    00396 }
    00397
    00398 static inline RT_TASK *RT_rpc_until(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret, RTIME time)
    00399 {
    00400         if (node) {
    00401                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; RTIME time; } arg = { task, msg, ret, time };
    00402                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPC_UNTIL, 4), UW1(3, 0), &arg, SIZARG, 1);
    00403         }
    00404         return rt_rpc_until(task, msg, ret, nano2count(time));
    00405 }
    00406
    00407 static inline RT_TASK *RT_rpc_timed(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret, RTIME delay)
    00408 {
    00409         if (node) {
    00410                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; RTIME delay; } arg = { task, msg, ret, delay };
    00411                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPC_TIMED, 4), UW1(3, 0), &arg, SIZARG, 1);
    00412         }
    00413         return rt_rpc_timed(task, msg, ret, nano2count(delay));
    00414 }
    00415
    00416 static inline int RT_isrpc(unsigned long node, int port, RT_TASK *task)
    00417 {
    00418         if (node) {
    00419                 struct { RT_TASK *task; } arg = { task };
    00420                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, ISRPC, 0), 0LL, &arg, SIZARG, 1);
    00421         }
    00422         return rt_isrpc(task);
    00423 }
    00424
    00425 static inline RT_TASK *RT_return(unsigned long node, int port, RT_TASK *task, unsigned int result)
    00426 {
    00427         if (!task || !node) {
    00428                 return rt_return(task, result);
    00429         }
    00430         return rt_return(rt_find_asgn_stub(OWNER(node, task), 1), result) ? task : 0;
    00431 }
    00432
    00433 static inline RT_TASK *RT_evdrp(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00434 {
    00435         if (!task || !node) {
    00436                 return rt_evdrp(task, msg);
    00437         }
    00438         return rt_evdrp(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00439 }
    00440
    00441 static inline RT_TASK *RT_rpcx(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
    00442 {
    00443         if (node) {
    00444                 struct { RT_TASK *task; void *smsg; void *rmsg; int ssize; int rsize; } arg = { task, smsg, rmsg, ssize, rsize };
    00445                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPCX, 0), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 1);
    00446         }
    00447         return rt_rpcx(task, smsg, rmsg, ssize, rsize);
    00448 }
    00449
    00450 static inline RT_TASK *RT_rpcx_if(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
    00451 {
    00452         if (node) {
    00453                 struct { RT_TASK *task; void *smsg; void *rmsg; int ssize; int rsize; } arg = { task, smsg, rmsg, ssize, rsize };
    00454                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPCX_IF, 0), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 1);
    00455         }
    00456         return rt_rpcx_if(task, smsg, rmsg, ssize, rsize);
    00457 }
    00458
    00459 static inline RT_TASK *RT_rpcx_until(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME time)
    00460 {
    00461         if (node) {
    00462                 struct { RT_TASK *task; void *smsg; void *rmsg; int ssize; int rsize; RTIME time; } arg = { task, smsg, rmsg, ssize, rsize, time };
    00463                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPCX_UNTIL, 6), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 1);
    00464         }
    00465         return rt_rpcx_until(task, smsg, rmsg, ssize, rsize, nano2count(time));
    00466 }
    00467
    00468 static inline RT_TASK *RT_rpcx_timed(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME delay)
    00469 {
    00470         if (node) {
    00471                 struct { RT_TASK *task; void *smsg; void *rmsg; int ssize; int rsize; RTIME delay; } arg = { task, smsg, rmsg, ssize, rsize, delay };
    00472                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, RPCX_TIMED, 6), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 1);
    00473         }
    00474         return rt_rpcx_timed(task, smsg, rmsg, ssize, rsize, nano2count(delay));
    00475 }
    00476
    00477 static inline RT_TASK *RT_sendx(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    00478 {
    00479         if (node) {
    00480                 struct { RT_TASK *task; void *msg; int size; } arg = { task, msg, size };
    00481                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SENDX, 0), UR1(2, 3), &arg, SIZARG, 1);
    00482         }
    00483         return rt_sendx(task, msg, size);
    00484 }
    00485
    00486 static inline RT_TASK *RT_sendx_if(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    00487 {
    00488         if (node) {
    00489                 struct { RT_TASK *task; void *msg; int size; } arg = { task, msg, size };
    00490                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SENDX_IF, 0), UR1(2, 3), &arg, SIZARG, 1);
    00491         }
    00492         return rt_sendx_if(task, msg, size);
    00493 }
    00494
    00495 static inline RT_TASK *RT_sendx_until(unsigned long node, int port, RT_TASK *task, void *msg, int size, RTIME time)
    00496 {
    00497         if (node) {
    00498                 struct { RT_TASK *task; void *msg; int size; RTIME time; } arg = { task, msg, size, time };
    00499                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SENDX_UNTIL, 4), UR1(2, 3), &arg, SIZARG, 1);
    00500         }
    00501         return rt_sendx_until(task, msg, size, nano2count(time));
    00502 }
    00503
    00504 static inline RT_TASK *RT_sendx_timed(unsigned long node, int port, RT_TASK *task, void *msg, int size, RTIME delay)
    00505 {
    00506         if (node) {
    00507                 struct { RT_TASK *task; void *msg; int size; RTIME delay; } arg = { task, msg, size, delay };
    00508                 return (void *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, SENDX_TIMED, 4), UR1(2, 3), &arg, SIZARG, 1);
    00509         }
    00510         return rt_sendx_timed(task, msg, size, nano2count(delay));
    00511 }
    00512
    00513 static inline RT_TASK *RT_returnx(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    00514 {
    00515         if (!task || !node) {
    00516                 return rt_returnx(task, msg, size);
    00517         }
    00518         return rt_returnx(rt_find_asgn_stub(OWNER(node, task), 1), msg, size) ? task : 0;
    00519 }
    00520
    00521 static inline RT_TASK *RT_evdrpx(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    00522 {
    00523         if (!task || !node) {
    00524                 return rt_evdrpx(task, msg, size, len);
    00525         }
    00526         return rt_evdrpx(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    00527 }
    00528
    00529 static inline RT_TASK *RT_receivex(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    00530 {
    00531         if (!task || !node) {
    00532                 return rt_receivex(task, msg, size, len);
    00533         }
    00534         return rt_receivex(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    00535 }
    00536
    00537 static inline RT_TASK *RT_receivex_if(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    00538 {
    00539         if (!task || !node) {
    00540                 return rt_receivex_if(task, msg, size, len);
    00541         }
    00542         return rt_receivex_if(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    00543 }
    00544
    00545 static inline RT_TASK *RT_receivex_until(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len, RTIME time)
    00546 {
    00547         if (!task || !node) {
    00548                 return rt_receivex_until(task, msg, size, len, nano2count(time));
    00549         }
    00550         return rt_receivex_until(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len, nano2count(time)) ? task : 0;
    00551 }
    00552
    00553 static inline RT_TASK *RT_receivex_timed(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len, RTIME delay)
    00554 {
    00555         if (!task || !node) {
    00556                 return rt_receivex_timed(task, msg, size, len, nano2count(delay));
    00557         }
    00558         return rt_receivex_timed(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len, nano2count(delay)) ? task : 0;
    00559 }
    00560
    00561 #endif /* CONFIG_RTAI_MSG */
    00562
    00563 #if CONFIG_RTAI_MBX
    00564
    00565 static inline MBX *RT_typed_named_mbx_init(unsigned long node, int port, const char *mbx_name, int size, int qtype)
    00566 {
    00567         if (node) {
    00568                 struct { unsigned long mbx_name; int size; int qype; int namelen; } arg = { nam2num(mbx_name), size, qtype };
    00569                 return (MBX *)(unsigned long)rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_MBX_INIT, 0), 0LL, &arg, SIZARG, 1);
    00570         }
    00571         return rt_typed_named_mbx_init(mbx_name, size, qtype);
    00572 }
    00573
    00574 static inline int RT_named_mbx_delete(unsigned long node, int port, MBX *mbx)
    00575 {
    00576         if (node) {
    00577                 struct { MBX *mbx; } arg = { mbx };
    00578                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, NAMED_MBX_DELETE, 0), 0LL, &arg, SIZARG, 1);
    00579         }
    00580         return rt_named_mbx_delete(mbx);
    00581 }
    00582
    00583 static inline int RT_mbx_send(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00584 {
    00585         if (node) {
    00586                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00587                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_SEND, 0), UR1(2, 3), &arg, SIZARG, 1);
    00588         }
    00589         return rt_mbx_send(mbx, msg, msg_size);
    00590 }
    00591
    00592 static inline int RT_mbx_send_wp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00593 {
    00594         if (node) {
    00595                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00596                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_SEND_WP, 0), UR1(2, 3), &arg, SIZARG, 1);
    00597         }
    00598         return rt_mbx_send_wp(mbx, msg, msg_size);
    00599 }
    00600
    00601 static inline int RT_mbx_send_if(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00602 {
    00603         if (node) {
    00604                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00605                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_SEND_IF, 0), UR1(2, 3), &arg, SIZARG, 1);
    00606         }
    00607         return rt_mbx_send_if(mbx, msg, msg_size);
    00608 }
    00609
    00610 static inline int RT_mbx_ovrwr_send(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00611 {
    00612         if (node) {
    00613                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00614                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_OVRWR_SEND, 0), UR1(2, 3), &arg, SIZARG, 1);
    00615         }
    00616         return rt_mbx_ovrwr_send(mbx, msg, msg_size);
    00617 }
    00618
    00619 static inline int RT_mbx_send_until(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME time)
    00620 {
    00621         if (node) {
    00622                 struct { MBX *mbx; void *msg; int msg_size; RTIME time; int space; } arg = { mbx, msg, msg_size, time, 1 };
    00623                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_SEND_UNTIL, 4), UR1(2, 3), &arg, SIZARG, 1);
    00624         }
    00625         return rt_mbx_send_until(mbx, msg, msg_size, nano2count(time));
    00626 }
    00627
    00628 static inline int RT_mbx_send_timed(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME delay)
    00629 {
    00630         if (node) {
    00631                 struct { MBX *mbx; void *msg; int msg_size; RTIME delay; int space; } arg = { mbx, msg, msg_size, delay, 1 };
    00632                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_SEND_TIMED, 4), UR1(2, 3), &arg, SIZARG, 1);
    00633         }
    00634         return rt_mbx_send_timed(mbx, msg, msg_size, nano2count(delay));
    00635 }
    00636
    00637 static inline int RT_mbx_evdrp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00638 {
    00639         if (node) {
    00640                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00641                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_EVDRP, 0), UW1(2, 3), &arg, SIZARG, 1);
    00642         }
    00643         return rt_mbx_evdrp(mbx, msg, msg_size);
    00644 }
    00645
    00646 static inline int RT_mbx_receive(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00647 {
    00648         if (node) {
    00649                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00650                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE, 0), UW1(2, 3), &arg, SIZARG, 1);
    00651         }
    00652         return rt_mbx_receive(mbx, msg, msg_size);
    00653 }
    00654
    00655 static inline int RT_mbx_receive_wp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00656 {
    00657         if (node) {
    00658                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00659                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_WP, 0), UW1(2, 3), &arg, SIZARG, 1);
    00660         }
    00661         return rt_mbx_receive_wp(mbx, msg, msg_size);
    00662 }
    00663
    00664 static inline int RT_mbx_receive_if(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    00665 {
    00666         if (node) {
    00667                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    00668                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_IF, 0), UW1(2, 3), &arg, SIZARG, 1);
    00669         }
    00670         return rt_mbx_receive_if(mbx, msg, msg_size);
    00671 }
    00672
    00673 static inline int RT_mbx_receive_until(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME time)
    00674 {
    00675         if (node) {
    00676                 struct { MBX *mbx; void *msg; int msg_size; RTIME time; int space; } arg = { mbx, msg, msg_size, time, 1 };
    00677                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_UNTIL, 4), UW1(2, 3), &arg, SIZARG, 1);
    00678         }
    00679         return rt_mbx_receive_until(mbx, msg, msg_size, nano2count(time));
    00680 }
    00681
    00682 static inline int RT_mbx_receive_timed(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME delay)
    00683 {
    00684         if (node) {
    00685                 struct { MBX *mbx; void *msg; int msg_size; RTIME delay; int space; } arg = { mbx, msg, msg_size, delay, 1 };
    00686                 return rt_net_rpc(PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_TIMED, 4), UW1(2, 3), &arg, SIZARG, 1);
    00687         }
    00688         return rt_mbx_receive_timed(mbx, msg, msg_size, nano2count(delay));
    00689 }
    00690
    00691 #endif /* CONFIG_RTAI_MBX */
    00692
    00693 #ifdef __cplusplus
    00694 }
    00695 #endif /* __cplusplus */
    00696
    00697 #else /* !__KERNEL__ */
    00698
    00699 #include <stdlib.h>
    00700
    00701 #define NET_RPC_IDX  0
    00702
    00703 #define SIZARGS sizeof(args)
    00704
    00705 static inline int rt_send_req_rel_port(unsigned long node, int port, unsigned long id, MBX *mbx, int hard)
    00706 {
    00707         struct { unsigned long node, port; unsigned long id; MBX *mbx; int hard; } args = { node, port, id, mbx, hard };
    00708         return rtai_lxrt(NET_RPC_IDX, SIZARGS, SEND_REQ_REL_PORT, &args).i[LOW];
    00709 }
    00710
    00711 static inline unsigned long ddn2nl(const char *ddn)
    00712 {
    00713         struct { const char *ddn; } args = { ddn };
    00714         return rtai_lxrt(NET_RPC_IDX, SIZARGS, DDN2NL, &args).i[LOW];
    00715 }
    00716
    00717 static inline unsigned long rt_set_this_node(const char *ddn, unsigned long node, int hard)
    00718 {
    00719         struct { const char *ddn; unsigned long node; int hard; } args = { ddn, node, hard };
    00720         return rtai_lxrt(NET_RPC_IDX, SIZARGS, SET_THIS_NODE, &args).i[LOW];
    00721 }
    00722
    00723 static inline RT_TASK *rt_find_asgn_stub(unsigned long long owner, int asgn)
    00724 {
    00725         struct { unsigned long long owner; int asgn; } args = { owner, asgn };
    00726         return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, FIND_ASGN_STUB, &args).v[LOW];
    00727 }
    00728
    00729 static inline int rt_rel_stub(unsigned long long owner)
    00730 {
    00731         struct { unsigned long long owner; } args = { owner };
    00732         return rtai_lxrt(NET_RPC_IDX, SIZARGS, REL_STUB, &args).i[LOW];
    00733 }
    00734
    00735 static inline int rt_waiting_return(unsigned long node, int port)
    00736 {
    00737         struct { unsigned long node; int port; } args = { node, port };
    00738         return rtai_lxrt(NET_RPC_IDX, SIZARGS, WAITING_RETURN, &args).i[LOW];
    00739 }
    00740
    00741 static inline int rt_sync_net_rpc(unsigned long node, int port)
    00742 {
    00743         if (node) {
    00744                 struct { int dummy; } arg = { 0 };
    00745                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(abs(port), NET_RPC_EXT, SYNC_NET_RPC, 0), 0LL, &arg, SIZARG, 0 };
    00746                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00747         }
    00748         return 1;
    00749 }
    00750
    00751 static inline void *RT_get_adr(unsigned long node, int port, const char *sname)
    00752 {
    00753         if (node) {
    00754                 struct { int name; } arg = { nam2num(sname) };
    00755                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, GET_ADR, 0), 0LL, &arg,SIZARG, 0 };
    00756                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00757         }
    00758         return rt_get_adr(nam2num(sname));
    00759 }
    00760
    00761 static inline RTIME RT_get_time_ns(unsigned long node, int port)
    00762 {
    00763         if (node) {
    00764                 struct { int dummy; } arg = { 0 };
    00765                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, GET_TIME_NS, 0), 0LL, &arg, SIZARG, 0 };
    00766                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).rt;
    00767         }
    00768         return rt_get_time_ns();
    00769 }
    00770
    00771 static inline RTIME RT_get_time_ns_cpuid(unsigned long node, int port, int cpuid)
    00772 {
    00773         if (node) {
    00774                 struct { int cpuid; } arg = { cpuid };
    00775                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, GET_TIME_NS_CPUID, 0), 0LL, &arg, SIZARG, 0 };
    00776                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).rt;
    00777         }
    00778         return rt_get_time_ns_cpuid(cpuid);
    00779 }
    00780
    00781 static inline RTIME RT_get_cpu_time_ns(unsigned long node, int port)
    00782 {
    00783         if (node) {
    00784                 struct { int dummy; } arg = { 0 };
    00785                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, GET_CPU_TIME_NS, 0), 0LL, &arg, SIZARG, 0 };
    00786                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).rt;
    00787         }
    00788         return rt_get_cpu_time_ns();
    00789 }
    00790
    00791 static inline void RT_task_suspend(unsigned long node, int port, RT_TASK *task)
    00792 {
    00793         if (node) {
    00794                 struct { RT_TASK *task; } arg = { task };
    00795                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SUSPEND, 0), 0LL, &arg, SIZARG, 0 };
    00796                 rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args);
    00797                 return;
    00798         }
    00799         rt_task_suspend(task);
    00800 }
    00801
    00802 static inline void RT_task_resume(unsigned long node, int port, RT_TASK *task)
    00803 {
    00804         if (node) {
    00805                 struct { RT_TASK *task; } arg = { task };
    00806                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RESUME, 0), 0LL, &arg, SIZARG, 0 };
    00807                 rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args);
    00808                 return;
    00809         }
    00810         rt_task_resume(task);
    00811 }
    00812
    00813 static inline void RT_sleep(unsigned long node, int port, RTIME delay)
    00814 {
    00815         if (node) {
    00816                 struct { RTIME delay; } arg = { delay };
    00817                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SLEEP, 1), 0LL, &arg, SIZARG, 0 };
    00818                 rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args);
    00819                 return;
    00820         }
    00821         rt_sleep(nano2count(delay));
    00822 }
    00823
    00824 static inline void RT_sleep_until(unsigned long node, int port, RTIME time)
    00825 {
    00826         if (node) {
    00827                 struct { RTIME time; } arg = { time };
    00828                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SLEEP_UNTIL, 1), 0LL, &arg, SIZARG, 0 };
    00829                 rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args);
    00830                 return;
    00831         }
    00832         rt_sleep(nano2count(time));
    00833 }
    00834
    00835 #if CONFIG_RTAI_SEM
    00836
    00837 static inline SEM *RT_typed_named_sem_init(unsigned long node, int port, const char *sem_name, int value, int type)
    00838 {
    00839         if (node) {
    00840                 struct { unsigned long sem_name; int value; int type; int namelen; } arg = { nam2num(sem_name), value, type };
    00841                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, NAMED_SEM_INIT, 0), 0LL, &arg, SIZARG, 0 };
    00842                 return (SEM *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00843         }
    00844         return rt_typed_named_sem_init(sem_name, value, type);
    00845 }
    00846
    00847 static inline int RT_named_sem_delete(unsigned long node, int port, SEM *sem)
    00848 {
    00849         if (node) {
    00850                 struct { SEM *sem; } arg = { sem };
    00851                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, NAMED_SEM_DELETE, 0), 0LL, &arg, SIZARG, 0 };
    00852                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00853         }
    00854         return rt_named_sem_delete(sem);
    00855 }
    00856
    00857 static inline int RT_sem_signal(unsigned long node, int port, SEM *sem)
    00858 {
    00859         if (node) {
    00860                 struct { SEM *sem; } arg = { sem };
    00861                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_SIGNAL, 0), 0LL, &arg, SIZARG, 0 };
    00862                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00863         }
    00864         return rt_sem_signal(sem);
    00865 }
    00866
    00867 static inline int RT_sem_broadcast(unsigned long node, int port, SEM *sem)
    00868 {
    00869         if (node) {
    00870                 struct { SEM *sem; } arg = { sem };
    00871                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_BROADCAST, 0), 0LL, &arg, SIZARG, 0 };
    00872                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00873         }
    00874         return rt_sem_broadcast(sem);
    00875 }
    00876
    00877 static inline int RT_sem_wait(unsigned long node, int port, SEM *sem)
    00878 {
    00879         if (node) {
    00880                 struct { SEM *sem; } arg = { sem };
    00881                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_WAIT, 0), 0LL, &arg, SIZARG, 0 };
    00882                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00883         }
    00884         return rt_sem_wait(sem);
    00885 }
    00886
    00887 static inline int RT_sem_wait_if(unsigned long node, int port, SEM *sem)
    00888 {
    00889         if (node) {
    00890                 struct { SEM *sem; } arg = { sem };
    00891                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_WAIT_IF, 0), 0LL, &arg, SIZARG, 0 };
    00892                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00893         }
    00894         return rt_sem_wait_if(sem);
    00895 }
    00896
    00897 static inline int RT_sem_wait_until(unsigned long node, int port, SEM *sem, RTIME time)
    00898 {
    00899         if (node) {
    00900                 struct { SEM *sem; RTIME time; } arg = { sem, time };
    00901                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_WAIT_UNTIL, 2), 0LL, &arg, SIZARG, 0 };
    00902                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00903         }
    00904         return rt_sem_wait_until(sem, nano2count(time));
    00905 }
    00906
    00907 static inline int RT_sem_wait_timed(unsigned long node, int port, SEM *sem, RTIME delay)
    00908 {
    00909         if (node) {
    00910                 struct { SEM *sem; RTIME delay; } arg = { sem, delay };
    00911                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEM_WAIT_TIMED, 2), 0LL, &arg, SIZARG, 0 };
    00912                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    00913         }
    00914         return rt_sem_wait_timed(sem, nano2count(delay));
    00915 }
    00916
    00917 #endif /* CONFIG_RTAI_SEM */
    00918
    00919 #if CONFIG_RTAI_MSG
    00920
    00921 static inline RT_TASK *RT_send(unsigned long node, int port, RT_TASK *task, unsigned int msg)
    00922 {
    00923         if (node) {
    00924                 struct { RT_TASK *task; unsigned int msg; } arg = { task, msg };
    00925                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SENDMSG, 0), 0LL, &arg, SIZARG, 0 };
    00926                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00927         }
    00928         return rt_send(task, msg);
    00929 }
    00930
    00931 static inline RT_TASK *RT_send_if(unsigned long node, int port, RT_TASK *task, unsigned int msg)
    00932 {
    00933         if (node) {
    00934                 struct { RT_TASK *task; unsigned int msg; } arg = { task, msg };
    00935                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEND_IF, 0), 0LL, &arg, SIZARG, 0 };
    00936                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00937         }
    00938         return rt_send_if(task, msg);
    00939 }
    00940
    00941 static inline RT_TASK *RT_send_until(unsigned long node, int port, RT_TASK *task, unsigned int msg, RTIME time)
    00942 {
    00943         if (node) {
    00944                 struct { RT_TASK *task; unsigned int msg; RTIME time; } arg = { task, msg, time };
    00945                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEND_UNTIL, 3), 0LL, &arg, SIZARG, 0 };
    00946                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00947         }
    00948         return rt_send_until(task, msg, nano2count(time));
    00949 }
    00950
    00951 static inline RT_TASK *RT_send_timed(unsigned long node, int port, RT_TASK *task, unsigned int msg, RTIME delay)
    00952 {
    00953         if (node) {
    00954                 struct { RT_TASK *task; unsigned int msg; RTIME delay; } arg = { task, msg, delay };
    00955                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SEND_TIMED, 3), 0LL, &arg, SIZARG, 0 };
    00956                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    00957         }
    00958         return rt_send_timed(task, msg, nano2count(delay));
    00959 }
    00960
    00961 static inline RT_TASK *RT_evdrp(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00962 {
    00963         if (!task || !node) {
    00964                 return rt_evdrp(task, msg);
    00965         }
    00966         return rt_evdrp(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00967 }
    00968
    00969 static inline RT_TASK *RT_receive(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00970 {
    00971         if (!task || !node) {
    00972                 return rt_receive(task, msg);
    00973         }
    00974         return rt_receive(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00975 }
    00976
    00977 static inline RT_TASK *RT_receive_if(unsigned long node, int port, RT_TASK *task, unsigned int *msg)
    00978 {
    00979         if (!task || !node) {
    00980                 return rt_receive_if(task, msg);
    00981         }
    00982         return rt_receive_if(rt_find_asgn_stub(OWNER(node, task), 1), msg) ? task : 0;
    00983 }
    00984
    00985 static inline RT_TASK *RT_receive_until(unsigned long node, int port, RT_TASK *task, unsigned int *msg, RTIME time)
    00986 {
    00987         if (!task || !node) {
    00988                 return rt_receive_until(task, msg, nano2count(time));
    00989         }
    00990         return rt_receive_until(rt_find_asgn_stub(OWNER(node, task), 1), msg, nano2count(time)) ? task : 0;
    00991 }
    00992
    00993 static inline RT_TASK *RT_receive_timed(unsigned long node, int port, RT_TASK *task, unsigned int *msg, RTIME delay)
    00994 {
    00995         if (!task || !node) {
    00996                 return rt_receive_timed(task, msg, nano2count(delay));
    00997         }
    00998         return rt_receive_timed(rt_find_asgn_stub(OWNER(node, task), 1), msg, nano2count(delay)) ? task : 0;
    00999 }
    01000
    01001 static inline RT_TASK *RT_rpc(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret)
    01002 {
    01003         if (node) {
    01004                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; } arg = { task, msg, ret };
    01005                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPCMSG, 0), UW1(3, 0), &arg, SIZARG, 0 };
    01006                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01007         }
    01008         return rt_rpc(task, msg, ret);
    01009 }
    01010
    01011 static inline RT_TASK *RT_rpc_if(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret)
    01012 {
    01013         if (node) {
    01014                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; } arg = { task, msg, ret };
    01015                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPC_IF, 0), UW1(3, 0), &arg, SIZARG, 0 };
    01016                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01017         }
    01018         return rt_rpc_if(task, msg, ret);
    01019 }
    01020
    01021 static inline RT_TASK *RT_rpc_until(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret, RTIME time)
    01022 {
    01023         if (node) {
    01024                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; RTIME time; } arg = { task, msg, ret, time };
    01025                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPC_UNTIL, 4), UW1(3, 0), &arg, SIZARG, 0 };
    01026                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01027         }
    01028         return rt_rpc_until(task, msg, ret, nano2count(time));
    01029 }
    01030
    01031 static inline RT_TASK *RT_rpc_timed(unsigned long node, int port, RT_TASK *task, unsigned int msg, unsigned int *ret, RTIME delay)
    01032 {
    01033         if (node) {
    01034                 struct { RT_TASK *task; unsigned int msg; unsigned int *ret; RTIME delay; } arg = { task, msg, ret, delay };
    01035                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPC_TIMED, 4), UW1(3, 0), &arg, SIZARG, 0 };
    01036                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01037         }
    01038         return rt_rpc_timed(task, msg, ret, nano2count(delay));
    01039 }
    01040
    01041 static inline int RT_isrpc(unsigned long node, int port, RT_TASK *task)
    01042 {
    01043         if (node) {
    01044                 struct { RT_TASK *task; } arg = { task };
    01045                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, ISRPC, 0), 0LL, &arg, SIZARG, 0 };
    01046                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01047         }
    01048         return rt_isrpc(task);
    01049 }
    01050
    01051 static inline RT_TASK *RT_return(unsigned long node, int port, RT_TASK *task, unsigned int result)
    01052 {
    01053
    01054         if (!task || !node) {
    01055                 return rt_return(task, result);
    01056         }
    01057         return rt_return(rt_find_asgn_stub(OWNER(node, task), 1), result) ? task : 0;
    01058 }
    01059
    01060 static inline RT_TASK *RT_rpcx(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
    01061 {
    01062         if (node) {
    01063                 struct { RT_TASK *task; void *smsg, *rmsg; int ssize, rsize; } arg = { task, smsg, rmsg, ssize, rsize };
    01064                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPCX, 0), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 0 };
    01065                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01066         }
    01067         return rt_rpcx(task, smsg, rmsg, ssize, rsize);
    01068 }
    01069
    01070 static inline RT_TASK *RT_rpcx_if(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
    01071 {
    01072         if (node) {
    01073                 struct { RT_TASK *task; void *smsg, *rmsg; int ssize, rsize; } arg = { task, smsg, rmsg, ssize, rsize };
    01074                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPCX_IF, 0), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 0 };
    01075                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01076         }
    01077         return rt_rpcx_if(task, smsg, rmsg, ssize, rsize);
    01078 }
    01079
    01080 static inline RT_TASK *RT_rpcx_until(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME time)
    01081 {
    01082         if (node) {
    01083                 struct { RT_TASK *task; void *smsg, *rmsg; int ssize, rsize; RTIME time; } arg = { task, smsg, rmsg, ssize, rsize, time };
    01084                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPCX_UNTIL, 6), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 0 };
    01085                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01086         }
    01087         return rt_rpcx_until(task, smsg, rmsg, ssize, rsize, nano2count(time));
    01088 }
    01089
    01090 static inline RT_TASK *RT_rpcx_timed(unsigned long node, int port, RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME delay)
    01091 {
    01092         if (node) {
    01093                 struct { RT_TASK *task; void *smsg, *rmsg; int ssize, rsize; RTIME delay; } arg = { task, smsg, rmsg, ssize, rsize, delay };
    01094                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, RPCX_TIMED, 6), UR1(2, 4) | UW1(3, 5), &arg, SIZARG, 0 };
    01095                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01096         }
    01097         return rt_rpcx_timed(task, smsg, rmsg, ssize, rsize, nano2count(delay));
    01098 }
    01099
    01100 static inline RT_TASK *RT_sendx(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    01101 {
    01102         if (node) {
    01103                 struct { RT_TASK *task; void *msg; int size; } arg = { task, msg, size };
    01104                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SENDX, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01105                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01106         }
    01107         return rt_sendx(task, msg, size);
    01108 }
    01109
    01110 static inline RT_TASK *RT_sendx_if(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    01111 {
    01112         if (node) {
    01113                 struct { RT_TASK *task; void *msg; int size; } arg = { task, msg, size };
    01114                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SENDX_IF, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01115                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01116         }
    01117         return rt_sendx_if(task, msg, size);
    01118 }
    01119
    01120 static inline RT_TASK *RT_sendx_until(unsigned long node, int port, RT_TASK *task, void *msg, int size, RTIME time)
    01121 {
    01122         if (node) {
    01123                 struct { RT_TASK *task; void *msg; int size; RTIME time; } arg = { task, msg, size, time };
    01124                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SENDX_UNTIL, 4), UR1(2, 3), &arg, SIZARG, 0 };
    01125                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01126         }
    01127         return rt_sendx_until(task, msg, size, nano2count(time));
    01128 }
    01129
    01130 static inline RT_TASK *RT_sendx_timed(unsigned long node, int port, RT_TASK *task, void *msg, int size, RTIME delay)
    01131 {
    01132         if (node) {
    01133                 struct { RT_TASK *task; void *msg; int size; RTIME delay; } arg = { task, msg, size, delay };
    01134                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, SENDX_TIMED, 4), UR1(2, 3), &arg, SIZARG, 0 };
    01135                 return (RT_TASK *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01136         }
    01137         return rt_sendx_timed(task, msg, size, nano2count(delay));
    01138 }
    01139
    01140 static inline RT_TASK *RT_returnx(unsigned long node, int port, RT_TASK *task, void *msg, int size)
    01141 {
    01142
    01143         if (!task || !node) {
    01144                 return rt_returnx(task, msg, size);
    01145         }
    01146         return rt_returnx(rt_find_asgn_stub(OWNER(node, task), 1), msg, size) ? task : 0;
    01147 }
    01148
    01149 static inline RT_TASK *RT_evdrpx(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    01150 {
    01151         if (!task || !node) {
    01152                 return rt_evdrpx(task, msg, size, len);
    01153         }
    01154         return rt_evdrpx(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    01155 }
    01156
    01157 static inline RT_TASK *RT_receivex(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    01158 {
    01159         if (!task || !node) {
    01160                 return rt_receivex(task, msg, size, len);
    01161         }
    01162         return rt_receivex(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    01163 }
    01164
    01165 static inline RT_TASK *RT_receivex_if(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len)
    01166 {
    01167         if (!task || !node) {
    01168                 return rt_receivex_if(task, msg, size, len);
    01169         }
    01170         return rt_receivex_if(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len) ? task : 0;
    01171 }
    01172
    01173 static inline RT_TASK *RT_receivex_until(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len, RTIME time)
    01174 {
    01175         if (!task || !node) {
    01176                 return rt_receivex_until(task, msg, size, len, nano2count(time));
    01177         }
    01178         return rt_receivex_until(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len, nano2count(time)) ? task : 0;
    01179 }
    01180
    01181 static inline RT_TASK *RT_receivex_timed(unsigned long node, int port, RT_TASK *task, void *msg, int size, int *len, RTIME delay)
    01182 {
    01183         if (!task || !node) {
    01184                 return rt_receivex_timed(task, msg, size, len, nano2count(delay));
    01185         }
    01186         return rt_receivex_timed(rt_find_asgn_stub(OWNER(node, task), 1), msg, size, len, nano2count(delay)) ? task : 0;
    01187 }
    01188
    01189 #endif /* CONFIG_RTAI_MSG */
    01190
    01191 #if CONFIG_RTAI_MBX
    01192
    01193 static inline MBX *RT_typed_named_mbx_init(unsigned long node, int port, const char *mbx_name, int size, int qtype)
    01194 {
    01195         if (node) {
    01196                 struct { unsigned long mbx_name; int size; int qype; int namelen; } arg = { nam2num(mbx_name), size, qtype, strlen(mbx_name) };
    01197                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, NAMED_MBX_INIT, 0), 0LL, &arg, SIZARG, 0 };
    01198                 return (MBX *)rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).v[LOW];
    01199         }
    01200         return (MBX *)rt_typed_named_mbx_init(mbx_name, size, qtype);
    01201 }
    01202
    01203 static inline int RT_named_mbx_delete(unsigned long node, int port, MBX *mbx)
    01204 {
    01205         if (node) {
    01206                 struct { MBX *mbx; } arg = { mbx };
    01207                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, NAMED_MBX_DELETE, 0), 0LL, &arg, SIZARG, 0 };
    01208                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01209         }
    01210         return rt_named_mbx_delete(mbx);
    01211 }
    01212
    01213 static inline int RT_mbx_send(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01214 {
    01215         if (node) {
    01216                 struct { MBX *mbx; void *msg; int msg_size; int space; } arg = { mbx, msg, msg_size, 1 };
    01217                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_SEND, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01218                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01219         }
    01220         return rt_mbx_send(mbx, msg, msg_size);
    01221 }
    01222
    01223 static inline int RT_mbx_send_wp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01224 {
    01225         if (node) {
    01226                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01227                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_SEND_WP, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01228                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01229         }
    01230         return rt_mbx_send_wp(mbx, msg, msg_size);
    01231 }
    01232
    01233 static inline int RT_mbx_send_if(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01234 {
    01235         if (node) {
    01236                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01237                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_SEND_IF, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01238                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01239         }
    01240         return rt_mbx_send_if(mbx, msg, msg_size);
    01241 }
    01242
    01243 static inline int RT_mbx_ovrwr_send(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01244 {
    01245         if (node) {
    01246                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01247                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_OVRWR_SEND, 0), UR1(2, 3), &arg, SIZARG, 0 };
    01248                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01249         }
    01250         return rt_mbx_ovrwr_send(mbx, msg, msg_size);
    01251 }
    01252
    01253 static inline int RT_mbx_send_until(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME time)
    01254 {
    01255         if (node) {
    01256                 struct { MBX *mbx; void *msg; int msg_size; RTIME time; } arg = { mbx, msg, msg_size, time };
    01257                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_SEND_UNTIL, 4), UR1(2, 3), &arg, SIZARG, 0 };
    01258                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01259         }
    01260         return rt_mbx_send_until(mbx, msg, msg_size, nano2count(time));
    01261 }
    01262
    01263 static inline int RT_mbx_send_timed(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME delay)
    01264 {
    01265         if (node) {
    01266                 struct { MBX *mbx; void *msg; int msg_size; RTIME delay; } arg = { mbx, msg, msg_size, delay };
    01267                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_SEND_TIMED, 4), UR1(2, 3), &arg, SIZARG, 0 };
    01268                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01269         }
    01270         return rt_mbx_send_until(mbx, msg, msg_size, nano2count(delay));
    01271 }
    01272
    01273 static inline int RT_mbx_evdrp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01274 {
    01275         if (node) {
    01276                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01277                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_EVDRP, 0), UW1(2, 3), &arg, SIZARG, 0 };
    01278                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01279         }
    01280         return rt_mbx_evdrp(mbx, msg, msg_size);
    01281 }
    01282
    01283 static inline int RT_mbx_receive(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01284 {
    01285         if (node) {
    01286                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01287                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE, 0), UW1(2, 3), &arg, SIZARG, 0 };
    01288                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01289         }
    01290         return rt_mbx_receive(mbx, msg, msg_size);
    01291 }
    01292
    01293 static inline int RT_mbx_receive_wp(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01294 {
    01295         if (node) {
    01296                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01297                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_WP, 0), UW1(2, 3), &arg, SIZARG, 0 };
    01298                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01299         }
    01300         return rt_mbx_receive_wp(mbx, msg, msg_size);
    01301 }
    01302
    01303 static inline int RT_mbx_receive_if(unsigned long node, int port, MBX *mbx, void *msg, int msg_size)
    01304 {
    01305         if (node) {
    01306                 struct { MBX *mbx; void *msg; int msg_size; } arg = { mbx, msg, msg_size };
    01307                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_IF, 0), UW1(2, 3), &arg, SIZARG, 0 };
    01308                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01309         }
    01310         return rt_mbx_receive_if(mbx, msg, msg_size);
    01311 }
    01312
    01313 static inline int RT_mbx_receive_until(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME time)
    01314 {
    01315         if (node) {
    01316                 struct { MBX *mbx; void *msg; int msg_size; RTIME time; } arg = { mbx, msg, msg_size, time };
    01317                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_UNTIL, 4), UW1(2, 3), &arg, SIZARG, 0 };
    01318                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01319         }
    01320         return rt_mbx_receive_until(mbx, msg, msg_size, nano2count(time));
    01321 }
    01322
    01323 static inline int RT_mbx_receive_timed(unsigned long node, int port, MBX *mbx, void *msg, int msg_size, RTIME delay)
    01324 {
    01325         if (node) {
    01326                 struct { MBX *mbx; void *msg; int msg_size; RTIME delay; } arg = { mbx, msg, msg_size, delay };
    01327                 struct { unsigned long fun; long long type; void *args; int argsize; int space; } args = { PACKPORT(port, NET_RPC_EXT, MBX_RECEIVE_TIMED, 4), UW1(2, 3), &arg, SIZARG, 0 };
    01328                 return rtai_lxrt(NET_RPC_IDX, SIZARGS, NETRPC, &args).i[LOW];
    01329         }
    01330         return rt_mbx_receive_timed(mbx, msg, msg_size, nano2count(delay));
    01331 }
    01332
    01333 static inline int rt_get_net_rpc_ret(MBX *mbx, unsigned long long *retval, void *msg1, int *msglen1, void *msg2, int *msglen2, RTIME timeout, int type)
    01334 {
    01335         struct { int wsize, w2size; unsigned long long retval; } reply;
    01336         int ret;
    01337
    01338         switch (type) {
    01339                 case MBX_RECEIVE:
    01340                         ret = rt_mbx_receive(mbx, &reply, sizeof(reply));
    01341                         break;
    01342                 case MBX_RECEIVE_WP:
    01343                         ret = rt_mbx_receive_wp(mbx, &reply, sizeof(reply));
    01344                         break;
    01345                 case MBX_RECEIVE_IF:
    01346                         ret = rt_mbx_receive_if(mbx, &reply, sizeof(reply));
    01347                         break;
    01348                 case MBX_RECEIVE_UNTIL:
    01349                         ret = rt_mbx_receive_until(mbx, &reply, sizeof(reply), timeout);
    01350                         break;
    01351                 case MBX_RECEIVE_TIMED:
    01352                         ret = rt_mbx_receive_timed(mbx, &reply, sizeof(reply), timeout);
    01353                 default:
    01354                         ret = -1;
    01355         }
    01356         if (!ret) {
    01357                 *retval = reply.retval;
    01358                 if (reply.wsize) {
    01359                         if (*msglen1 > reply.wsize) {
    01360                                 *msglen1 = reply.wsize;
    01361                         }
    01362                         rt_mbx_receive(mbx, msg1, *msglen1);
    01363                 } else {
    01364                         *msglen1 = 0;
    01365                 }
    01366                 if (reply.w2size) {
    01367                         if (*msglen2 > reply.w2size) {
    01368                                 *msglen2 = reply.w2size;
    01369                         }
    01370                         rt_mbx_receive(mbx, msg2, *msglen2);
    01371                 } else {
    01372                         *msglen2 = 0;
    01373                 }
    01374                 return 0;
    01375         }
    01376         return ret;
    01377 }
    01378
    01379 #endif /* CONFIG_RTAI_MBX */
    01380
    01381 #endif /* __KERNEL__ */
    01382
    01383 /*
    01384  * A set of compatibility defines for APIs that can be interpreted in various
    01385  * ways but do the same the same things always.
    01386  */
    01387
    01388 #define RT_isrpcx(task)  RT_isrpc(task)
    01389
    01390 #define RT_waiting_return            rt_waiting_return
    01391
    01392 #define RT_sync_net_rpc              rt_sync_net_rpc
    01393
    01394 #define RT_request_port              rt_request_port
    01395
    01396 #define RT_request_port_id           rt_request_port_id
    01397
    01398 #define RT_request_port_mbx          rt_request_port_mbx
    01399
    01400 #define RT_request_port_id_mbx       rt_request_port_id_mbx
    01401
    01402 #define RT_request_soft_port         rt_request_soft_port
    01403
    01404 #define RT_request_soft_port_id      rt_request_soft_port_id
    01405
    01406 #define RT_request_soft_port_mbx     rt_request_soft_port_mbx
    01407
    01408 #define RT_request_soft_port_id_mbx  rt_request_soft_port_id_mbx
    01409
    01410 #define RT_request_hard_port         rt_request_hard_port
    01411
    01412 #define RT_request_hard_port_id      rt_request_hard_port_id
    01413
    01414 #define RT_request_hard_port_mbx     rt_request_hard_port_mbx
    01415
    01416 #define RT_request_hard_port_id_mbx  rt_request_hard_port_id_mbx
    01417
    01418 #define RT_release_port              rt_release_port
    01419
    01420 #define rt_request_port              rt_request_soft_port
    01421
    01422 #define rt_request_port_id           rt_request_soft_port_id
    01423
    01424 #define rt_request_port_mbx          rt_request_soft_port_mbx
    01425
    01426 #define rt_request_port_id_mbx       rt_request_soft_port_id_mbx
    01427
    01428 /*
    01429  * End of compatibility defines.
    01430  */
    01431
    01432 #define rt_request_soft_port(node) \
    01433         rt_send_req_rel_port(node, 0, 0, 0, 0)
    01434
    01435 #define rt_request_soft_port_id(node, id) \
    01436         rt_send_req_rel_port(node, 0, id, 0, 0)
    01437
    01438 #define rt_request_soft_port_mbx(node, mbx) \
    01439         rt_send_req_rel_port(node, 0, 0, mbx, 0)
    01440
    01441 #define rt_request_soft_port_id_mbx(node, id, mbx) \
    01442         rt_send_req_rel_port(node, 0, id, mbx, 0)
    01443
    01444 #define rt_request_hard_port(node) \
    01445         rt_send_req_rel_port(node, 0, 0, 0, 1)
    01446
    01447 #define rt_request_hard_port_id(node, id) \
    01448         rt_send_req_rel_port(node, 0, id, 0, 1)
    01449
    01450 #define rt_request_hard_port_mbx(node, mbx) \
    01451         rt_send_req_rel_port(node, 0, 0, mbx, 1)
    01452
    01453 #define rt_request_hard_port_id_mbx(node, id, mbx) \
    01454         rt_send_req_rel_port(node, 0, id, mbx, 1)
    01455
    01456 #define rt_release_port(node, port) \
    01457         rt_send_req_rel_port(node, port, 0, 0, 0)
    01458
    01459 #endif /* CONFIG_RTAI_INTERNAL_LXRT_SUPPORT */
    01460
    01461 #endif /* !_RTAI_NETRPC_H */