source: mainline/kernel/generic/src/ipc/sysipc.c@ cb4afd8b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since cb4afd8b was 51ec40f, checked in by Jakub Jermar <jakub@…>, 19 years ago

Improve comments for the IPC subsystem.
Fix formatting and indentation.

  • Property mode set to 100644
File size: 15.1 KB
RevLine 
[2d5a54f3]1/*
[df4ed85]2 * Copyright (c) 2006 Ondrej Palkovsky
[2d5a54f3]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.
27 */
28
[cc73a8a1]29/** @addtogroup genericipc
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[2d5a54f3]35#include <arch.h>
36#include <proc/task.h>
[e3c762cd]37#include <proc/thread.h>
[2d5a54f3]38#include <errno.h>
39#include <memstr.h>
40#include <debug.h>
41#include <ipc/ipc.h>
42#include <ipc/sysipc.h>
[162f919]43#include <ipc/irq.h>
[4e49572]44#include <ipc/ipcrsc.h>
[5626277]45#include <arch/interrupt.h>
[2d5a54f3]46#include <print.h>
[e3c762cd]47#include <syscall/copy.h>
[2bb8648]48#include <security/cap.h>
[7c23af9]49#include <mm/as.h>
[253f35a1]50#include <print.h>
[2d5a54f3]51
[51ec40f]52#define GET_CHECK_PHONE(phone, phoneid, err) { \
[ba81cab]53 if (phoneid > IPC_MAX_PHONES) { err; } \
54 phone = &TASK->phones[phoneid]; \
55}
56
[51ec40f]57#define STRUCT_TO_USPACE(dst, src) copy_to_uspace(dst, src, sizeof(*(src)))
[ba81cab]58
[2ba7810]59/** Return true if the method is a system method */
[7f1c620]60static inline int is_system_method(unative_t method)
[2ba7810]61{
62 if (method <= IPC_M_LAST_SYSTEM)
63 return 1;
64 return 0;
65}
66
67/** Return true if the message with this method is forwardable
68 *
69 * - some system messages may be forwarded, for some of them
70 * it is useless
71 */
[7f1c620]72static inline int is_forwardable(unative_t method)
[2ba7810]73{
[51ec40f]74 if (method == IPC_M_PHONE_HUNGUP || method == IPC_M_AS_AREA_SEND ||
75 method == IPC_M_AS_AREA_RECV)
[fbcfd458]76 return 0; /* This message is meant only for the receiver */
[2ba7810]77 return 1;
78}
79
[2d5a54f3]80/****************************************************/
81/* Functions that preprocess answer before sending
82 * it to the recepient
83 */
84
85/** Return true if the caller (ipc_answer) should save
[9f22213]86 * the old call contents for answer_preprocess
[2d5a54f3]87 */
[9f22213]88static inline int answer_need_old(call_t *call)
[2d5a54f3]89{
[fbcfd458]90 if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
[2d5a54f3]91 return 1;
[fbcfd458]92 if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_ME_TO)
[37c57f2]93 return 1;
[8497711]94 if (IPC_GET_METHOD(call->data) == IPC_M_AS_AREA_SEND)
[7c23af9]95 return 1;
[46fc2f9]96 if (IPC_GET_METHOD(call->data) == IPC_M_AS_AREA_RECV)
97 return 1;
[2d5a54f3]98 return 0;
99}
100
[46fc2f9]101/** Interpret process answer as control information
102 *
103 * This function is called directly after sys_ipc_answer
104 */
[7c23af9]105static inline int answer_preprocess(call_t *answer, ipc_data_t *olddata)
[2d5a54f3]106{
107 int phoneid;
108
[9f22213]109 if (IPC_GET_RETVAL(answer->data) == EHANGUP) {
[ca687ad]110 /* In case of forward, hangup the forwared phone,
111 * not the originator
112 */
113 spinlock_lock(&answer->data.phone->lock);
114 spinlock_lock(&TASK->answerbox.lock);
[eb3d379]115 if (answer->data.phone->state == IPC_PHONE_CONNECTED) {
[c4e4507]116 list_remove(&answer->data.phone->link);
[eb3d379]117 answer->data.phone->state = IPC_PHONE_SLAMMED;
[ca687ad]118 }
119 spinlock_unlock(&TASK->answerbox.lock);
120 spinlock_unlock(&answer->data.phone->lock);
[9f22213]121 }
122
123 if (!olddata)
[7c23af9]124 return 0;
[9f22213]125
[fbcfd458]126 if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
[2ba7810]127 phoneid = IPC_GET_ARG3(*olddata);
[2d5a54f3]128 if (IPC_GET_RETVAL(answer->data)) {
129 /* The connection was not accepted */
130 phone_dealloc(phoneid);
[2ba7810]131 } else {
[7c7aae16]132 /* The connection was accepted */
[51ec40f]133 phone_connect(phoneid, &answer->sender->answerbox);
[7c7aae16]134 /* Set 'phone identification' as arg3 of response */
[51ec40f]135 IPC_SET_ARG3(answer->data,
136 (unative_t) &TASK->phones[phoneid]);
[2d5a54f3]137 }
[fbcfd458]138 } else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
[37c57f2]139 /* If the users accepted call, connect */
140 if (!IPC_GET_RETVAL(answer->data)) {
[51ec40f]141 ipc_phone_connect((phone_t *) IPC_GET_ARG3(*olddata),
142 &TASK->answerbox);
[37c57f2]143 }
[8497711]144 } else if (IPC_GET_METHOD(*olddata) == IPC_M_AS_AREA_SEND) {
[51ec40f]145 if (!IPC_GET_RETVAL(answer->data)) {
146 /* Accepted, handle as_area receipt */
[8d6bc2d5]147 ipl_t ipl;
[76d7305]148 int rc;
[8d6bc2d5]149 as_t *as;
150
151 ipl = interrupts_disable();
152 spinlock_lock(&answer->sender->lock);
153 as = answer->sender->as;
154 spinlock_unlock(&answer->sender->lock);
155 interrupts_restore(ipl);
156
[51ec40f]157 rc = as_area_share(as, IPC_GET_ARG1(*olddata),
158 IPC_GET_ARG2(*olddata), AS,
159 IPC_GET_ARG1(answer->data), IPC_GET_ARG3(*olddata));
[76d7305]160 IPC_SET_RETVAL(answer->data, rc);
161 return rc;
[46fc2f9]162 }
163 } else if (IPC_GET_METHOD(*olddata) == IPC_M_AS_AREA_RECV) {
164 if (!IPC_GET_RETVAL(answer->data)) {
165 ipl_t ipl;
166 as_t *as;
[d6e5cbc]167 int rc;
[46fc2f9]168
169 ipl = interrupts_disable();
170 spinlock_lock(&answer->sender->lock);
171 as = answer->sender->as;
172 spinlock_unlock(&answer->sender->lock);
173 interrupts_restore(ipl);
174
[51ec40f]175 rc = as_area_share(AS, IPC_GET_ARG1(answer->data),
176 IPC_GET_ARG2(*olddata), as, IPC_GET_ARG1(*olddata),
177 IPC_GET_ARG2(answer->data));
[d6e5cbc]178 IPC_SET_RETVAL(answer->data, rc);
[7c23af9]179 }
[2d5a54f3]180 }
[7c23af9]181 return 0;
[2d5a54f3]182}
183
[7c7aae16]184/** Called before the request is sent
185 *
186 * @return 0 - no error, -1 - report error to user
187 */
188static int request_preprocess(call_t *call)
189{
190 int newphid;
[7c23af9]191 size_t size;
[7c7aae16]192
193 switch (IPC_GET_METHOD(call->data)) {
194 case IPC_M_CONNECT_ME_TO:
195 newphid = phone_alloc();
196 if (newphid < 0)
197 return ELIMIT;
198 /* Set arg3 for server */
[51ec40f]199 IPC_SET_ARG3(call->data, (unative_t) &TASK->phones[newphid]);
[7c7aae16]200 call->flags |= IPC_CALL_CONN_ME_TO;
[0c1a5d8a]201 call->priv = newphid;
[7c7aae16]202 break;
[8497711]203 case IPC_M_AS_AREA_SEND:
[fd4d8c0]204 size = as_get_size(IPC_GET_ARG1(call->data));
[7c23af9]205 if (!size) {
206 return EPERM;
207 }
[fd4d8c0]208 IPC_SET_ARG2(call->data, size);
[7c23af9]209 break;
[7c7aae16]210 default:
211 break;
212 }
213 return 0;
214}
215
[2d5a54f3]216/****************************************************/
217/* Functions called to process received call/answer
218 * before passing to uspace
219 */
220
221/** Do basic kernel processing of received call answer */
[7c7aae16]222static void process_answer(call_t *call)
[2d5a54f3]223{
[51ec40f]224 if (IPC_GET_RETVAL(call->data) == EHANGUP &&
225 (call->flags & IPC_CALL_FORWARDED))
[9f22213]226 IPC_SET_RETVAL(call->data, EFORWARD);
[7c7aae16]227
228 if (call->flags & IPC_CALL_CONN_ME_TO) {
229 if (IPC_GET_RETVAL(call->data))
[0c1a5d8a]230 phone_dealloc(call->priv);
[7c7aae16]231 else
[0c1a5d8a]232 IPC_SET_ARG3(call->data, call->priv);
[7c7aae16]233 }
[2d5a54f3]234}
235
236/** Do basic kernel processing of received call request
237 *
238 * @return 0 - the call should be passed to userspace, 1 - ignore call
239 */
[51ec40f]240static int process_request(answerbox_t *box, call_t *call)
[2d5a54f3]241{
242 int phoneid;
243
[fbcfd458]244 if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) {
[2ba7810]245 phoneid = phone_alloc();
[2d5a54f3]246 if (phoneid < 0) { /* Failed to allocate phone */
247 IPC_SET_RETVAL(call->data, ELIMIT);
248 ipc_answer(box,call);
249 return -1;
250 }
251 IPC_SET_ARG3(call->data, phoneid);
252 }
253 return 0;
254}
255
256/** Send a call over IPC, wait for reply, return to user
257 *
258 * @return Call identification, returns -1 on fatal error,
259 -2 on 'Too many async request, handle answers first
260 */
[51ec40f]261unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
262 unative_t arg1, ipc_data_t *data)
[2d5a54f3]263{
264 call_t call;
265 phone_t *phone;
[7c7aae16]266 int res;
[2d5a54f3]267
[ba81cab]268 GET_CHECK_PHONE(phone, phoneid, return ENOENT);
[4e49572]269
[ba81cab]270 ipc_call_static_init(&call);
[2d5a54f3]271 IPC_SET_METHOD(call.data, method);
272 IPC_SET_ARG1(call.data, arg1);
273
[7c7aae16]274 if (!(res=request_preprocess(&call))) {
275 ipc_call_sync(phone, &call);
276 process_answer(&call);
277 } else
278 IPC_SET_RETVAL(call.data, res);
[fbcfd458]279 STRUCT_TO_USPACE(&data->args, &call.data.args);
[2d5a54f3]280
281 return 0;
282}
283
284/** Synchronous IPC call allowing to send whole message */
[51ec40f]285unative_t sys_ipc_call_sync(unative_t phoneid, ipc_data_t *question,
286 ipc_data_t *reply)
[2d5a54f3]287{
288 call_t call;
289 phone_t *phone;
[7c7aae16]290 int res;
[e3c762cd]291 int rc;
[2d5a54f3]292
[ba81cab]293 ipc_call_static_init(&call);
[51ec40f]294 rc = copy_from_uspace(&call.data.args, &question->args,
295 sizeof(call.data.args));
[e3c762cd]296 if (rc != 0)
[7f1c620]297 return (unative_t) rc;
[2ba7810]298
[ba81cab]299 GET_CHECK_PHONE(phone, phoneid, return ENOENT);
[4e49572]300
[7c7aae16]301 if (!(res=request_preprocess(&call))) {
302 ipc_call_sync(phone, &call);
303 process_answer(&call);
304 } else
305 IPC_SET_RETVAL(call.data, res);
[2d5a54f3]306
[e3c762cd]307 rc = STRUCT_TO_USPACE(&reply->args, &call.data.args);
308 if (rc != 0)
309 return rc;
[2d5a54f3]310
311 return 0;
312}
313
314/** Check that the task did not exceed allowed limit
315 *
316 * @return 0 - Limit OK, -1 - limit exceeded
317 */
318static int check_call_limit(void)
319{
320 if (atomic_preinc(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) {
321 atomic_dec(&TASK->active_calls);
322 return -1;
323 }
324 return 0;
325}
326
327/** Send an asynchronous call over ipc
328 *
329 * @return Call identification, returns -1 on fatal error,
330 -2 on 'Too many async request, handle answers first
331 */
[51ec40f]332unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
333 unative_t arg1, unative_t arg2)
[2d5a54f3]334{
335 call_t *call;
336 phone_t *phone;
[7c7aae16]337 int res;
[2ba7810]338
[2d5a54f3]339 if (check_call_limit())
340 return IPC_CALLRET_TEMPORARY;
341
[7c7aae16]342 GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL);
[4e49572]343
[5626277]344 call = ipc_call_alloc(0);
[2d5a54f3]345 IPC_SET_METHOD(call->data, method);
346 IPC_SET_ARG1(call->data, arg1);
347 IPC_SET_ARG2(call->data, arg2);
[85d24f61]348 IPC_SET_ARG3(call->data, 0);
[2d5a54f3]349
[51ec40f]350 if (!(res = request_preprocess(call)))
[7c7aae16]351 ipc_call(phone, call);
352 else
353 ipc_backsend_err(phone, call, res);
[2d5a54f3]354
[7f1c620]355 return (unative_t) call;
[2d5a54f3]356}
357
358/** Synchronous IPC call allowing to send whole message
359 *
360 * @return The same as sys_ipc_call_async
361 */
[7f1c620]362unative_t sys_ipc_call_async(unative_t phoneid, ipc_data_t *data)
[2d5a54f3]363{
364 call_t *call;
365 phone_t *phone;
[7c7aae16]366 int res;
[e3c762cd]367 int rc;
[2d5a54f3]368
369 if (check_call_limit())
370 return IPC_CALLRET_TEMPORARY;
371
[7c7aae16]372 GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL);
[4e49572]373
[5626277]374 call = ipc_call_alloc(0);
[51ec40f]375 rc = copy_from_uspace(&call->data.args, &data->args,
376 sizeof(call->data.args));
[f58af46]377 if (rc != 0) {
378 ipc_call_free(call);
[7f1c620]379 return (unative_t) rc;
[f58af46]380 }
[51ec40f]381 if (!(res = request_preprocess(call)))
[7c7aae16]382 ipc_call(phone, call);
383 else
384 ipc_backsend_err(phone, call, res);
[2d5a54f3]385
[7f1c620]386 return (unative_t) call;
[2d5a54f3]387}
388
[2ba7810]389/** Forward received call to another destination
390 *
391 * The arg1 and arg2 are changed in the forwarded message
[37c57f2]392 *
393 * Warning: If implementing non-fast version, make sure that
394 * arg3 is not rewritten for certain system IPC
[2ba7810]395 */
[7f1c620]396unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
[51ec40f]397 unative_t method, unative_t arg1)
[2ba7810]398{
399 call_t *call;
400 phone_t *phone;
401
402 call = get_call(callid);
403 if (!call)
404 return ENOENT;
405
[9f22213]406 call->flags |= IPC_CALL_FORWARDED;
407
[ba81cab]408 GET_CHECK_PHONE(phone, phoneid, {
[2ba7810]409 IPC_SET_RETVAL(call->data, EFORWARD);
410 ipc_answer(&TASK->answerbox, call);
411 return ENOENT;
[ba81cab]412 });
[2ba7810]413
414 if (!is_forwardable(IPC_GET_METHOD(call->data))) {
415 IPC_SET_RETVAL(call->data, EFORWARD);
416 ipc_answer(&TASK->answerbox, call);
417 return EPERM;
418 }
419
420 /* Userspace is not allowed to change method of system methods
421 * on forward, allow changing ARG1 and ARG2 by means of method and arg1
422 */
423 if (is_system_method(IPC_GET_METHOD(call->data))) {
[7c7aae16]424 if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
425 phone_dealloc(IPC_GET_ARG3(call->data));
426
[2ba7810]427 IPC_SET_ARG1(call->data, method);
428 IPC_SET_ARG2(call->data, arg1);
429 } else {
430 IPC_SET_METHOD(call->data, method);
431 IPC_SET_ARG1(call->data, arg1);
432 }
433
[9f22213]434 return ipc_forward(call, phone, &TASK->answerbox);
[2ba7810]435}
436
[2d5a54f3]437/** Send IPC answer */
[51ec40f]438unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
439 unative_t arg1, unative_t arg2)
[2d5a54f3]440{
441 call_t *call;
[2ba7810]442 ipc_data_t saved_data;
[9f22213]443 int saveddata = 0;
[7c23af9]444 int rc;
[2d5a54f3]445
[897f2e76]446 /* Do not answer notification callids */
447 if (callid & IPC_CALLID_NOTIFICATION)
448 return 0;
449
[2ba7810]450 call = get_call(callid);
451 if (!call)
452 return ENOENT;
[2d5a54f3]453
[9f22213]454 if (answer_need_old(call)) {
[2ba7810]455 memcpy(&saved_data, &call->data, sizeof(call->data));
[9f22213]456 saveddata = 1;
[2d5a54f3]457 }
458
459 IPC_SET_RETVAL(call->data, retval);
460 IPC_SET_ARG1(call->data, arg1);
461 IPC_SET_ARG2(call->data, arg2);
[7c23af9]462 rc = answer_preprocess(call, saveddata ? &saved_data : NULL);
[2d5a54f3]463
464 ipc_answer(&TASK->answerbox, call);
[7c23af9]465 return rc;
[2d5a54f3]466}
467
468/** Send IPC answer */
[7f1c620]469unative_t sys_ipc_answer(unative_t callid, ipc_data_t *data)
[2d5a54f3]470{
471 call_t *call;
[2ba7810]472 ipc_data_t saved_data;
[9f22213]473 int saveddata = 0;
[e3c762cd]474 int rc;
[2d5a54f3]475
[897f2e76]476 /* Do not answer notification callids */
477 if (callid & IPC_CALLID_NOTIFICATION)
478 return 0;
479
[2ba7810]480 call = get_call(callid);
481 if (!call)
482 return ENOENT;
[2d5a54f3]483
[9f22213]484 if (answer_need_old(call)) {
[2ba7810]485 memcpy(&saved_data, &call->data, sizeof(call->data));
[9f22213]486 saveddata = 1;
[2d5a54f3]487 }
[e3c762cd]488 rc = copy_from_uspace(&call->data.args, &data->args,
[51ec40f]489 sizeof(call->data.args));
[e3c762cd]490 if (rc != 0)
491 return rc;
[2d5a54f3]492
[7c23af9]493 rc = answer_preprocess(call, saveddata ? &saved_data : NULL);
[2d5a54f3]494
495 ipc_answer(&TASK->answerbox, call);
496
[7c23af9]497 return rc;
[2d5a54f3]498}
499
[fbcfd458]500/** Hang up the phone
[2d5a54f3]501 *
[fbcfd458]502 */
[7f1c620]503unative_t sys_ipc_hangup(int phoneid)
[fbcfd458]504{
505 phone_t *phone;
506
507 GET_CHECK_PHONE(phone, phoneid, return ENOENT);
508
[d8f7362]509 if (ipc_phone_hangup(phone))
[fbcfd458]510 return -1;
511
512 return 0;
513}
514
515/** Wait for incoming ipc call or answer
516 *
[51ec40f]517 * @param calldata Pointer to buffer where the call/answer data is stored.
518 * @param usec Timeout. See waitq_sleep_timeout() for explanation.
519 * @param flags Select mode of sleep operation. See waitq_sleep_timeout()
520 * for explanation.
[bd5a663]521 *
[2d5a54f3]522 * @return Callid, if callid & 1, then the call is answer
523 */
[7f1c620]524unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, int flags)
[2d5a54f3]525{
526 call_t *call;
527
528restart:
[51ec40f]529 call = ipc_wait_for_call(&TASK->answerbox, usec,
530 flags | SYNCH_FLAGS_INTERRUPTIBLE);
[9f22213]531 if (!call)
532 return 0;
[2d5a54f3]533
[5626277]534 if (call->flags & IPC_CALL_NOTIF) {
535 ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
[43752b6]536
537 /* Set in_phone_hash to the interrupt counter */
[0c1a5d8a]538 call->data.phone = (void *) call->priv;
[43752b6]539
540 STRUCT_TO_USPACE(calldata, &call->data);
541
[5626277]542 ipc_call_free(call);
543
[7f1c620]544 return ((unative_t)call) | IPC_CALLID_NOTIFICATION;
[5626277]545 }
546
[2d5a54f3]547 if (call->flags & IPC_CALL_ANSWERED) {
[7c7aae16]548 process_answer(call);
[2d5a54f3]549
550 ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
[fbcfd458]551
552 atomic_dec(&TASK->active_calls);
553
554 if (call->flags & IPC_CALL_DISCARD_ANSWER) {
555 ipc_call_free(call);
556 goto restart;
557 }
558
559 STRUCT_TO_USPACE(&calldata->args, &call->data.args);
[2d5a54f3]560 ipc_call_free(call);
561
[7f1c620]562 return ((unative_t)call) | IPC_CALLID_ANSWERED;
[2d5a54f3]563 }
[fbcfd458]564
[2d5a54f3]565 if (process_request(&TASK->answerbox, call))
566 goto restart;
[fbcfd458]567
[7c7aae16]568 /* Include phone address('id') of the caller in the request,
569 * copy whole call->data, not only call->data.args */
[bd55bbb]570 if (STRUCT_TO_USPACE(calldata, &call->data)) {
571 return 0;
572 }
[7f1c620]573 return (unative_t)call;
[2d5a54f3]574}
[5626277]575
[2b017ba]576/** Connect irq handler to task.
577 *
578 * @param inr IRQ number.
579 * @param devno Device number.
580 * @param method Method to be associated with the notification.
581 * @param ucode Uspace pointer to the top-half pseudocode.
582 *
583 * @return EPERM or a return code returned by ipc_irq_register().
584 */
[51ec40f]585unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
586 irq_code_t *ucode)
[5626277]587{
[2bb8648]588 if (!(cap_get(TASK) & CAP_IRQ_REG))
589 return EPERM;
590
[2b017ba]591 return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);
[5626277]592}
593
[2b017ba]594/** Disconnect irq handler from task.
595 *
596 * @param inr IRQ number.
597 * @param devno Device number.
598 */
599unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)
[5626277]600{
[2bb8648]601 if (!(cap_get(TASK) & CAP_IRQ_REG))
602 return EPERM;
603
[2b017ba]604 ipc_irq_unregister(&TASK->answerbox, inr, devno);
[5626277]605
606 return 0;
607}
[b45c443]608
[cc73a8a1]609/** @}
[b45c443]610 */
Note: See TracBrowser for help on using the repository browser.