ipc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2006 Ondrej Palkovsky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
00036         #error Do not intermix low-level IPC interface and async framework
00037 #endif
00038 
00039 #ifndef LIBC_IPC_H_
00040 #define LIBC_IPC_H_
00041 
00042 #include <sys/types.h>
00043 #include <ipc/common.h>
00044 #include <kernel/synch/synch.h>
00045 #include <task.h>
00046 
00047 typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
00048 
00049 /*
00050  * User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
00051  * They are in the form ipc_call_sync_m_n(), where m denotes the number of
00052  * arguments of payload and n denotes number of return values. Whenever
00053  * possible, the fast version is used.
00054  */
00055 
00056 #define ipc_call_sync_0_0(phoneid, method) \
00057         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
00058 #define ipc_call_sync_0_1(phoneid, method, res1) \
00059         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
00060 #define ipc_call_sync_0_2(phoneid, method, res1, res2) \
00061         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
00062 #define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
00063         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
00064             0, 0)
00065 #define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
00066         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
00067             (res4), 0)
00068 #define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
00069         ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
00070             (res4), (res5))
00071 
00072 #define ipc_call_sync_1_0(phoneid, method, arg1) \
00073         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
00074 #define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
00075         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
00076 #define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
00077         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
00078             0, 0)
00079 #define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
00080         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
00081             (res3), 0, 0)
00082 #define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
00083         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
00084             (res3), (res4), 0)
00085 #define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
00086     res5) \
00087         ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
00088             (res3), (res4), (res5))
00089 
00090 #define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
00091         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
00092             0, 0)
00093 #define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
00094         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
00095             0, 0)
00096 #define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
00097         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
00098             (res2), 0, 0, 0)
00099 #define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
00100         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
00101             (res2), (res3), 0, 0)
00102 #define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
00103     res4) \
00104         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
00105             (res2), (res3), (res4), 0)
00106 #define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
00107     res4, res5)\
00108         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
00109             (res2), (res3), (res4), (res5))
00110 
00111 #define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
00112         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
00113             0, 0)
00114 #define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
00115         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
00116             0, 0, 0, 0)
00117 #define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
00118         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
00119             (res2), 0, 0, 0)
00120 #define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
00121     res3) \
00122         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00123             (res1), (res2), (res3), 0, 0)
00124 #define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
00125     res3, res4) \
00126         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00127             (res1), (res2), (res3), (res4), 0)
00128 #define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
00129     res3, res4, res5) \
00130         ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00131             (res1), (res2), (res3), (res4), (res5))
00132 
00133 #define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
00134         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
00135             0, 0, 0, 0, 0)
00136 #define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
00137         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
00138             (res1), 0, 0, 0, 0)
00139 #define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
00140         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
00141             (res1), (res2), 0, 0, 0)
00142 #define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
00143     res3) \
00144         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00145             (arg4), 0, (res1), (res2), (res3), 0, 0)
00146 #define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
00147     res3, res4) \
00148         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00149             (arg4), 0, (res1), (res2), (res3), (res4), 0)
00150 #define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
00151     res3, res4, res5) \
00152         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00153             (arg4), 0, (res1), (res2), (res3), (res4), (res5))
00154 
00155 #define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
00156         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00157             (arg5), 0, 0, 0, 0, 0)
00158 #define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
00159         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00160             (arg5), (res1), 0, 0, 0, 0)
00161 #define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
00162     res2) \
00163         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00164             (arg4), (arg5), (res1), (res2), 0, 0, 0)
00165 #define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
00166     res2, res3) \
00167         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00168             (arg4), (arg5), (res1), (res2), (res3), 0, 0)
00169 #define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
00170     res2, res3, res4) \
00171         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00172             (arg4), (arg5), (res1), (res2), (res3), (res4), 0)
00173 #define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
00174     res2, res3, res4, res5) \
00175         ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00176             (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
00177 
00178 extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00179     sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
00180 
00181 extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00182     sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
00183     sysarg_t *);
00184 
00185 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
00186 extern void ipc_poke(void);
00187 
00188 #define ipc_wait_for_call(data) \
00189         ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
00190 
00191 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
00192 extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
00193 
00194 /*
00195  * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
00196  * They are in the form of ipc_answer_m(), where m is the number of return
00197  * arguments. The macros decide between the fast and the slow version according
00198  * to m.
00199  */
00200 
00201 #define ipc_answer_0(callid, retval) \
00202         ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
00203 #define ipc_answer_1(callid, retval, arg1) \
00204         ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
00205 #define ipc_answer_2(callid, retval, arg1, arg2) \
00206         ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
00207 #define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
00208         ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
00209 #define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
00210         ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
00211 #define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
00212         ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
00213 
00214 extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
00215     sysarg_t, sysarg_t);
00216 extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
00217     sysarg_t, sysarg_t, sysarg_t);
00218 
00219 /*
00220  * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
00221  * They are in the form of ipc_call_async_m(), where m is the number of payload
00222  * arguments. The macros decide between the fast and the slow version according
00223  * to m.
00224  */
00225 
00226 #define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
00227         ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
00228             (callback), (can_preempt))
00229 #define ipc_call_async_1(phoneid, method, arg1, private, callback, \
00230     can_preempt) \
00231         ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, 0, (private), \
00232             (callback), (can_preempt))
00233 #define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback, \
00234     can_preempt) \
00235         ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
00236             (private), (callback), (can_preempt))
00237 #define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback, \
00238     can_preempt) \
00239         ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
00240             (private), (callback), (can_preempt))
00241 #define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
00242     callback, can_preempt) \
00243         ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00244             (arg4), (private), (callback), (can_preempt))
00245 #define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
00246     private, callback, can_preempt) \
00247         ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
00248             (arg4), (arg5), (private), (callback), (can_preempt))
00249 
00250 extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00251     sysarg_t, void *, ipc_async_callback_t, bool);
00252 extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00253     sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
00254 
00255 extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t *,
00256     sysarg_t *);
00257 extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
00258 extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
00259 
00260 extern int ipc_hangup(int);
00261 
00262 extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
00263     unsigned int);
00264 extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
00265     sysarg_t, sysarg_t, sysarg_t, unsigned int);
00266 
00267 /*
00268  * User-friendly wrappers for ipc_share_in_start().
00269  */
00270 
00271 #define ipc_share_in_start_0_0(phoneid, dst, size) \
00272         ipc_share_in_start((phoneid), (dst), (size), 0, NULL)
00273 #define ipc_share_in_start_0_1(phoneid, dst, size, flags) \
00274         ipc_share_in_start((phoneid), (dst), (size), 0, (flags))
00275 #define ipc_share_in_start_1_0(phoneid, dst, size, arg) \
00276         ipc_share_in_start((phoneid), (dst), (size), (arg), NULL)
00277 #define ipc_share_in_start_1_1(phoneid, dst, size, arg, flags) \
00278         ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
00279 
00280 extern int ipc_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
00281 extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int);
00282 extern int ipc_share_out_start(int, void *, unsigned int);
00283 extern int ipc_share_out_finalize(ipc_callid_t, void *);
00284 extern int ipc_data_read_start(int, void *, size_t);
00285 extern int ipc_data_read_finalize(ipc_callid_t, const void *, size_t);
00286 extern int ipc_data_write_start(int, const void *, size_t);
00287 extern int ipc_data_write_finalize(ipc_callid_t, void *, size_t);
00288 
00289 extern int ipc_connect_kbox(task_id_t);
00290 
00291 #endif
00292 

Generated on Thu Jun 2 07:45:47 2011 for HelenOS/USB by  doxygen 1.4.7