[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>
|
---|
[e028660] | 45 | #include <ipc/kbox.h>
|
---|
[057d21a] | 46 | #include <synch/waitq.h>
|
---|
[9a1b20c] | 47 | #include <udebug/udebug_ipc.h>
|
---|
[5626277] | 48 | #include <arch/interrupt.h>
|
---|
[e3c762cd] | 49 | #include <syscall/copy.h>
|
---|
[2bb8648] | 50 | #include <security/cap.h>
|
---|
[6b10dab] | 51 | #include <console/console.h>
|
---|
[7c23af9] | 52 | #include <mm/as.h>
|
---|
[253f35a1] | 53 | #include <print.h>
|
---|
[2d5a54f3] | 54 |
|
---|
[36d852c] | 55 | /**
|
---|
| 56 | * Maximum buffer size allowed for IPC_M_DATA_WRITE and IPC_M_DATA_READ
|
---|
| 57 | * requests.
|
---|
| 58 | */
|
---|
[da1bafb] | 59 | #define DATA_XFER_LIMIT (64 * 1024)
|
---|
| 60 |
|
---|
| 61 | #define STRUCT_TO_USPACE(dst, src) copy_to_uspace((dst), (src), sizeof(*(src)))
|
---|
[7918fce] | 62 |
|
---|
[c9fff17] | 63 | /** Get phone from the current task by ID.
|
---|
| 64 | *
|
---|
[da1bafb] | 65 | * @param phoneid Phone ID.
|
---|
| 66 | * @param phone Place to store pointer to phone.
|
---|
| 67 | *
|
---|
| 68 | * @return EOK on success, EINVAL if ID is invalid.
|
---|
| 69 | *
|
---|
[c9fff17] | 70 | */
|
---|
[96b02eb9] | 71 | static int phone_get(sysarg_t phoneid, phone_t **phone)
|
---|
[c9fff17] | 72 | {
|
---|
| 73 | if (phoneid >= IPC_MAX_PHONES)
|
---|
| 74 | return EINVAL;
|
---|
[da1bafb] | 75 |
|
---|
[c9fff17] | 76 | *phone = &TASK->phones[phoneid];
|
---|
| 77 | return EOK;
|
---|
[ba81cab] | 78 | }
|
---|
| 79 |
|
---|
[228e490] | 80 | /** Decide if the interface and method is a system method.
|
---|
[8b243f2] | 81 | *
|
---|
[228e490] | 82 | * @param imethod Interface and method to be decided.
|
---|
[da1bafb] | 83 | *
|
---|
[228e490] | 84 | * @return True if the interface and method is a system
|
---|
| 85 | * interface and method.
|
---|
[8b243f2] | 86 | *
|
---|
| 87 | */
|
---|
[228e490] | 88 | static inline bool method_is_system(sysarg_t imethod)
|
---|
[2ba7810] | 89 | {
|
---|
[228e490] | 90 | if (imethod <= IPC_M_LAST_SYSTEM)
|
---|
[da1bafb] | 91 | return true;
|
---|
| 92 |
|
---|
| 93 | return false;
|
---|
[2ba7810] | 94 | }
|
---|
| 95 |
|
---|
[228e490] | 96 | /** Decide if the message with this interface and method is forwardable.
|
---|
[2ba7810] | 97 | *
|
---|
[228e490] | 98 | * Some system messages may be forwarded, for some of them
|
---|
| 99 | * it is useless.
|
---|
[8b243f2] | 100 | *
|
---|
[228e490] | 101 | * @param imethod Interface and method to be decided.
|
---|
[da1bafb] | 102 | *
|
---|
[228e490] | 103 | * @return True if the interface and method is forwardable.
|
---|
[8b243f2] | 104 | *
|
---|
[2ba7810] | 105 | */
|
---|
[228e490] | 106 | static inline bool method_is_forwardable(sysarg_t imethod)
|
---|
[2ba7810] | 107 | {
|
---|
[228e490] | 108 | switch (imethod) {
|
---|
[2c0e5d2] | 109 | case IPC_M_CONNECTION_CLONE:
|
---|
| 110 | case IPC_M_CONNECT_ME:
|
---|
[7918fce] | 111 | case IPC_M_PHONE_HUNGUP:
|
---|
| 112 | /* This message is meant only for the original recipient. */
|
---|
[da1bafb] | 113 | return false;
|
---|
[7918fce] | 114 | default:
|
---|
[da1bafb] | 115 | return true;
|
---|
[7918fce] | 116 | }
|
---|
[2ba7810] | 117 | }
|
---|
| 118 |
|
---|
[228e490] | 119 | /** Decide if the message with this interface and method is immutable on forward.
|
---|
[0dc4258] | 120 | *
|
---|
[228e490] | 121 | * Some system messages may be forwarded but their content cannot be altered.
|
---|
[0dc4258] | 122 | *
|
---|
[228e490] | 123 | * @param imethod Interface and method to be decided.
|
---|
[da1bafb] | 124 | *
|
---|
[228e490] | 125 | * @return True if the interface and method is immutable on forward.
|
---|
[0dc4258] | 126 | *
|
---|
| 127 | */
|
---|
[228e490] | 128 | static inline bool method_is_immutable(sysarg_t imethod)
|
---|
[0dc4258] | 129 | {
|
---|
[228e490] | 130 | switch (imethod) {
|
---|
[27d293a] | 131 | case IPC_M_SHARE_OUT:
|
---|
| 132 | case IPC_M_SHARE_IN:
|
---|
[36d852c] | 133 | case IPC_M_DATA_WRITE:
|
---|
| 134 | case IPC_M_DATA_READ:
|
---|
[da1bafb] | 135 | return true;
|
---|
[0dc4258] | 136 | default:
|
---|
[da1bafb] | 137 | return false;
|
---|
[0dc4258] | 138 | }
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[2d5a54f3] | 141 |
|
---|
[8b243f2] | 142 | /***********************************************************************
|
---|
| 143 | * Functions that preprocess answer before sending it to the recepient.
|
---|
| 144 | ***********************************************************************/
|
---|
| 145 |
|
---|
| 146 | /** Decide if the caller (e.g. ipc_answer()) should save the old call contents
|
---|
| 147 | * for answer_preprocess().
|
---|
| 148 | *
|
---|
[da1bafb] | 149 | * @param call Call structure to be decided.
|
---|
| 150 | *
|
---|
| 151 | * @return true if the old call contents should be saved.
|
---|
[8b243f2] | 152 | *
|
---|
[2d5a54f3] | 153 | */
|
---|
[da1bafb] | 154 | static inline bool answer_need_old(call_t *call)
|
---|
[2d5a54f3] | 155 | {
|
---|
[228e490] | 156 | switch (IPC_GET_IMETHOD(call->data)) {
|
---|
[2c0e5d2] | 157 | case IPC_M_CONNECTION_CLONE:
|
---|
| 158 | case IPC_M_CONNECT_ME:
|
---|
[7918fce] | 159 | case IPC_M_CONNECT_TO_ME:
|
---|
| 160 | case IPC_M_CONNECT_ME_TO:
|
---|
[27d293a] | 161 | case IPC_M_SHARE_OUT:
|
---|
| 162 | case IPC_M_SHARE_IN:
|
---|
[36d852c] | 163 | case IPC_M_DATA_WRITE:
|
---|
| 164 | case IPC_M_DATA_READ:
|
---|
[da1bafb] | 165 | return true;
|
---|
[7918fce] | 166 | default:
|
---|
[da1bafb] | 167 | return false;
|
---|
[7918fce] | 168 | }
|
---|
[2d5a54f3] | 169 | }
|
---|
| 170 |
|
---|
[8b243f2] | 171 | /** Interpret process answer as control information.
|
---|
| 172 | *
|
---|
| 173 | * This function is called directly after sys_ipc_answer().
|
---|
[46fc2f9] | 174 | *
|
---|
[da1bafb] | 175 | * @param answer Call structure with the answer.
|
---|
| 176 | * @param olddata Saved data of the request.
|
---|
| 177 | *
|
---|
| 178 | * @return Return 0 on success or an error code.
|
---|
[8b243f2] | 179 | *
|
---|
[46fc2f9] | 180 | */
|
---|
[7c23af9] | 181 | static inline int answer_preprocess(call_t *answer, ipc_data_t *olddata)
|
---|
[2d5a54f3] | 182 | {
|
---|
[6c441cf8] | 183 | if ((native_t) IPC_GET_RETVAL(answer->data) == EHANGUP) {
|
---|
[ca687ad] | 184 | /* In case of forward, hangup the forwared phone,
|
---|
| 185 | * not the originator
|
---|
| 186 | */
|
---|
[ff48a15] | 187 | mutex_lock(&answer->data.phone->lock);
|
---|
[da1bafb] | 188 | irq_spinlock_lock(&TASK->answerbox.lock, true);
|
---|
[eb3d379] | 189 | if (answer->data.phone->state == IPC_PHONE_CONNECTED) {
|
---|
[c4e4507] | 190 | list_remove(&answer->data.phone->link);
|
---|
[eb3d379] | 191 | answer->data.phone->state = IPC_PHONE_SLAMMED;
|
---|
[ca687ad] | 192 | }
|
---|
[da1bafb] | 193 | irq_spinlock_unlock(&TASK->answerbox.lock, true);
|
---|
[ff48a15] | 194 | mutex_unlock(&answer->data.phone->lock);
|
---|
[9f22213] | 195 | }
|
---|
[da1bafb] | 196 |
|
---|
[9f22213] | 197 | if (!olddata)
|
---|
[7c23af9] | 198 | return 0;
|
---|
[da1bafb] | 199 |
|
---|
[228e490] | 200 | if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECTION_CLONE) {
|
---|
[da1bafb] | 201 | int phoneid = IPC_GET_ARG1(*olddata);
|
---|
| 202 | phone_t *phone = &TASK->phones[phoneid];
|
---|
| 203 |
|
---|
[2c0e5d2] | 204 | if (IPC_GET_RETVAL(answer->data) != EOK) {
|
---|
| 205 | /*
|
---|
| 206 | * The recipient of the cloned phone rejected the offer.
|
---|
| 207 | * In this case, the connection was established at the
|
---|
| 208 | * request time and therefore we need to slam the phone.
|
---|
| 209 | * We don't merely hangup as that would result in
|
---|
| 210 | * sending IPC_M_HUNGUP to the third party on the
|
---|
| 211 | * other side of the cloned phone.
|
---|
| 212 | */
|
---|
| 213 | mutex_lock(&phone->lock);
|
---|
| 214 | if (phone->state == IPC_PHONE_CONNECTED) {
|
---|
[da1bafb] | 215 | irq_spinlock_lock(&phone->callee->lock, true);
|
---|
[2c0e5d2] | 216 | list_remove(&phone->link);
|
---|
| 217 | phone->state = IPC_PHONE_SLAMMED;
|
---|
[da1bafb] | 218 | irq_spinlock_unlock(&phone->callee->lock, true);
|
---|
[2c0e5d2] | 219 | }
|
---|
| 220 | mutex_unlock(&phone->lock);
|
---|
| 221 | }
|
---|
[228e490] | 222 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME) {
|
---|
[da1bafb] | 223 | phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
|
---|
| 224 |
|
---|
[2c0e5d2] | 225 | if (IPC_GET_RETVAL(answer->data) != EOK) {
|
---|
| 226 | /*
|
---|
| 227 | * The other party on the cloned phoned rejected our
|
---|
| 228 | * request for connection on the protocol level.
|
---|
| 229 | * We need to break the connection without sending
|
---|
| 230 | * IPC_M_HUNGUP back.
|
---|
| 231 | */
|
---|
| 232 | mutex_lock(&phone->lock);
|
---|
| 233 | if (phone->state == IPC_PHONE_CONNECTED) {
|
---|
[da1bafb] | 234 | irq_spinlock_lock(&phone->callee->lock, true);
|
---|
[2c0e5d2] | 235 | list_remove(&phone->link);
|
---|
| 236 | phone->state = IPC_PHONE_SLAMMED;
|
---|
[da1bafb] | 237 | irq_spinlock_unlock(&phone->callee->lock, true);
|
---|
[2c0e5d2] | 238 | }
|
---|
| 239 | mutex_unlock(&phone->lock);
|
---|
| 240 | }
|
---|
[228e490] | 241 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
|
---|
[da1bafb] | 242 | int phoneid = IPC_GET_ARG5(*olddata);
|
---|
| 243 |
|
---|
[2c0e5d2] | 244 | if (IPC_GET_RETVAL(answer->data) != EOK) {
|
---|
[2d5a54f3] | 245 | /* The connection was not accepted */
|
---|
| 246 | phone_dealloc(phoneid);
|
---|
[2ba7810] | 247 | } else {
|
---|
[7c7aae16] | 248 | /* The connection was accepted */
|
---|
[51ec40f] | 249 | phone_connect(phoneid, &answer->sender->answerbox);
|
---|
[124c061] | 250 | /* Set 'task hash' as arg4 of response */
|
---|
| 251 | IPC_SET_ARG4(answer->data, (sysarg_t) TASK);
|
---|
[6364d3c] | 252 | /* Set 'phone hash' as arg5 of response */
|
---|
[38c706cc] | 253 | IPC_SET_ARG5(answer->data,
|
---|
[96b02eb9] | 254 | (sysarg_t) &TASK->phones[phoneid]);
|
---|
[2d5a54f3] | 255 | }
|
---|
[228e490] | 256 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
|
---|
[37c57f2] | 257 | /* If the users accepted call, connect */
|
---|
[2c0e5d2] | 258 | if (IPC_GET_RETVAL(answer->data) == EOK) {
|
---|
[b61d47d] | 259 | ipc_phone_connect((phone_t *) IPC_GET_ARG5(*olddata),
|
---|
[51ec40f] | 260 | &TASK->answerbox);
|
---|
[37c57f2] | 261 | }
|
---|
[228e490] | 262 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_OUT) {
|
---|
[51ec40f] | 263 | if (!IPC_GET_RETVAL(answer->data)) {
|
---|
| 264 | /* Accepted, handle as_area receipt */
|
---|
[8d6bc2d5] | 265 |
|
---|
[da1bafb] | 266 | irq_spinlock_lock(&answer->sender->lock, true);
|
---|
| 267 | as_t *as = answer->sender->as;
|
---|
| 268 | irq_spinlock_unlock(&answer->sender->lock, true);
|
---|
[8d6bc2d5] | 269 |
|
---|
[da1bafb] | 270 | int rc = as_area_share(as, IPC_GET_ARG1(*olddata),
|
---|
[51ec40f] | 271 | IPC_GET_ARG2(*olddata), AS,
|
---|
| 272 | IPC_GET_ARG1(answer->data), IPC_GET_ARG3(*olddata));
|
---|
[76d7305] | 273 | IPC_SET_RETVAL(answer->data, rc);
|
---|
| 274 | return rc;
|
---|
[46fc2f9] | 275 | }
|
---|
[228e490] | 276 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) {
|
---|
[46fc2f9] | 277 | if (!IPC_GET_RETVAL(answer->data)) {
|
---|
[da1bafb] | 278 | irq_spinlock_lock(&answer->sender->lock, true);
|
---|
| 279 | as_t *as = answer->sender->as;
|
---|
| 280 | irq_spinlock_unlock(&answer->sender->lock, true);
|
---|
[46fc2f9] | 281 |
|
---|
[da1bafb] | 282 | int rc = as_area_share(AS, IPC_GET_ARG1(answer->data),
|
---|
[51ec40f] | 283 | IPC_GET_ARG2(*olddata), as, IPC_GET_ARG1(*olddata),
|
---|
| 284 | IPC_GET_ARG2(answer->data));
|
---|
[d6e5cbc] | 285 | IPC_SET_RETVAL(answer->data, rc);
|
---|
[7c23af9] | 286 | }
|
---|
[228e490] | 287 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_READ) {
|
---|
[a55d5f9f] | 288 | ASSERT(!answer->buffer);
|
---|
| 289 | if (!IPC_GET_RETVAL(answer->data)) {
|
---|
| 290 | /* The recipient agreed to send data. */
|
---|
| 291 | uintptr_t src = IPC_GET_ARG1(answer->data);
|
---|
| 292 | uintptr_t dst = IPC_GET_ARG1(*olddata);
|
---|
| 293 | size_t max_size = IPC_GET_ARG2(*olddata);
|
---|
| 294 | size_t size = IPC_GET_ARG2(answer->data);
|
---|
[1a60feeb] | 295 | if (size && size <= max_size) {
|
---|
[a55d5f9f] | 296 | /*
|
---|
| 297 | * Copy the destination VA so that this piece of
|
---|
| 298 | * information is not lost.
|
---|
| 299 | */
|
---|
| 300 | IPC_SET_ARG1(answer->data, dst);
|
---|
[da1bafb] | 301 |
|
---|
[a55d5f9f] | 302 | answer->buffer = malloc(size, 0);
|
---|
| 303 | int rc = copy_from_uspace(answer->buffer,
|
---|
| 304 | (void *) src, size);
|
---|
| 305 | if (rc) {
|
---|
| 306 | IPC_SET_RETVAL(answer->data, rc);
|
---|
| 307 | free(answer->buffer);
|
---|
| 308 | answer->buffer = NULL;
|
---|
| 309 | }
|
---|
[1a60feeb] | 310 | } else if (!size) {
|
---|
| 311 | IPC_SET_RETVAL(answer->data, EOK);
|
---|
[a55d5f9f] | 312 | } else {
|
---|
| 313 | IPC_SET_RETVAL(answer->data, ELIMIT);
|
---|
| 314 | }
|
---|
| 315 | }
|
---|
[228e490] | 316 | } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_WRITE) {
|
---|
[654b7db] | 317 | ASSERT(answer->buffer);
|
---|
[7918fce] | 318 | if (!IPC_GET_RETVAL(answer->data)) {
|
---|
[a55d5f9f] | 319 | /* The recipient agreed to receive data. */
|
---|
[da1bafb] | 320 | uintptr_t dst = (uintptr_t)IPC_GET_ARG1(answer->data);
|
---|
| 321 | size_t size = (size_t)IPC_GET_ARG2(answer->data);
|
---|
| 322 | size_t max_size = (size_t)IPC_GET_ARG2(*olddata);
|
---|
| 323 |
|
---|
[a55d5f9f] | 324 | if (size <= max_size) {
|
---|
[da1bafb] | 325 | int rc = copy_to_uspace((void *) dst,
|
---|
[a55d5f9f] | 326 | answer->buffer, size);
|
---|
| 327 | if (rc)
|
---|
| 328 | IPC_SET_RETVAL(answer->data, rc);
|
---|
| 329 | } else {
|
---|
| 330 | IPC_SET_RETVAL(answer->data, ELIMIT);
|
---|
| 331 | }
|
---|
[7918fce] | 332 | }
|
---|
[654b7db] | 333 | free(answer->buffer);
|
---|
| 334 | answer->buffer = NULL;
|
---|
[2d5a54f3] | 335 | }
|
---|
[da1bafb] | 336 |
|
---|
[7c23af9] | 337 | return 0;
|
---|
[2d5a54f3] | 338 | }
|
---|
| 339 |
|
---|
[bf1fb9f] | 340 | static void phones_lock(phone_t *p1, phone_t *p2)
|
---|
| 341 | {
|
---|
| 342 | if (p1 < p2) {
|
---|
| 343 | mutex_lock(&p1->lock);
|
---|
| 344 | mutex_lock(&p2->lock);
|
---|
| 345 | } else if (p1 > p2) {
|
---|
| 346 | mutex_lock(&p2->lock);
|
---|
| 347 | mutex_lock(&p1->lock);
|
---|
[da1bafb] | 348 | } else
|
---|
[bf1fb9f] | 349 | mutex_lock(&p1->lock);
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | static void phones_unlock(phone_t *p1, phone_t *p2)
|
---|
| 353 | {
|
---|
| 354 | mutex_unlock(&p1->lock);
|
---|
| 355 | if (p1 != p2)
|
---|
| 356 | mutex_unlock(&p2->lock);
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[8b243f2] | 359 | /** Called before the request is sent.
|
---|
| 360 | *
|
---|
[da1bafb] | 361 | * @param call Call structure with the request.
|
---|
| 362 | * @param phone Phone that the call will be sent through.
|
---|
| 363 | *
|
---|
| 364 | * @return Return 0 on success, ELIMIT or EPERM on error.
|
---|
[7c7aae16] | 365 | *
|
---|
| 366 | */
|
---|
[9a1b20c] | 367 | static int request_preprocess(call_t *call, phone_t *phone)
|
---|
[7c7aae16] | 368 | {
|
---|
[228e490] | 369 | switch (IPC_GET_IMETHOD(call->data)) {
|
---|
[2c0e5d2] | 370 | case IPC_M_CONNECTION_CLONE: {
|
---|
| 371 | phone_t *cloned_phone;
|
---|
[c9fff17] | 372 | if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK)
|
---|
| 373 | return ENOENT;
|
---|
[da1bafb] | 374 |
|
---|
[bf1fb9f] | 375 | phones_lock(cloned_phone, phone);
|
---|
[da1bafb] | 376 |
|
---|
[2c0e5d2] | 377 | if ((cloned_phone->state != IPC_PHONE_CONNECTED) ||
|
---|
| 378 | phone->state != IPC_PHONE_CONNECTED) {
|
---|
[bf1fb9f] | 379 | phones_unlock(cloned_phone, phone);
|
---|
[2c0e5d2] | 380 | return EINVAL;
|
---|
| 381 | }
|
---|
[da1bafb] | 382 |
|
---|
[2c0e5d2] | 383 | /*
|
---|
| 384 | * We can be pretty sure now that both tasks exist and we are
|
---|
| 385 | * connected to them. As we continue to hold the phone locks,
|
---|
| 386 | * we are effectively preventing them from finishing their
|
---|
| 387 | * potential cleanup.
|
---|
[da1bafb] | 388 | *
|
---|
[2c0e5d2] | 389 | */
|
---|
[da1bafb] | 390 | int newphid = phone_alloc(phone->callee->task);
|
---|
[2c0e5d2] | 391 | if (newphid < 0) {
|
---|
[bf1fb9f] | 392 | phones_unlock(cloned_phone, phone);
|
---|
[2c0e5d2] | 393 | return ELIMIT;
|
---|
| 394 | }
|
---|
[da1bafb] | 395 |
|
---|
[2c0e5d2] | 396 | ipc_phone_connect(&phone->callee->task->phones[newphid],
|
---|
| 397 | cloned_phone->callee);
|
---|
[bf1fb9f] | 398 | phones_unlock(cloned_phone, phone);
|
---|
[da1bafb] | 399 |
|
---|
[2c0e5d2] | 400 | /* Set the new phone for the callee. */
|
---|
| 401 | IPC_SET_ARG1(call->data, newphid);
|
---|
| 402 | break;
|
---|
| 403 | }
|
---|
| 404 | case IPC_M_CONNECT_ME:
|
---|
[96b02eb9] | 405 | IPC_SET_ARG5(call->data, (sysarg_t) phone);
|
---|
[2c0e5d2] | 406 | break;
|
---|
[da1bafb] | 407 | case IPC_M_CONNECT_ME_TO: {
|
---|
| 408 | int newphid = phone_alloc(TASK);
|
---|
[7c7aae16] | 409 | if (newphid < 0)
|
---|
| 410 | return ELIMIT;
|
---|
[da1bafb] | 411 |
|
---|
[6364d3c] | 412 | /* Set arg5 for server */
|
---|
[96b02eb9] | 413 | IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]);
|
---|
[7c7aae16] | 414 | call->flags |= IPC_CALL_CONN_ME_TO;
|
---|
[0c1a5d8a] | 415 | call->priv = newphid;
|
---|
[7c7aae16] | 416 | break;
|
---|
[da1bafb] | 417 | }
|
---|
| 418 | case IPC_M_SHARE_OUT: {
|
---|
| 419 | size_t size = as_area_get_size(IPC_GET_ARG1(call->data));
|
---|
[8b243f2] | 420 | if (!size)
|
---|
[7c23af9] | 421 | return EPERM;
|
---|
[da1bafb] | 422 |
|
---|
[fd4d8c0] | 423 | IPC_SET_ARG2(call->data, size);
|
---|
[7c23af9] | 424 | break;
|
---|
[da1bafb] | 425 | }
|
---|
| 426 | case IPC_M_DATA_READ: {
|
---|
| 427 | size_t size = IPC_GET_ARG2(call->data);
|
---|
[a55d5f9f] | 428 | if ((size <= 0 || (size > DATA_XFER_LIMIT)))
|
---|
| 429 | return ELIMIT;
|
---|
[da1bafb] | 430 |
|
---|
[a55d5f9f] | 431 | break;
|
---|
[da1bafb] | 432 | }
|
---|
| 433 | case IPC_M_DATA_WRITE: {
|
---|
| 434 | uintptr_t src = IPC_GET_ARG1(call->data);
|
---|
| 435 | size_t size = IPC_GET_ARG2(call->data);
|
---|
[7918fce] | 436 |
|
---|
[6b6e423a] | 437 | if (size > DATA_XFER_LIMIT)
|
---|
[7918fce] | 438 | return ELIMIT;
|
---|
| 439 |
|
---|
| 440 | call->buffer = (uint8_t *) malloc(size, 0);
|
---|
[da1bafb] | 441 | int rc = copy_from_uspace(call->buffer, (void *) src, size);
|
---|
[7918fce] | 442 | if (rc != 0) {
|
---|
| 443 | free(call->buffer);
|
---|
| 444 | return rc;
|
---|
| 445 | }
|
---|
[da1bafb] | 446 |
|
---|
[7918fce] | 447 | break;
|
---|
[da1bafb] | 448 | }
|
---|
[9a1b20c] | 449 | #ifdef CONFIG_UDEBUG
|
---|
| 450 | case IPC_M_DEBUG_ALL:
|
---|
| 451 | return udebug_request_preprocess(call, phone);
|
---|
| 452 | #endif
|
---|
[7c7aae16] | 453 | default:
|
---|
| 454 | break;
|
---|
| 455 | }
|
---|
[da1bafb] | 456 |
|
---|
[7c7aae16] | 457 | return 0;
|
---|
| 458 | }
|
---|
| 459 |
|
---|
[8b243f2] | 460 | /*******************************************************************************
|
---|
| 461 | * Functions called to process received call/answer before passing it to uspace.
|
---|
| 462 | *******************************************************************************/
|
---|
[2d5a54f3] | 463 |
|
---|
[8b243f2] | 464 | /** Do basic kernel processing of received call answer.
|
---|
| 465 | *
|
---|
[da1bafb] | 466 | * @param call Call structure with the answer.
|
---|
| 467 | *
|
---|
[8b243f2] | 468 | */
|
---|
[7c7aae16] | 469 | static void process_answer(call_t *call)
|
---|
[2d5a54f3] | 470 | {
|
---|
[6c441cf8] | 471 | if (((native_t) IPC_GET_RETVAL(call->data) == EHANGUP) &&
|
---|
[51ec40f] | 472 | (call->flags & IPC_CALL_FORWARDED))
|
---|
[9f22213] | 473 | IPC_SET_RETVAL(call->data, EFORWARD);
|
---|
[da1bafb] | 474 |
|
---|
[7c7aae16] | 475 | if (call->flags & IPC_CALL_CONN_ME_TO) {
|
---|
| 476 | if (IPC_GET_RETVAL(call->data))
|
---|
[0c1a5d8a] | 477 | phone_dealloc(call->priv);
|
---|
[7c7aae16] | 478 | else
|
---|
[b61d47d] | 479 | IPC_SET_ARG5(call->data, call->priv);
|
---|
[7c7aae16] | 480 | }
|
---|
[da1bafb] | 481 |
|
---|
[a55d5f9f] | 482 | if (call->buffer) {
|
---|
[da1bafb] | 483 | /*
|
---|
| 484 | * This must be an affirmative answer to IPC_M_DATA_READ
|
---|
| 485 | * or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ...
|
---|
| 486 | *
|
---|
| 487 | */
|
---|
[a55d5f9f] | 488 | uintptr_t dst = IPC_GET_ARG1(call->data);
|
---|
| 489 | size_t size = IPC_GET_ARG2(call->data);
|
---|
| 490 | int rc = copy_to_uspace((void *) dst, call->buffer, size);
|
---|
| 491 | if (rc)
|
---|
| 492 | IPC_SET_RETVAL(call->data, rc);
|
---|
| 493 | free(call->buffer);
|
---|
| 494 | call->buffer = NULL;
|
---|
| 495 | }
|
---|
[2d5a54f3] | 496 | }
|
---|
| 497 |
|
---|
[8b243f2] | 498 | /** Do basic kernel processing of received call request.
|
---|
| 499 | *
|
---|
[da1bafb] | 500 | * @param box Destination answerbox structure.
|
---|
| 501 | * @param call Call structure with the request.
|
---|
| 502 | *
|
---|
| 503 | * @return 0 if the call should be passed to userspace.
|
---|
| 504 | * @return -1 if the call should be ignored.
|
---|
[2d5a54f3] | 505 | *
|
---|
| 506 | */
|
---|
[51ec40f] | 507 | static int process_request(answerbox_t *box, call_t *call)
|
---|
[2d5a54f3] | 508 | {
|
---|
[228e490] | 509 | if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) {
|
---|
[da1bafb] | 510 | int phoneid = phone_alloc(TASK);
|
---|
[2d5a54f3] | 511 | if (phoneid < 0) { /* Failed to allocate phone */
|
---|
| 512 | IPC_SET_RETVAL(call->data, ELIMIT);
|
---|
[8b243f2] | 513 | ipc_answer(box, call);
|
---|
[2d5a54f3] | 514 | return -1;
|
---|
| 515 | }
|
---|
[da1bafb] | 516 |
|
---|
[38c706cc] | 517 | IPC_SET_ARG5(call->data, phoneid);
|
---|
[9a1b20c] | 518 | }
|
---|
[da1bafb] | 519 |
|
---|
[228e490] | 520 | switch (IPC_GET_IMETHOD(call->data)) {
|
---|
[9a1b20c] | 521 | case IPC_M_DEBUG_ALL:
|
---|
| 522 | return -1;
|
---|
| 523 | default:
|
---|
| 524 | break;
|
---|
| 525 | }
|
---|
[da1bafb] | 526 |
|
---|
[2d5a54f3] | 527 | return 0;
|
---|
| 528 | }
|
---|
| 529 |
|
---|
[8b243f2] | 530 | /** Make a fast call over IPC, wait for reply and return to user.
|
---|
| 531 | *
|
---|
[2e51969] | 532 | * This function can handle only three arguments of payload, but is faster than
|
---|
| 533 | * the generic function (i.e. sys_ipc_call_sync_slow()).
|
---|
[2d5a54f3] | 534 | *
|
---|
[da1bafb] | 535 | * @param phoneid Phone handle for the call.
|
---|
[228e490] | 536 | * @param imethod Interface and method of the call.
|
---|
[da1bafb] | 537 | * @param arg1 Service-defined payload argument.
|
---|
| 538 | * @param arg2 Service-defined payload argument.
|
---|
| 539 | * @param arg3 Service-defined payload argument.
|
---|
[228e490] | 540 | * @param data Address of user-space structure where the reply call will
|
---|
[da1bafb] | 541 | * be stored.
|
---|
| 542 | *
|
---|
| 543 | * @return 0 on success.
|
---|
| 544 | * @return ENOENT if there is no such phone handle.
|
---|
[8b243f2] | 545 | *
|
---|
[2d5a54f3] | 546 | */
|
---|
[228e490] | 547 | sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod,
|
---|
[96b02eb9] | 548 | sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data)
|
---|
[2d5a54f3] | 549 | {
|
---|
| 550 | phone_t *phone;
|
---|
[c9fff17] | 551 | if (phone_get(phoneid, &phone) != EOK)
|
---|
| 552 | return ENOENT;
|
---|
[228e490] | 553 |
|
---|
[da1bafb] | 554 | call_t *call = ipc_call_alloc(0);
|
---|
[228e490] | 555 | IPC_SET_IMETHOD(call->data, imethod);
|
---|
[35bb2e7] | 556 | IPC_SET_ARG1(call->data, arg1);
|
---|
| 557 | IPC_SET_ARG2(call->data, arg2);
|
---|
| 558 | IPC_SET_ARG3(call->data, arg3);
|
---|
[da1bafb] | 559 |
|
---|
[8498915] | 560 | /*
|
---|
| 561 | * To achieve deterministic behavior, zero out arguments that are beyond
|
---|
| 562 | * the limits of the fast version.
|
---|
| 563 | */
|
---|
[35bb2e7] | 564 | IPC_SET_ARG4(call->data, 0);
|
---|
| 565 | IPC_SET_ARG5(call->data, 0);
|
---|
[da1bafb] | 566 |
|
---|
| 567 | int res = request_preprocess(call, phone);
|
---|
| 568 | int rc;
|
---|
| 569 |
|
---|
| 570 | if (!res) {
|
---|
[741fd16] | 571 | #ifdef CONFIG_UDEBUG
|
---|
| 572 | udebug_stoppable_begin();
|
---|
| 573 | #endif
|
---|
[35bb2e7] | 574 | rc = ipc_call_sync(phone, call);
|
---|
[741fd16] | 575 | #ifdef CONFIG_UDEBUG
|
---|
| 576 | udebug_stoppable_end();
|
---|
| 577 | #endif
|
---|
[da1bafb] | 578 |
|
---|
[35bb2e7] | 579 | if (rc != EOK) {
|
---|
[33adc6ce] | 580 | /* The call will be freed by ipc_cleanup(). */
|
---|
[79872cd] | 581 | return rc;
|
---|
[35bb2e7] | 582 | }
|
---|
[da1bafb] | 583 |
|
---|
[35bb2e7] | 584 | process_answer(call);
|
---|
[da1bafb] | 585 | } else
|
---|
[35bb2e7] | 586 | IPC_SET_RETVAL(call->data, res);
|
---|
[da1bafb] | 587 |
|
---|
[35bb2e7] | 588 | rc = STRUCT_TO_USPACE(&data->args, &call->data.args);
|
---|
| 589 | ipc_call_free(call);
|
---|
[bc50fc42] | 590 | if (rc != 0)
|
---|
| 591 | return rc;
|
---|
[da1bafb] | 592 |
|
---|
[2d5a54f3] | 593 | return 0;
|
---|
| 594 | }
|
---|
| 595 |
|
---|
[8b243f2] | 596 | /** Make a synchronous IPC call allowing to transmit the entire payload.
|
---|
| 597 | *
|
---|
[228e490] | 598 | * @param phoneid Phone handle for the call.
|
---|
| 599 | * @param request User-space address of call data with the request.
|
---|
| 600 | * @param reply User-space address of call data where to store the
|
---|
| 601 | * answer.
|
---|
[da1bafb] | 602 | *
|
---|
| 603 | * @return Zero on success or an error code.
|
---|
[8b243f2] | 604 | *
|
---|
| 605 | */
|
---|
[228e490] | 606 | sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request,
|
---|
[51ec40f] | 607 | ipc_data_t *reply)
|
---|
[2d5a54f3] | 608 | {
|
---|
| 609 | phone_t *phone;
|
---|
[c9fff17] | 610 | if (phone_get(phoneid, &phone) != EOK)
|
---|
| 611 | return ENOENT;
|
---|
[228e490] | 612 |
|
---|
[da1bafb] | 613 | call_t *call = ipc_call_alloc(0);
|
---|
[228e490] | 614 | int rc = copy_from_uspace(&call->data.args, &request->args,
|
---|
[35bb2e7] | 615 | sizeof(call->data.args));
|
---|
| 616 | if (rc != 0) {
|
---|
| 617 | ipc_call_free(call);
|
---|
[96b02eb9] | 618 | return (sysarg_t) rc;
|
---|
[35bb2e7] | 619 | }
|
---|
[da1bafb] | 620 |
|
---|
| 621 | int res = request_preprocess(call, phone);
|
---|
| 622 |
|
---|
| 623 | if (!res) {
|
---|
[741fd16] | 624 | #ifdef CONFIG_UDEBUG
|
---|
| 625 | udebug_stoppable_begin();
|
---|
| 626 | #endif
|
---|
[35bb2e7] | 627 | rc = ipc_call_sync(phone, call);
|
---|
[741fd16] | 628 | #ifdef CONFIG_UDEBUG
|
---|
| 629 | udebug_stoppable_end();
|
---|
| 630 | #endif
|
---|
[da1bafb] | 631 |
|
---|
[35bb2e7] | 632 | if (rc != EOK) {
|
---|
[33adc6ce] | 633 | /* The call will be freed by ipc_cleanup(). */
|
---|
[79872cd] | 634 | return rc;
|
---|
[35bb2e7] | 635 | }
|
---|
[da1bafb] | 636 |
|
---|
[35bb2e7] | 637 | process_answer(call);
|
---|
[da1bafb] | 638 | } else
|
---|
[35bb2e7] | 639 | IPC_SET_RETVAL(call->data, res);
|
---|
[da1bafb] | 640 |
|
---|
[35bb2e7] | 641 | rc = STRUCT_TO_USPACE(&reply->args, &call->data.args);
|
---|
| 642 | ipc_call_free(call);
|
---|
[e3c762cd] | 643 | if (rc != 0)
|
---|
| 644 | return rc;
|
---|
[da1bafb] | 645 |
|
---|
[2d5a54f3] | 646 | return 0;
|
---|
| 647 | }
|
---|
| 648 |
|
---|
[97d17fe] | 649 | /** Check that the task did not exceed the allowed limit of asynchronous calls
|
---|
| 650 | * made over a phone.
|
---|
[2d5a54f3] | 651 | *
|
---|
[228e490] | 652 | * @param phone Phone to check the limit against.
|
---|
| 653 | *
|
---|
[da1bafb] | 654 | * @return 0 if limit not reached or -1 if limit exceeded.
|
---|
| 655 | *
|
---|
[2d5a54f3] | 656 | */
|
---|
[97d17fe] | 657 | static int check_call_limit(phone_t *phone)
|
---|
[2d5a54f3] | 658 | {
|
---|
[97d17fe] | 659 | if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS)
|
---|
[2d5a54f3] | 660 | return -1;
|
---|
[da1bafb] | 661 |
|
---|
[2d5a54f3] | 662 | return 0;
|
---|
| 663 | }
|
---|
| 664 |
|
---|
[8b243f2] | 665 | /** Make a fast asynchronous call over IPC.
|
---|
[2d5a54f3] | 666 | *
|
---|
[3209923] | 667 | * This function can only handle four arguments of payload, but is faster than
|
---|
| 668 | * the generic function sys_ipc_call_async_slow().
|
---|
[8b243f2] | 669 | *
|
---|
[da1bafb] | 670 | * @param phoneid Phone handle for the call.
|
---|
[228e490] | 671 | * @param imethod Interface and method of the call.
|
---|
[da1bafb] | 672 | * @param arg1 Service-defined payload argument.
|
---|
| 673 | * @param arg2 Service-defined payload argument.
|
---|
| 674 | * @param arg3 Service-defined payload argument.
|
---|
| 675 | * @param arg4 Service-defined payload argument.
|
---|
| 676 | *
|
---|
| 677 | * @return Call hash on success.
|
---|
| 678 | * @return IPC_CALLRET_FATAL in case of a fatal error.
|
---|
| 679 | * @return IPC_CALLRET_TEMPORARY if there are too many pending
|
---|
| 680 | * asynchronous requests; answers should be handled first.
|
---|
| 681 | *
|
---|
[2d5a54f3] | 682 | */
|
---|
[228e490] | 683 | sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod,
|
---|
[96b02eb9] | 684 | sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
|
---|
[2d5a54f3] | 685 | {
|
---|
[da1bafb] | 686 | phone_t *phone;
|
---|
[c9fff17] | 687 | if (phone_get(phoneid, &phone) != EOK)
|
---|
| 688 | return IPC_CALLRET_FATAL;
|
---|
[228e490] | 689 |
|
---|
[97d17fe] | 690 | if (check_call_limit(phone))
|
---|
| 691 | return IPC_CALLRET_TEMPORARY;
|
---|
[da1bafb] | 692 |
|
---|
| 693 | call_t *call = ipc_call_alloc(0);
|
---|
[228e490] | 694 | IPC_SET_IMETHOD(call->data, imethod);
|
---|
[2d5a54f3] | 695 | IPC_SET_ARG1(call->data, arg1);
|
---|
| 696 | IPC_SET_ARG2(call->data, arg2);
|
---|
[3209923] | 697 | IPC_SET_ARG3(call->data, arg3);
|
---|
| 698 | IPC_SET_ARG4(call->data, arg4);
|
---|
[da1bafb] | 699 |
|
---|
[8498915] | 700 | /*
|
---|
| 701 | * To achieve deterministic behavior, zero out arguments that are beyond
|
---|
| 702 | * the limits of the fast version.
|
---|
| 703 | */
|
---|
| 704 | IPC_SET_ARG5(call->data, 0);
|
---|
[da1bafb] | 705 |
|
---|
| 706 | int res = request_preprocess(call, phone);
|
---|
| 707 |
|
---|
| 708 | if (!res)
|
---|
[7c7aae16] | 709 | ipc_call(phone, call);
|
---|
| 710 | else
|
---|
| 711 | ipc_backsend_err(phone, call, res);
|
---|
[da1bafb] | 712 |
|
---|
[96b02eb9] | 713 | return (sysarg_t) call;
|
---|
[2d5a54f3] | 714 | }
|
---|
| 715 |
|
---|
[8b243f2] | 716 | /** Make an asynchronous IPC call allowing to transmit the entire payload.
|
---|
| 717 | *
|
---|
[da1bafb] | 718 | * @param phoneid Phone handle for the call.
|
---|
| 719 | * @param data Userspace address of call data with the request.
|
---|
| 720 | *
|
---|
| 721 | * @return See sys_ipc_call_async_fast().
|
---|
[2d5a54f3] | 722 | *
|
---|
| 723 | */
|
---|
[96b02eb9] | 724 | sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data)
|
---|
[2d5a54f3] | 725 | {
|
---|
[da1bafb] | 726 | phone_t *phone;
|
---|
[c9fff17] | 727 | if (phone_get(phoneid, &phone) != EOK)
|
---|
| 728 | return IPC_CALLRET_FATAL;
|
---|
[4e49572] | 729 |
|
---|
[97d17fe] | 730 | if (check_call_limit(phone))
|
---|
| 731 | return IPC_CALLRET_TEMPORARY;
|
---|
| 732 |
|
---|
[da1bafb] | 733 | call_t *call = ipc_call_alloc(0);
|
---|
| 734 | int rc = copy_from_uspace(&call->data.args, &data->args,
|
---|
[51ec40f] | 735 | sizeof(call->data.args));
|
---|
[f58af46] | 736 | if (rc != 0) {
|
---|
| 737 | ipc_call_free(call);
|
---|
[96b02eb9] | 738 | return (sysarg_t) rc;
|
---|
[f58af46] | 739 | }
|
---|
[da1bafb] | 740 |
|
---|
| 741 | int res = request_preprocess(call, phone);
|
---|
| 742 |
|
---|
| 743 | if (!res)
|
---|
[7c7aae16] | 744 | ipc_call(phone, call);
|
---|
| 745 | else
|
---|
| 746 | ipc_backsend_err(phone, call, res);
|
---|
[da1bafb] | 747 |
|
---|
[96b02eb9] | 748 | return (sysarg_t) call;
|
---|
[2d5a54f3] | 749 | }
|
---|
| 750 |
|
---|
[da1bafb] | 751 | /** Forward a received call to another destination
|
---|
| 752 | *
|
---|
| 753 | * Common code for both the fast and the slow version.
|
---|
| 754 | *
|
---|
| 755 | * @param callid Hash of the call to forward.
|
---|
| 756 | * @param phoneid Phone handle to use for forwarding.
|
---|
[228e490] | 757 | * @param imethod New interface and method to use for the forwarded call.
|
---|
[da1bafb] | 758 | * @param arg1 New value of the first argument for the forwarded call.
|
---|
| 759 | * @param arg2 New value of the second argument for the forwarded call.
|
---|
| 760 | * @param arg3 New value of the third argument for the forwarded call.
|
---|
| 761 | * @param arg4 New value of the fourth argument for the forwarded call.
|
---|
| 762 | * @param arg5 New value of the fifth argument for the forwarded call.
|
---|
| 763 | * @param mode Flags that specify mode of the forward operation.
|
---|
| 764 | * @param slow If true, arg3, arg4 and arg5 are considered. Otherwise
|
---|
| 765 | * the function considers only the fast version arguments:
|
---|
| 766 | * i.e. arg1 and arg2.
|
---|
| 767 | *
|
---|
| 768 | * @return 0 on succes, otherwise an error code.
|
---|
| 769 | *
|
---|
| 770 | * Warning: Make sure that ARG5 is not rewritten for certain system IPC
|
---|
| 771 | *
|
---|
[2ba7810] | 772 | */
|
---|
[96b02eb9] | 773 | static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid,
|
---|
[228e490] | 774 | sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
|
---|
[96b02eb9] | 775 | sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow)
|
---|
[2ba7810] | 776 | {
|
---|
[da1bafb] | 777 | call_t *call = get_call(callid);
|
---|
[2ba7810] | 778 | if (!call)
|
---|
| 779 | return ENOENT;
|
---|
[48daf64] | 780 |
|
---|
[9f22213] | 781 | call->flags |= IPC_CALL_FORWARDED;
|
---|
[da1bafb] | 782 |
|
---|
| 783 | phone_t *phone;
|
---|
[c9fff17] | 784 | if (phone_get(phoneid, &phone) != EOK) {
|
---|
[2ba7810] | 785 | IPC_SET_RETVAL(call->data, EFORWARD);
|
---|
| 786 | ipc_answer(&TASK->answerbox, call);
|
---|
| 787 | return ENOENT;
|
---|
[c9fff17] | 788 | }
|
---|
[da1bafb] | 789 |
|
---|
[228e490] | 790 | if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) {
|
---|
[2ba7810] | 791 | IPC_SET_RETVAL(call->data, EFORWARD);
|
---|
| 792 | ipc_answer(&TASK->answerbox, call);
|
---|
| 793 | return EPERM;
|
---|
| 794 | }
|
---|
[da1bafb] | 795 |
|
---|
[0dc4258] | 796 | /*
|
---|
[228e490] | 797 | * Userspace is not allowed to change interface and method of system
|
---|
| 798 | * methods on forward, allow changing ARG1, ARG2, ARG3 and ARG4 by
|
---|
| 799 | * means of method, arg1, arg2 and arg3.
|
---|
| 800 | * If the interface and method is immutable, don't change anything.
|
---|
[2ba7810] | 801 | */
|
---|
[228e490] | 802 | if (!method_is_immutable(IPC_GET_IMETHOD(call->data))) {
|
---|
| 803 | if (method_is_system(IPC_GET_IMETHOD(call->data))) {
|
---|
| 804 | if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME)
|
---|
[b61d47d] | 805 | phone_dealloc(IPC_GET_ARG5(call->data));
|
---|
[da1bafb] | 806 |
|
---|
[228e490] | 807 | IPC_SET_ARG1(call->data, imethod);
|
---|
[0dc4258] | 808 | IPC_SET_ARG2(call->data, arg1);
|
---|
[b61d47d] | 809 | IPC_SET_ARG3(call->data, arg2);
|
---|
[da1bafb] | 810 |
|
---|
[48daf64] | 811 | if (slow) {
|
---|
| 812 | IPC_SET_ARG4(call->data, arg3);
|
---|
| 813 | /*
|
---|
| 814 | * For system methods we deliberately don't
|
---|
| 815 | * overwrite ARG5.
|
---|
| 816 | */
|
---|
| 817 | }
|
---|
[0dc4258] | 818 | } else {
|
---|
[228e490] | 819 | IPC_SET_IMETHOD(call->data, imethod);
|
---|
[0dc4258] | 820 | IPC_SET_ARG1(call->data, arg1);
|
---|
[b61d47d] | 821 | IPC_SET_ARG2(call->data, arg2);
|
---|
[48daf64] | 822 | if (slow) {
|
---|
| 823 | IPC_SET_ARG3(call->data, arg3);
|
---|
| 824 | IPC_SET_ARG4(call->data, arg4);
|
---|
| 825 | IPC_SET_ARG5(call->data, arg5);
|
---|
| 826 | }
|
---|
[0dc4258] | 827 | }
|
---|
[2ba7810] | 828 | }
|
---|
[da1bafb] | 829 |
|
---|
[d40a8ff] | 830 | return ipc_forward(call, phone, &TASK->answerbox, mode);
|
---|
[2ba7810] | 831 | }
|
---|
| 832 |
|
---|
[48daf64] | 833 | /** Forward a received call to another destination - fast version.
|
---|
| 834 | *
|
---|
[228e490] | 835 | * In case the original interface and method is a system method, ARG1, ARG2
|
---|
| 836 | * and ARG3 are overwritten in the forwarded message with the new method and
|
---|
| 837 | * the new arg1 and arg2, respectively. Otherwise the IMETHOD, ARG1 and ARG2
|
---|
| 838 | * are rewritten with the new interface and method, arg1 and arg2, respectively.
|
---|
| 839 | * Also note there is a set of immutable methods, for which the new method and
|
---|
| 840 | * arguments are not set and these values are ignored.
|
---|
[da1bafb] | 841 | *
|
---|
| 842 | * @param callid Hash of the call to forward.
|
---|
| 843 | * @param phoneid Phone handle to use for forwarding.
|
---|
[228e490] | 844 | * @param imethod New interface and method to use for the forwarded call.
|
---|
[da1bafb] | 845 | * @param arg1 New value of the first argument for the forwarded call.
|
---|
| 846 | * @param arg2 New value of the second argument for the forwarded call.
|
---|
| 847 | * @param mode Flags that specify mode of the forward operation.
|
---|
| 848 | *
|
---|
| 849 | * @return 0 on succes, otherwise an error code.
|
---|
| 850 | *
|
---|
[48daf64] | 851 | */
|
---|
[96b02eb9] | 852 | sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid,
|
---|
[228e490] | 853 | sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
|
---|
[48daf64] | 854 | {
|
---|
[228e490] | 855 | return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0,
|
---|
[48daf64] | 856 | 0, mode, false);
|
---|
| 857 | }
|
---|
| 858 |
|
---|
| 859 | /** Forward a received call to another destination - slow version.
|
---|
| 860 | *
|
---|
| 861 | * This function is the slow verision of the sys_ipc_forward_fast interface.
|
---|
[228e490] | 862 | * It can copy all five new arguments and the new interface and method from
|
---|
| 863 | * the userspace. It naturally extends the functionality of the fast version.
|
---|
| 864 | * For system methods, it additionally stores the new value of arg3 to ARG4.
|
---|
| 865 | * For non-system methods, it additionally stores the new value of arg3, arg4
|
---|
| 866 | * and arg5, respectively, to ARG3, ARG4 and ARG5, respectively.
|
---|
[da1bafb] | 867 | *
|
---|
| 868 | * @param callid Hash of the call to forward.
|
---|
| 869 | * @param phoneid Phone handle to use for forwarding.
|
---|
| 870 | * @param data Userspace address of the new IPC data.
|
---|
| 871 | * @param mode Flags that specify mode of the forward operation.
|
---|
| 872 | *
|
---|
| 873 | * @return 0 on succes, otherwise an error code.
|
---|
| 874 | *
|
---|
[48daf64] | 875 | */
|
---|
[96b02eb9] | 876 | sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid,
|
---|
[da1bafb] | 877 | ipc_data_t *data, unsigned int mode)
|
---|
[48daf64] | 878 | {
|
---|
| 879 | ipc_data_t newdata;
|
---|
[da1bafb] | 880 | int rc = copy_from_uspace(&newdata.args, &data->args,
|
---|
[48daf64] | 881 | sizeof(newdata.args));
|
---|
[da1bafb] | 882 | if (rc != 0)
|
---|
[96b02eb9] | 883 | return (sysarg_t) rc;
|
---|
[da1bafb] | 884 |
|
---|
[48daf64] | 885 | return sys_ipc_forward_common(callid, phoneid,
|
---|
[228e490] | 886 | IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata),
|
---|
[48daf64] | 887 | IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata),
|
---|
| 888 | IPC_GET_ARG4(newdata), IPC_GET_ARG5(newdata), mode, true);
|
---|
| 889 | }
|
---|
| 890 |
|
---|
[8b243f2] | 891 | /** Answer an IPC call - fast version.
|
---|
| 892 | *
|
---|
| 893 | * This function can handle only two return arguments of payload, but is faster
|
---|
| 894 | * than the generic sys_ipc_answer().
|
---|
| 895 | *
|
---|
[da1bafb] | 896 | * @param callid Hash of the call to be answered.
|
---|
| 897 | * @param retval Return value of the answer.
|
---|
| 898 | * @param arg1 Service-defined return value.
|
---|
| 899 | * @param arg2 Service-defined return value.
|
---|
| 900 | * @param arg3 Service-defined return value.
|
---|
| 901 | * @param arg4 Service-defined return value.
|
---|
| 902 | *
|
---|
| 903 | * @return 0 on success, otherwise an error code.
|
---|
[8b243f2] | 904 | *
|
---|
| 905 | */
|
---|
[96b02eb9] | 906 | sysarg_t sys_ipc_answer_fast(sysarg_t callid, sysarg_t retval,
|
---|
| 907 | sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
|
---|
[2d5a54f3] | 908 | {
|
---|
[897f2e76] | 909 | /* Do not answer notification callids */
|
---|
| 910 | if (callid & IPC_CALLID_NOTIFICATION)
|
---|
| 911 | return 0;
|
---|
[da1bafb] | 912 |
|
---|
| 913 | call_t *call = get_call(callid);
|
---|
[2ba7810] | 914 | if (!call)
|
---|
| 915 | return ENOENT;
|
---|
[da1bafb] | 916 |
|
---|
| 917 | ipc_data_t saved_data;
|
---|
| 918 | bool saved;
|
---|
| 919 |
|
---|
[9f22213] | 920 | if (answer_need_old(call)) {
|
---|
[2ba7810] | 921 | memcpy(&saved_data, &call->data, sizeof(call->data));
|
---|
[da1bafb] | 922 | saved = true;
|
---|
| 923 | } else
|
---|
| 924 | saved = false;
|
---|
| 925 |
|
---|
[2d5a54f3] | 926 | IPC_SET_RETVAL(call->data, retval);
|
---|
| 927 | IPC_SET_ARG1(call->data, arg1);
|
---|
| 928 | IPC_SET_ARG2(call->data, arg2);
|
---|
[b74959bd] | 929 | IPC_SET_ARG3(call->data, arg3);
|
---|
| 930 | IPC_SET_ARG4(call->data, arg4);
|
---|
[da1bafb] | 931 |
|
---|
[8498915] | 932 | /*
|
---|
| 933 | * To achieve deterministic behavior, zero out arguments that are beyond
|
---|
| 934 | * the limits of the fast version.
|
---|
| 935 | */
|
---|
| 936 | IPC_SET_ARG5(call->data, 0);
|
---|
[da1bafb] | 937 | int rc = answer_preprocess(call, saved ? &saved_data : NULL);
|
---|
| 938 |
|
---|
[2d5a54f3] | 939 | ipc_answer(&TASK->answerbox, call);
|
---|
[7c23af9] | 940 | return rc;
|
---|
[2d5a54f3] | 941 | }
|
---|
| 942 |
|
---|
[8b243f2] | 943 | /** Answer an IPC call.
|
---|
| 944 | *
|
---|
[da1bafb] | 945 | * @param callid Hash of the call to be answered.
|
---|
| 946 | * @param data Userspace address of call data with the answer.
|
---|
| 947 | *
|
---|
| 948 | * @return 0 on success, otherwise an error code.
|
---|
[8b243f2] | 949 | *
|
---|
| 950 | */
|
---|
[96b02eb9] | 951 | sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data)
|
---|
[2d5a54f3] | 952 | {
|
---|
[897f2e76] | 953 | /* Do not answer notification callids */
|
---|
| 954 | if (callid & IPC_CALLID_NOTIFICATION)
|
---|
| 955 | return 0;
|
---|
[da1bafb] | 956 |
|
---|
| 957 | call_t *call = get_call(callid);
|
---|
[2ba7810] | 958 | if (!call)
|
---|
| 959 | return ENOENT;
|
---|
[da1bafb] | 960 |
|
---|
| 961 | ipc_data_t saved_data;
|
---|
| 962 | bool saved;
|
---|
| 963 |
|
---|
[9f22213] | 964 | if (answer_need_old(call)) {
|
---|
[2ba7810] | 965 | memcpy(&saved_data, &call->data, sizeof(call->data));
|
---|
[da1bafb] | 966 | saved = true;
|
---|
| 967 | } else
|
---|
| 968 | saved = false;
|
---|
| 969 |
|
---|
| 970 | int rc = copy_from_uspace(&call->data.args, &data->args,
|
---|
[51ec40f] | 971 | sizeof(call->data.args));
|
---|
[e3c762cd] | 972 | if (rc != 0)
|
---|
| 973 | return rc;
|
---|
[da1bafb] | 974 |
|
---|
| 975 | rc = answer_preprocess(call, saved ? &saved_data : NULL);
|
---|
[2d5a54f3] | 976 |
|
---|
| 977 | ipc_answer(&TASK->answerbox, call);
|
---|
[7c23af9] | 978 | return rc;
|
---|
[2d5a54f3] | 979 | }
|
---|
| 980 |
|
---|
[8b243f2] | 981 | /** Hang up a phone.
|
---|
[2d5a54f3] | 982 | *
|
---|
[da1bafb] | 983 | * @param Phone handle of the phone to be hung up.
|
---|
| 984 | *
|
---|
| 985 | * @return 0 on success or an error code.
|
---|
[8b243f2] | 986 | *
|
---|
[fbcfd458] | 987 | */
|
---|
[96b02eb9] | 988 | sysarg_t sys_ipc_hangup(sysarg_t phoneid)
|
---|
[fbcfd458] | 989 | {
|
---|
| 990 | phone_t *phone;
|
---|
[da1bafb] | 991 |
|
---|
[c9fff17] | 992 | if (phone_get(phoneid, &phone) != EOK)
|
---|
| 993 | return ENOENT;
|
---|
[da1bafb] | 994 |
|
---|
[d8f7362] | 995 | if (ipc_phone_hangup(phone))
|
---|
[fbcfd458] | 996 | return -1;
|
---|
[da1bafb] | 997 |
|
---|
[fbcfd458] | 998 | return 0;
|
---|
| 999 | }
|
---|
| 1000 |
|
---|
[8b243f2] | 1001 | /** Wait for an incoming IPC call or an answer.
|
---|
[fbcfd458] | 1002 | *
|
---|
[da1bafb] | 1003 | * @param calldata Pointer to buffer where the call/answer data is stored.
|
---|
| 1004 | * @param usec Timeout. See waitq_sleep_timeout() for explanation.
|
---|
| 1005 | * @param flags Select mode of sleep operation. See waitq_sleep_timeout()
|
---|
| 1006 | * for explanation.
|
---|
| 1007 | *
|
---|
| 1008 | * @return Hash of the call.
|
---|
| 1009 | * If IPC_CALLID_NOTIFICATION bit is set in the hash, the
|
---|
| 1010 | * call is a notification. IPC_CALLID_ANSWERED denotes an
|
---|
| 1011 | * answer.
|
---|
[bd5a663] | 1012 | *
|
---|
[2d5a54f3] | 1013 | */
|
---|
[96b02eb9] | 1014 | sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
|
---|
[da1bafb] | 1015 | unsigned int flags)
|
---|
[2d5a54f3] | 1016 | {
|
---|
| 1017 | call_t *call;
|
---|
[da1bafb] | 1018 |
|
---|
[741fd16] | 1019 | restart:
|
---|
[da1bafb] | 1020 |
|
---|
[741fd16] | 1021 | #ifdef CONFIG_UDEBUG
|
---|
| 1022 | udebug_stoppable_begin();
|
---|
[da1bafb] | 1023 | #endif
|
---|
| 1024 |
|
---|
[51ec40f] | 1025 | call = ipc_wait_for_call(&TASK->answerbox, usec,
|
---|
| 1026 | flags | SYNCH_FLAGS_INTERRUPTIBLE);
|
---|
[da1bafb] | 1027 |
|
---|
[741fd16] | 1028 | #ifdef CONFIG_UDEBUG
|
---|
| 1029 | udebug_stoppable_end();
|
---|
| 1030 | #endif
|
---|
[da1bafb] | 1031 |
|
---|
[9f22213] | 1032 | if (!call)
|
---|
| 1033 | return 0;
|
---|
[da1bafb] | 1034 |
|
---|
[5626277] | 1035 | if (call->flags & IPC_CALL_NOTIF) {
|
---|
[43752b6] | 1036 | /* Set in_phone_hash to the interrupt counter */
|
---|
[0c1a5d8a] | 1037 | call->data.phone = (void *) call->priv;
|
---|
[43752b6] | 1038 |
|
---|
| 1039 | STRUCT_TO_USPACE(calldata, &call->data);
|
---|
[da1bafb] | 1040 |
|
---|
[5626277] | 1041 | ipc_call_free(call);
|
---|
| 1042 |
|
---|
[96b02eb9] | 1043 | return ((sysarg_t) call) | IPC_CALLID_NOTIFICATION;
|
---|
[5626277] | 1044 | }
|
---|
[da1bafb] | 1045 |
|
---|
[2d5a54f3] | 1046 | if (call->flags & IPC_CALL_ANSWERED) {
|
---|
[7c7aae16] | 1047 | process_answer(call);
|
---|
[da1bafb] | 1048 |
|
---|
[fbcfd458] | 1049 | if (call->flags & IPC_CALL_DISCARD_ANSWER) {
|
---|
| 1050 | ipc_call_free(call);
|
---|
| 1051 | goto restart;
|
---|
| 1052 | }
|
---|
[da1bafb] | 1053 |
|
---|
[fbcfd458] | 1054 | STRUCT_TO_USPACE(&calldata->args, &call->data.args);
|
---|
[2d5a54f3] | 1055 | ipc_call_free(call);
|
---|
[da1bafb] | 1056 |
|
---|
[96b02eb9] | 1057 | return ((sysarg_t) call) | IPC_CALLID_ANSWERED;
|
---|
[2d5a54f3] | 1058 | }
|
---|
[da1bafb] | 1059 |
|
---|
[2d5a54f3] | 1060 | if (process_request(&TASK->answerbox, call))
|
---|
| 1061 | goto restart;
|
---|
[da1bafb] | 1062 |
|
---|
[7c7aae16] | 1063 | /* Include phone address('id') of the caller in the request,
|
---|
| 1064 | * copy whole call->data, not only call->data.args */
|
---|
[bd55bbb] | 1065 | if (STRUCT_TO_USPACE(calldata, &call->data)) {
|
---|
[e06da7e] | 1066 | /*
|
---|
| 1067 | * The callee will not receive this call and no one else has
|
---|
| 1068 | * a chance to answer it. Reply with the EPARTY error code.
|
---|
[b11ee88] | 1069 | */
|
---|
[e06da7e] | 1070 | ipc_data_t saved_data;
|
---|
[da1bafb] | 1071 | bool saved;
|
---|
| 1072 |
|
---|
[e06da7e] | 1073 | if (answer_need_old(call)) {
|
---|
| 1074 | memcpy(&saved_data, &call->data, sizeof(call->data));
|
---|
[da1bafb] | 1075 | saved = true;
|
---|
| 1076 | } else
|
---|
| 1077 | saved = false;
|
---|
[e06da7e] | 1078 |
|
---|
| 1079 | IPC_SET_RETVAL(call->data, EPARTY);
|
---|
[da1bafb] | 1080 | (void) answer_preprocess(call, saved ? &saved_data : NULL);
|
---|
[e06da7e] | 1081 | ipc_answer(&TASK->answerbox, call);
|
---|
[bd55bbb] | 1082 | return 0;
|
---|
| 1083 | }
|
---|
[da1bafb] | 1084 |
|
---|
[96b02eb9] | 1085 | return (sysarg_t) call;
|
---|
[2d5a54f3] | 1086 | }
|
---|
[5626277] | 1087 |
|
---|
[da1bafb] | 1088 | /** Interrupt one thread from sys_ipc_wait_for_call().
|
---|
| 1089 | *
|
---|
| 1090 | */
|
---|
[96b02eb9] | 1091 | sysarg_t sys_ipc_poke(void)
|
---|
[057d21a] | 1092 | {
|
---|
[da1bafb] | 1093 | waitq_unsleep(&TASK->answerbox.wq);
|
---|
[057d21a] | 1094 | return EOK;
|
---|
| 1095 | }
|
---|
| 1096 |
|
---|
[8b243f2] | 1097 | /** Connect an IRQ handler to a task.
|
---|
[2b017ba] | 1098 | *
|
---|
[228e490] | 1099 | * @param inr IRQ number.
|
---|
| 1100 | * @param devno Device number.
|
---|
| 1101 | * @param imethod Interface and method to be associated with the notification.
|
---|
| 1102 | * @param ucode Uspace pointer to the top-half pseudocode.
|
---|
[da1bafb] | 1103 | *
|
---|
| 1104 | * @return EPERM or a return code returned by ipc_irq_register().
|
---|
[2b017ba] | 1105 | *
|
---|
| 1106 | */
|
---|
[8add9ca5] | 1107 | sysarg_t sys_register_irq(inr_t inr, devno_t devno, sysarg_t imethod,
|
---|
[51ec40f] | 1108 | irq_code_t *ucode)
|
---|
[5626277] | 1109 | {
|
---|
[2bb8648] | 1110 | if (!(cap_get(TASK) & CAP_IRQ_REG))
|
---|
| 1111 | return EPERM;
|
---|
[da1bafb] | 1112 |
|
---|
[228e490] | 1113 | return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode);
|
---|
[5626277] | 1114 | }
|
---|
| 1115 |
|
---|
[8b243f2] | 1116 | /** Disconnect an IRQ handler from a task.
|
---|
| 1117 | *
|
---|
[da1bafb] | 1118 | * @param inr IRQ number.
|
---|
| 1119 | * @param devno Device number.
|
---|
| 1120 | *
|
---|
| 1121 | * @return Zero on success or EPERM on error.
|
---|
[2b017ba] | 1122 | *
|
---|
| 1123 | */
|
---|
[8add9ca5] | 1124 | sysarg_t sys_unregister_irq(inr_t inr, devno_t devno)
|
---|
[5626277] | 1125 | {
|
---|
[2bb8648] | 1126 | if (!(cap_get(TASK) & CAP_IRQ_REG))
|
---|
| 1127 | return EPERM;
|
---|
[da1bafb] | 1128 |
|
---|
[2b017ba] | 1129 | ipc_irq_unregister(&TASK->answerbox, inr, devno);
|
---|
[da1bafb] | 1130 |
|
---|
[5626277] | 1131 | return 0;
|
---|
| 1132 | }
|
---|
[b45c443] | 1133 |
|
---|
[6b10dab] | 1134 | #ifdef __32_BITS__
|
---|
[9a1b20c] | 1135 |
|
---|
[6b10dab] | 1136 | /** Syscall connect to a task by ID (32 bits)
|
---|
[da1bafb] | 1137 | *
|
---|
| 1138 | * @return Phone id on success, or negative error code.
|
---|
[9a1b20c] | 1139 | *
|
---|
| 1140 | */
|
---|
[6b10dab] | 1141 | sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid)
|
---|
[9a1b20c] | 1142 | {
|
---|
| 1143 | #ifdef CONFIG_UDEBUG
|
---|
[6b10dab] | 1144 | sysarg64_t taskid;
|
---|
| 1145 | int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t));
|
---|
[9a1b20c] | 1146 | if (rc != 0)
|
---|
[96b02eb9] | 1147 | return (sysarg_t) rc;
|
---|
[da1bafb] | 1148 |
|
---|
[6b10dab] | 1149 | return ipc_connect_kbox((task_id_t) taskid);
|
---|
[9a1b20c] | 1150 | #else
|
---|
[96b02eb9] | 1151 | return (sysarg_t) ENOTSUP;
|
---|
[9a1b20c] | 1152 | #endif
|
---|
| 1153 | }
|
---|
| 1154 |
|
---|
[6b10dab] | 1155 | #endif /* __32_BITS__ */
|
---|
| 1156 |
|
---|
| 1157 | #ifdef __64_BITS__
|
---|
| 1158 |
|
---|
| 1159 | /** Syscall connect to a task by ID (64 bits)
|
---|
| 1160 | *
|
---|
| 1161 | * @return Phone id on success, or negative error code.
|
---|
| 1162 | *
|
---|
| 1163 | */
|
---|
| 1164 | sysarg_t sys_ipc_connect_kbox(sysarg_t taskid)
|
---|
| 1165 | {
|
---|
| 1166 | #ifdef CONFIG_UDEBUG
|
---|
| 1167 | return ipc_connect_kbox((task_id_t) taskid);
|
---|
| 1168 | #else
|
---|
| 1169 | return (sysarg_t) ENOTSUP;
|
---|
| 1170 | #endif
|
---|
| 1171 | }
|
---|
| 1172 |
|
---|
| 1173 | #endif /* __64_BITS__ */
|
---|
| 1174 |
|
---|
[cc73a8a1] | 1175 | /** @}
|
---|
[b45c443] | 1176 | */
|
---|