[b419162] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2006 Ondrej Palkovsky
|
---|
[b419162] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
[b2951e2] | 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libc
|
---|
| 30 | * @{
|
---|
| 31 | * @}
|
---|
| 32 | */
|
---|
| 33 |
|
---|
[fadd381] | 34 | /** @addtogroup libcipc IPC
|
---|
[b2951e2] | 35 | * @brief HelenOS uspace IPC
|
---|
| 36 | * @{
|
---|
| 37 | * @ingroup libc
|
---|
| 38 | */
|
---|
| 39 | /** @file
|
---|
[b419162] | 40 | */
|
---|
| 41 |
|
---|
[7ee6aff] | 42 | #include <ipc/ipc.h>
|
---|
[b419162] | 43 | #include <libc.h>
|
---|
[936351c1] | 44 | #include <malloc.h>
|
---|
| 45 | #include <errno.h>
|
---|
[7ee6aff] | 46 | #include <libadt/list.h>
|
---|
[936351c1] | 47 | #include <stdio.h>
|
---|
| 48 | #include <unistd.h>
|
---|
[35509652] | 49 | #include <futex.h>
|
---|
[04a73cdf] | 50 | #include <kernel/synch/synch.h>
|
---|
[fc42b28] | 51 | #include <async.h>
|
---|
| 52 | #include <psthread.h>
|
---|
[b419162] | 53 |
|
---|
[936351c1] | 54 | /** Structure used for keeping track of sent async msgs
|
---|
| 55 | * and queing unsent msgs
|
---|
| 56 | *
|
---|
| 57 | */
|
---|
| 58 | typedef struct {
|
---|
| 59 | link_t list;
|
---|
| 60 |
|
---|
| 61 | ipc_async_callback_t callback;
|
---|
| 62 | void *private;
|
---|
| 63 | union {
|
---|
| 64 | ipc_callid_t callid;
|
---|
| 65 | struct {
|
---|
[4c61e60] | 66 | ipc_call_t data;
|
---|
[936351c1] | 67 | int phoneid;
|
---|
| 68 | } msg;
|
---|
| 69 | }u;
|
---|
[fc42b28] | 70 | pstid_t ptid; /**< Thread waiting for sending this msg */
|
---|
[936351c1] | 71 | } async_call_t;
|
---|
| 72 |
|
---|
| 73 | LIST_INITIALIZE(dispatched_calls);
|
---|
[fc42b28] | 74 |
|
---|
| 75 | /* queued_calls is protcted by async_futex, because if the
|
---|
| 76 | * call cannot be sent into kernel, async framework is used
|
---|
| 77 | * automatically
|
---|
| 78 | */
|
---|
| 79 | LIST_INITIALIZE(queued_calls); /**< List of async calls that were not accepted
|
---|
| 80 | * by kernel */
|
---|
[936351c1] | 81 |
|
---|
[80649a91] | 82 | static atomic_t ipc_futex = FUTEX_INITIALIZER;
|
---|
[35509652] | 83 |
|
---|
[936351c1] | 84 | int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
|
---|
| 85 | ipcarg_t *result)
|
---|
[b419162] | 86 | {
|
---|
[4c61e60] | 87 | ipc_call_t resdata;
|
---|
[06502f7d] | 88 | int callres;
|
---|
| 89 |
|
---|
[936351c1] | 90 | callres = __SYSCALL4(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
|
---|
[06502f7d] | 91 | (sysarg_t)&resdata);
|
---|
| 92 | if (callres)
|
---|
| 93 | return callres;
|
---|
| 94 | if (result)
|
---|
| 95 | *result = IPC_GET_ARG1(resdata);
|
---|
| 96 | return IPC_GET_RETVAL(resdata);
|
---|
[b419162] | 97 | }
|
---|
| 98 |
|
---|
[936351c1] | 99 | int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
|
---|
| 100 | ipcarg_t arg2, ipcarg_t arg3,
|
---|
| 101 | ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3)
|
---|
[06502f7d] | 102 | {
|
---|
[4c61e60] | 103 | ipc_call_t data;
|
---|
[06502f7d] | 104 | int callres;
|
---|
| 105 |
|
---|
| 106 | IPC_SET_METHOD(data, method);
|
---|
| 107 | IPC_SET_ARG1(data, arg1);
|
---|
| 108 | IPC_SET_ARG2(data, arg2);
|
---|
| 109 | IPC_SET_ARG3(data, arg3);
|
---|
| 110 |
|
---|
[d73942c] | 111 | callres = __SYSCALL3(SYS_IPC_CALL_SYNC, phoneid, (sysarg_t)&data,
|
---|
| 112 | (sysarg_t)&data);
|
---|
[06502f7d] | 113 | if (callres)
|
---|
| 114 | return callres;
|
---|
| 115 |
|
---|
| 116 | if (result1)
|
---|
| 117 | *result1 = IPC_GET_ARG1(data);
|
---|
| 118 | if (result2)
|
---|
| 119 | *result2 = IPC_GET_ARG2(data);
|
---|
| 120 | if (result3)
|
---|
| 121 | *result3 = IPC_GET_ARG3(data);
|
---|
| 122 | return IPC_GET_RETVAL(data);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
[936351c1] | 125 | /** Syscall to send asynchronous message */
|
---|
[4c61e60] | 126 | static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
|
---|
[936351c1] | 127 | {
|
---|
| 128 | return __SYSCALL2(SYS_IPC_CALL_ASYNC, phoneid, (sysarg_t)data);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[c1d2c9d] | 131 | /** Prolog to ipc_async_send functions */
|
---|
| 132 | static inline async_call_t *ipc_prepare_async(void *private, ipc_async_callback_t callback)
|
---|
[b419162] | 133 | {
|
---|
[936351c1] | 134 | async_call_t *call;
|
---|
[06502f7d] | 135 |
|
---|
[936351c1] | 136 | call = malloc(sizeof(*call));
|
---|
| 137 | if (!call) {
|
---|
[a784a96] | 138 | if (callback)
|
---|
| 139 | callback(private, ENOMEM, NULL);
|
---|
[c1d2c9d] | 140 | return NULL;
|
---|
[936351c1] | 141 | }
|
---|
[fc42b28] | 142 | call->callback = callback;
|
---|
| 143 | call->private = private;
|
---|
| 144 |
|
---|
[c1d2c9d] | 145 | return call;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | /** Epilogue of ipc_async_send functions */
|
---|
[b1f51f0] | 149 | static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
|
---|
| 150 | async_call_t *call, int can_preempt)
|
---|
[c1d2c9d] | 151 | {
|
---|
[d8b42fb2] | 152 | if (!call) { /* Nothing to do regardless if failed or not */
|
---|
| 153 | futex_up(&ipc_futex);
|
---|
| 154 | return;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[06502f7d] | 157 | if (callid == IPC_CALLRET_FATAL) {
|
---|
[fc42b28] | 158 | futex_up(&ipc_futex);
|
---|
[06502f7d] | 159 | /* Call asynchronous handler with error code */
|
---|
[c1d2c9d] | 160 | if (call->callback)
|
---|
| 161 | call->callback(call->private, ENOENT, NULL);
|
---|
[936351c1] | 162 | free(call);
|
---|
[06502f7d] | 163 | return;
|
---|
| 164 | }
|
---|
[936351c1] | 165 |
|
---|
[06502f7d] | 166 | if (callid == IPC_CALLRET_TEMPORARY) {
|
---|
[fc42b28] | 167 | futex_up(&ipc_futex);
|
---|
| 168 |
|
---|
[936351c1] | 169 | call->u.msg.phoneid = phoneid;
|
---|
[b1f51f0] | 170 |
|
---|
[fc42b28] | 171 | futex_down(&async_futex);
|
---|
[936351c1] | 172 | list_append(&call->list, &queued_calls);
|
---|
[fc42b28] | 173 |
|
---|
[b1f51f0] | 174 | if (can_preempt) {
|
---|
| 175 | call->ptid = psthread_get_id();
|
---|
| 176 | psthread_schedule_next_adv(PS_TO_MANAGER);
|
---|
| 177 | /* Async futex unlocked by previous call */
|
---|
| 178 | } else {
|
---|
| 179 | call->ptid = 0;
|
---|
| 180 | futex_up(&async_futex);
|
---|
| 181 | }
|
---|
[06502f7d] | 182 | return;
|
---|
| 183 | }
|
---|
[936351c1] | 184 | call->u.callid = callid;
|
---|
| 185 | /* Add call to list of dispatched calls */
|
---|
| 186 | list_append(&call->list, &dispatched_calls);
|
---|
[35509652] | 187 | futex_up(&ipc_futex);
|
---|
[c1d2c9d] | 188 |
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | /** Send asynchronous message
|
---|
| 192 | *
|
---|
| 193 | * - if fatal error, call callback handler with proper error code
|
---|
| 194 | * - if message cannot be temporarily sent, add to queue
|
---|
| 195 | */
|
---|
| 196 | void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
|
---|
| 197 | ipcarg_t arg2, void *private,
|
---|
[b1f51f0] | 198 | ipc_async_callback_t callback, int can_preempt)
|
---|
[c1d2c9d] | 199 | {
|
---|
[d8b42fb2] | 200 | async_call_t *call = NULL;
|
---|
[c1d2c9d] | 201 | ipc_callid_t callid;
|
---|
| 202 |
|
---|
[d8b42fb2] | 203 | if (callback) {
|
---|
| 204 | call = ipc_prepare_async(private, callback);
|
---|
| 205 | if (!call)
|
---|
| 206 | return;
|
---|
| 207 | }
|
---|
[c1d2c9d] | 208 |
|
---|
| 209 | /* We need to make sure that we get callid before
|
---|
| 210 | * another thread accesses the queue again */
|
---|
| 211 | futex_down(&ipc_futex);
|
---|
| 212 | callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
|
---|
| 213 |
|
---|
| 214 | if (callid == IPC_CALLRET_TEMPORARY) {
|
---|
[d8b42fb2] | 215 | if (!call) {
|
---|
| 216 | call = ipc_prepare_async(private, callback);
|
---|
| 217 | if (!call)
|
---|
| 218 | return;
|
---|
| 219 | }
|
---|
[c1d2c9d] | 220 | IPC_SET_METHOD(call->u.msg.data, method);
|
---|
| 221 | IPC_SET_ARG1(call->u.msg.data, arg1);
|
---|
| 222 | IPC_SET_ARG2(call->u.msg.data, arg2);
|
---|
| 223 | }
|
---|
[b1f51f0] | 224 | ipc_finish_async(callid, phoneid, call, can_preempt);
|
---|
[c1d2c9d] | 225 | }
|
---|
| 226 |
|
---|
| 227 | /** Send asynchronous message
|
---|
| 228 | *
|
---|
| 229 | * - if fatal error, call callback handler with proper error code
|
---|
| 230 | * - if message cannot be temporarily sent, add to queue
|
---|
| 231 | */
|
---|
| 232 | void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
|
---|
| 233 | ipcarg_t arg2, ipcarg_t arg3, void *private,
|
---|
[b1f51f0] | 234 | ipc_async_callback_t callback, int can_preempt)
|
---|
[c1d2c9d] | 235 | {
|
---|
| 236 | async_call_t *call;
|
---|
| 237 | ipc_callid_t callid;
|
---|
| 238 |
|
---|
| 239 | call = ipc_prepare_async(private, callback);
|
---|
| 240 | if (!call)
|
---|
| 241 | return;
|
---|
| 242 |
|
---|
| 243 | IPC_SET_METHOD(call->u.msg.data, method);
|
---|
| 244 | IPC_SET_ARG1(call->u.msg.data, arg1);
|
---|
| 245 | IPC_SET_ARG2(call->u.msg.data, arg2);
|
---|
| 246 | IPC_SET_ARG3(call->u.msg.data, arg3);
|
---|
| 247 | /* We need to make sure that we get callid before
|
---|
| 248 | * another thread accesses the queue again */
|
---|
| 249 | futex_down(&ipc_futex);
|
---|
| 250 | callid = _ipc_call_async(phoneid, &call->u.msg.data);
|
---|
| 251 |
|
---|
[b1f51f0] | 252 | ipc_finish_async(callid, phoneid, call, can_preempt);
|
---|
[b419162] | 253 | }
|
---|
| 254 |
|
---|
[06502f7d] | 255 |
|
---|
[250717cc] | 256 | /** Send a fast answer to a received call.
|
---|
| 257 | *
|
---|
| 258 | * The fast answer makes use of passing retval and first two arguments in registers.
|
---|
| 259 | * If you need to return more, use the ipc_answer() instead.
|
---|
| 260 | *
|
---|
| 261 | * @param callid ID of the call being answered.
|
---|
| 262 | * @param retval Return value.
|
---|
| 263 | * @param arg1 First return argument.
|
---|
| 264 | * @param arg2 Second return argument.
|
---|
| 265 | *
|
---|
| 266 | * @return Zero on success or a value from @ref errno.h on failure.
|
---|
| 267 | */
|
---|
| 268 | ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
|
---|
[936351c1] | 269 | ipcarg_t arg2)
|
---|
[b419162] | 270 | {
|
---|
[8a568e3] | 271 | return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2);
|
---|
[b419162] | 272 | }
|
---|
[06502f7d] | 273 |
|
---|
[250717cc] | 274 | /** Send a full answer to a received call.
|
---|
| 275 | *
|
---|
| 276 | * @param callid ID of the call being answered.
|
---|
| 277 | * @param call Call data. Must be already initialized by the responder.
|
---|
| 278 | *
|
---|
| 279 | * @return Zero on success or a value from @ref errno.h on failure.
|
---|
| 280 | */
|
---|
| 281 | ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call)
|
---|
| 282 | {
|
---|
| 283 | return __SYSCALL2(SYS_IPC_ANSWER, callid, (sysarg_t) call);
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 |
|
---|
[936351c1] | 287 | /** Try to dispatch queed calls from async queue */
|
---|
| 288 | static void try_dispatch_queued_calls(void)
|
---|
| 289 | {
|
---|
| 290 | async_call_t *call;
|
---|
| 291 | ipc_callid_t callid;
|
---|
| 292 |
|
---|
[fc42b28] | 293 | /* TODO: integrate intelligently ipc_futex, so that it
|
---|
| 294 | * is locked during ipc_call_async, until it is added
|
---|
| 295 | * to dispatched_calls
|
---|
| 296 | */
|
---|
| 297 | futex_down(&async_futex);
|
---|
[936351c1] | 298 | while (!list_empty(&queued_calls)) {
|
---|
| 299 | call = list_get_instance(queued_calls.next, async_call_t,
|
---|
| 300 | list);
|
---|
| 301 |
|
---|
| 302 | callid = _ipc_call_async(call->u.msg.phoneid,
|
---|
| 303 | &call->u.msg.data);
|
---|
[fc42b28] | 304 | if (callid == IPC_CALLRET_TEMPORARY) {
|
---|
[936351c1] | 305 | break;
|
---|
[fc42b28] | 306 | }
|
---|
[936351c1] | 307 | list_remove(&call->list);
|
---|
[35509652] | 308 |
|
---|
[fc42b28] | 309 | futex_up(&async_futex);
|
---|
[b1f51f0] | 310 | if (call->ptid)
|
---|
| 311 | psthread_add_ready(call->ptid);
|
---|
[fc42b28] | 312 |
|
---|
[936351c1] | 313 | if (callid == IPC_CALLRET_FATAL) {
|
---|
[a784a96] | 314 | if (call->callback)
|
---|
| 315 | call->callback(call->private, ENOENT, NULL);
|
---|
[936351c1] | 316 | free(call);
|
---|
| 317 | } else {
|
---|
| 318 | call->u.callid = callid;
|
---|
[fc42b28] | 319 | futex_down(&ipc_futex);
|
---|
[936351c1] | 320 | list_append(&call->list, &dispatched_calls);
|
---|
[fc42b28] | 321 | futex_up(&ipc_futex);
|
---|
[936351c1] | 322 | }
|
---|
[fc42b28] | 323 | futex_down(&async_futex);
|
---|
[936351c1] | 324 | }
|
---|
[fc42b28] | 325 | futex_up(&async_futex);
|
---|
[936351c1] | 326 | }
|
---|
| 327 |
|
---|
| 328 | /** Handle received answer
|
---|
| 329 | *
|
---|
| 330 | * TODO: Make it use hash table
|
---|
| 331 | *
|
---|
| 332 | * @param callid Callid (with first bit set) of the answered call
|
---|
| 333 | */
|
---|
[4c61e60] | 334 | static void handle_answer(ipc_callid_t callid, ipc_call_t *data)
|
---|
[936351c1] | 335 | {
|
---|
| 336 | link_t *item;
|
---|
| 337 | async_call_t *call;
|
---|
| 338 |
|
---|
| 339 | callid &= ~IPC_CALLID_ANSWERED;
|
---|
| 340 |
|
---|
[35509652] | 341 | futex_down(&ipc_futex);
|
---|
[936351c1] | 342 | for (item = dispatched_calls.next; item != &dispatched_calls;
|
---|
| 343 | item = item->next) {
|
---|
| 344 | call = list_get_instance(item, async_call_t, list);
|
---|
| 345 | if (call->u.callid == callid) {
|
---|
| 346 | list_remove(&call->list);
|
---|
[35509652] | 347 | futex_up(&ipc_futex);
|
---|
[a784a96] | 348 | if (call->callback)
|
---|
| 349 | call->callback(call->private,
|
---|
| 350 | IPC_GET_RETVAL(*data),
|
---|
| 351 | data);
|
---|
| 352 | free(call);
|
---|
[936351c1] | 353 | return;
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
[35509652] | 356 | futex_up(&ipc_futex);
|
---|
[d8b42fb2] | 357 | /* We may get here after async_msg, which doesn't register any callback */
|
---|
[936351c1] | 358 | }
|
---|
| 359 |
|
---|
| 360 |
|
---|
[80649a91] | 361 | /** One cycle of ipc wait for call call
|
---|
[b419162] | 362 | *
|
---|
| 363 | * - dispatch ASYNC reoutines in the background
|
---|
[04a73cdf] | 364 | * @param call Space where the message is stored
|
---|
[80649a91] | 365 | * @param usec Timeout in microseconds
|
---|
| 366 | * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking)
|
---|
[04a73cdf] | 367 | * @return Callid of the answer.
|
---|
[b419162] | 368 | */
|
---|
[80649a91] | 369 | ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec, int flags)
|
---|
[b419162] | 370 | {
|
---|
| 371 | ipc_callid_t callid;
|
---|
| 372 |
|
---|
[80649a91] | 373 | callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
|
---|
| 374 | /* Handle received answers */
|
---|
[fc42b28] | 375 | if (callid & IPC_CALLID_ANSWERED) {
|
---|
[80649a91] | 376 | handle_answer(callid, call);
|
---|
[fc42b28] | 377 | try_dispatch_queued_calls();
|
---|
| 378 | }
|
---|
[04a73cdf] | 379 |
|
---|
| 380 | return callid;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | /** Wait some time for an IPC call.
|
---|
| 384 | *
|
---|
| 385 | * - dispatch ASYNC reoutines in the background
|
---|
[096ba7a] | 386 | *
|
---|
[04a73cdf] | 387 | * @param call Space where the message is stored
|
---|
| 388 | * @param usec Timeout in microseconds.
|
---|
| 389 | * @return Callid of the answer.
|
---|
| 390 | */
|
---|
| 391 | ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec)
|
---|
| 392 | {
|
---|
| 393 | ipc_callid_t callid;
|
---|
| 394 |
|
---|
| 395 | do {
|
---|
[2d22049] | 396 | callid = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE);
|
---|
[04a73cdf] | 397 | } while (callid & IPC_CALLID_ANSWERED);
|
---|
| 398 |
|
---|
| 399 | return callid;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | /** Check if there is an IPC call waiting to be picked up.
|
---|
| 403 | *
|
---|
| 404 | * - dispatch ASYNC reoutines in the background
|
---|
[096ba7a] | 405 | *
|
---|
[04a73cdf] | 406 | * @param call Space where the message is stored
|
---|
| 407 | * @return Callid of the answer.
|
---|
| 408 | */
|
---|
| 409 | ipc_callid_t ipc_trywait_for_call(ipc_call_t *call)
|
---|
| 410 | {
|
---|
| 411 | ipc_callid_t callid;
|
---|
| 412 |
|
---|
| 413 | do {
|
---|
[2d22049] | 414 | callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
|
---|
[06502f7d] | 415 | } while (callid & IPC_CALLID_ANSWERED);
|
---|
[936351c1] | 416 |
|
---|
[b419162] | 417 | return callid;
|
---|
| 418 | }
|
---|
[5106e98] | 419 |
|
---|
[4c61e60] | 420 | /** Ask destination to do a callback connection
|
---|
| 421 | *
|
---|
| 422 | * @return 0 - OK, error code
|
---|
| 423 | */
|
---|
| 424 | int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone)
|
---|
[5106e98] | 425 | {
|
---|
[4c61e60] | 426 | return ipc_call_sync_3(phoneid, IPC_M_CONNECT_TO_ME, arg1,
|
---|
| 427 | arg2, 0, 0, 0, phone);
|
---|
[5106e98] | 428 | }
|
---|
[11eae82] | 429 |
|
---|
[4c61e60] | 430 | /** Ask through phone for a new connection to some service
|
---|
| 431 | *
|
---|
| 432 | * @return new phoneid - OK, error code
|
---|
| 433 | */
|
---|
[11eae82] | 434 | int ipc_connect_me_to(int phoneid, int arg1, int arg2)
|
---|
| 435 | {
|
---|
[06b0d112] | 436 | ipcarg_t newphid;
|
---|
[4c61e60] | 437 | int res;
|
---|
| 438 |
|
---|
| 439 | res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1,
|
---|
| 440 | arg2, 0, 0, 0, &newphid);
|
---|
| 441 | if (res)
|
---|
| 442 | return res;
|
---|
| 443 | return newphid;
|
---|
[11eae82] | 444 | }
|
---|
| 445 |
|
---|
[7048773] | 446 | /* Hang up specified phone */
|
---|
| 447 | int ipc_hangup(int phoneid)
|
---|
| 448 | {
|
---|
| 449 | return __SYSCALL1(SYS_IPC_HANGUP, phoneid);
|
---|
| 450 | }
|
---|
[6180b57] | 451 |
|
---|
[2b017ba] | 452 | /** Register IRQ notification.
|
---|
| 453 | *
|
---|
| 454 | * @param inr IRQ number.
|
---|
| 455 | * @param devno Device number of the device generating inr.
|
---|
| 456 | * @param method Use this method for notifying me.
|
---|
| 457 | * @param ucode Top-half pseudocode handler.
|
---|
| 458 | *
|
---|
| 459 | * @return Value returned by the kernel.
|
---|
| 460 | */
|
---|
| 461 | int ipc_register_irq(int inr, int devno, int method, irq_code_t *ucode)
|
---|
[6180b57] | 462 | {
|
---|
[2b017ba] | 463 | return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method, (sysarg_t) ucode);
|
---|
[6180b57] | 464 | }
|
---|
| 465 |
|
---|
[2b017ba] | 466 | /** Unregister IRQ notification.
|
---|
| 467 | *
|
---|
| 468 | * @param inr IRQ number.
|
---|
| 469 | * @param devno Device number of the device generating inr.
|
---|
| 470 | *
|
---|
| 471 | * @return Value returned by the kernel.
|
---|
| 472 | */
|
---|
| 473 | int ipc_unregister_irq(int inr, int devno)
|
---|
[6180b57] | 474 | {
|
---|
[2b017ba] | 475 | return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno);
|
---|
[6180b57] | 476 | }
|
---|
[8a568e3] | 477 |
|
---|
[043dcc27] | 478 | int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method, ipcarg_t arg1)
|
---|
| 479 | {
|
---|
| 480 | return __SYSCALL4(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1);
|
---|
| 481 | }
|
---|
| 482 |
|
---|
[fadd381] | 483 | /** @}
|
---|
[b2951e2] | 484 | */
|
---|