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