Changeset 91b60499 in mainline for kernel/generic/src/ipc/sysipc.c
- Timestamp:
- 2017-09-30T06:29:42Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 300f4c4
- Parents:
- d076f16 (diff), 6636fb19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
rd076f16 r91b60499 85 85 { 86 86 switch (imethod) { 87 case IPC_M_CONNECTION_CLONE:88 case IPC_M_CLONE_ESTABLISH:89 87 case IPC_M_PHONE_HUNGUP: 90 88 /* This message is meant only for the original recipient. */ … … 135 133 { 136 134 switch (IPC_GET_IMETHOD(call->data)) { 137 case IPC_M_CONNECTION_CLONE:138 case IPC_M_CLONE_ESTABLISH:139 135 case IPC_M_CONNECT_TO_ME: 140 136 case IPC_M_CONNECT_ME_TO: … … 264 260 /** Make a call over IPC and wait for reply. 265 261 * 266 * @param phoneid Phonehandle for the call.267 * @param data[inout] Structure with request/reply data.268 * @param priv Value to be stored in call->priv.262 * @param handle Phone capability handle for the call. 263 * @param data[inout] Structure with request/reply data. 264 * @param priv Value to be stored in call->priv. 269 265 * 270 266 * @return EOK on success. … … 272 268 * 273 269 */ 274 int ipc_req_internal( int phoneid, ipc_data_t *data, sysarg_t priv)275 { 276 phone_t *phone;277 if ( phone_get(phoneid, &phone) != EOK)270 int ipc_req_internal(cap_handle_t handle, ipc_data_t *data, sysarg_t priv) 271 { 272 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 273 if (!kobj->phone) 278 274 return ENOENT; 279 275 … … 282 278 memcpy(call->data.args, data->args, sizeof(data->args)); 283 279 284 int rc = request_preprocess(call, phone);280 int rc = request_preprocess(call, kobj->phone); 285 281 if (!rc) { 286 282 #ifdef CONFIG_UDEBUG … … 289 285 290 286 ipc_call_hold(call); 291 rc = ipc_call_sync( phone, call);287 rc = ipc_call_sync(kobj->phone, call); 292 288 spinlock_lock(&call->forget_lock); 293 289 bool forgotten = call->forget; … … 316 312 assert(rc == EINTR); 317 313 } 318 return rc; 314 kobject_put(kobj); 315 return rc; 319 316 } 320 317 … … 325 322 memcpy(data->args, call->data.args, sizeof(data->args)); 326 323 ipc_call_free(call); 324 kobject_put(kobj); 327 325 328 326 return EOK; … … 350 348 * the generic function sys_ipc_call_async_slow(). 351 349 * 352 * @param phoneid Phonehandle for the call.353 * @param imethod Interface and method of the call.354 * @param arg1 Service-defined payload argument.355 * @param arg2 Service-defined payload argument.356 * @param arg3 Service-defined payload argument.357 * @param arg4 Service-defined payload argument.350 * @param handle Phone capability handle for the call. 351 * @param imethod Interface and method of the call. 352 * @param arg1 Service-defined payload argument. 353 * @param arg2 Service-defined payload argument. 354 * @param arg3 Service-defined payload argument. 355 * @param arg4 Service-defined payload argument. 358 356 * 359 357 * @return Call hash on success. … … 363 361 * 364 362 */ 365 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod,363 sysarg_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod, 366 364 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 367 365 { 368 phone_t *phone;369 if ( phone_get(phoneid, &phone) != EOK)366 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 367 if (!kobj) 370 368 return IPC_CALLRET_FATAL; 371 369 372 if (check_call_limit(phone)) 370 if (check_call_limit(kobj->phone)) { 371 kobject_put(kobj); 373 372 return IPC_CALLRET_TEMPORARY; 373 } 374 374 375 375 call_t *call = ipc_call_alloc(0); … … 386 386 IPC_SET_ARG5(call->data, 0); 387 387 388 int res = request_preprocess(call, phone);388 int res = request_preprocess(call, kobj->phone); 389 389 390 390 if (!res) 391 ipc_call( phone, call);391 ipc_call(kobj->phone, call); 392 392 else 393 ipc_backsend_err(phone, call, res); 394 393 ipc_backsend_err(kobj->phone, call, res); 394 395 kobject_put(kobj); 395 396 return (sysarg_t) call; 396 397 } … … 398 399 /** Make an asynchronous IPC call allowing to transmit the entire payload. 399 400 * 400 * @param phoneid Phone handlefor the call.401 * @param handle Phone capability for the call. 401 402 * @param data Userspace address of call data with the request. 402 403 * … … 404 405 * 405 406 */ 406 sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data)407 { 408 phone_t *phone;409 if ( phone_get(phoneid, &phone) != EOK)407 sysarg_t sys_ipc_call_async_slow(sysarg_t handle, ipc_data_t *data) 408 { 409 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 410 if (!kobj) 410 411 return IPC_CALLRET_FATAL; 411 412 412 if (check_call_limit(phone)) 413 if (check_call_limit(kobj->phone)) { 414 kobject_put(kobj); 413 415 return IPC_CALLRET_TEMPORARY; 416 } 414 417 415 418 call_t *call = ipc_call_alloc(0); … … 418 421 if (rc != 0) { 419 422 ipc_call_free(call); 423 kobject_put(kobj); 420 424 return (sysarg_t) rc; 421 425 } 422 426 423 int res = request_preprocess(call, phone);427 int res = request_preprocess(call, kobj->phone); 424 428 425 429 if (!res) 426 ipc_call( phone, call);430 ipc_call(kobj->phone, call); 427 431 else 428 ipc_backsend_err(phone, call, res); 429 432 ipc_backsend_err(kobj->phone, call, res); 433 434 kobject_put(kobj); 430 435 return (sysarg_t) call; 431 436 } … … 435 440 * Common code for both the fast and the slow version. 436 441 * 437 * @param callid Hash of the call to forward.438 * @param phoneid Phone handleto use for forwarding.439 * @param imethod New interface and method to use for the forwarded call.440 * @param arg1 New value of the first argument for the forwarded call.441 * @param arg2 New value of the second argument for the forwarded call.442 * @param arg3 New value of the third argument for the forwarded call.443 * @param arg4 New value of the fourth argument for the forwarded call.444 * @param arg5 New value of the fifth argument for the forwarded call.445 * @param mode Flags that specify mode of the forward operation.446 * @param slow If true, arg3, arg4 and arg5 are considered. Otherwise447 * the function considers only the fast version arguments:448 * i.e. arg1 and arg2.442 * @param callid Hash of the call to forward. 443 * @param handle Phone capability to use for forwarding. 444 * @param imethod New interface and method to use for the forwarded call. 445 * @param arg1 New value of the first argument for the forwarded call. 446 * @param arg2 New value of the second argument for the forwarded call. 447 * @param arg3 New value of the third argument for the forwarded call. 448 * @param arg4 New value of the fourth argument for the forwarded call. 449 * @param arg5 New value of the fifth argument for the forwarded call. 450 * @param mode Flags that specify mode of the forward operation. 451 * @param slow If true, arg3, arg4 and arg5 are considered. Otherwise 452 * the function considers only the fast version arguments: 453 * i.e. arg1 and arg2. 449 454 * 450 455 * @return 0 on succes, otherwise an error code. … … 453 458 * 454 459 */ 455 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid,460 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t handle, 456 461 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 457 462 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) … … 468 473 bool after_forward = false; 469 474 int rc; 470 phone_t *phone; 471 472 if ( phone_get(phoneid, &phone) != EOK) {475 476 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 477 if (!kobj) { 473 478 rc = ENOENT; 474 479 goto error; … … 516 521 } 517 522 518 rc = ipc_forward(call, phone, &TASK->answerbox, mode);523 rc = ipc_forward(call, kobj->phone, &TASK->answerbox, mode); 519 524 if (rc != EOK) { 520 525 after_forward = true; … … 522 527 } 523 528 529 kobject_put(kobj); 524 530 return EOK; 525 531 … … 532 538 ipc_answer(&TASK->answerbox, call); 533 539 540 if (kobj) 541 kobject_put(kobj); 534 542 return rc; 535 543 } … … 544 552 * arguments are not set and these values are ignored. 545 553 * 546 * @param callid Hash of the call to forward.547 * @param phoneidPhone handle to use for forwarding.548 * @param imethod New interface and method to use for the forwarded call.549 * @param arg1 New value of the first argument for the forwarded call.550 * @param arg2 New value of the second argument for the forwarded call.551 * @param mode Flags that specify mode of the forward operation.554 * @param callid Hash of the call to forward. 555 * @param handle Phone handle to use for forwarding. 556 * @param imethod New interface and method to use for the forwarded call. 557 * @param arg1 New value of the first argument for the forwarded call. 558 * @param arg2 New value of the second argument for the forwarded call. 559 * @param mode Flags that specify mode of the forward operation. 552 560 * 553 561 * @return 0 on succes, otherwise an error code. 554 562 * 555 563 */ 556 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid,564 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t handle, 557 565 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 558 566 { 559 return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0,567 return sys_ipc_forward_common(callid, handle, imethod, arg1, arg2, 0, 0, 560 568 0, mode, false); 561 569 } … … 571 579 * 572 580 * @param callid Hash of the call to forward. 573 * @param phoneidPhone handle to use for forwarding.581 * @param handle Phone handle to use for forwarding. 574 582 * @param data Userspace address of the new IPC data. 575 583 * @param mode Flags that specify mode of the forward operation. … … 578 586 * 579 587 */ 580 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid,588 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t handle, 581 589 ipc_data_t *data, unsigned int mode) 582 590 { … … 587 595 return (sysarg_t) rc; 588 596 589 return sys_ipc_forward_common(callid, phoneid,597 return sys_ipc_forward_common(callid, handle, 590 598 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 591 599 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), … … 685 693 /** Hang up a phone. 686 694 * 687 * @param Phonehandle of the phone to be hung up.695 * @param handle Phone capability handle of the phone to be hung up. 688 696 * 689 697 * @return 0 on success or an error code. 690 698 * 691 699 */ 692 sysarg_t sys_ipc_hangup(sysarg_t phoneid) 693 { 694 phone_t *phone; 695 696 if (phone_get(phoneid, &phone) != EOK) 700 sysarg_t sys_ipc_hangup(sysarg_t handle) 701 { 702 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); 703 if (!kobj) 697 704 return ENOENT; 698 705 699 if (ipc_phone_hangup(phone)) 706 if (ipc_phone_hangup(kobj->phone)) { 707 kobject_put(kobj); 700 708 return -1; 701 709 } 710 711 kobject_put(kobj); 702 712 return 0; 703 713 } … … 802 812 * 803 813 * @param inr IRQ number. 804 * @param devno Device number.805 814 * @param imethod Interface and method to be associated with the notification. 806 815 * @param ucode Uspace pointer to the top-half pseudocode. 807 816 * 808 * @return EPERM or a return code returned by ipc_irq_subscribe(). 809 * 810 */ 811 sysarg_t sys_ipc_irq_subscribe(inr_t inr, devno_t devno, sysarg_t imethod, 812 irq_code_t *ucode) 817 * @return IRQ kernel object capability 818 * @return EPERM 819 * @return Error code returned by ipc_irq_subscribe(). 820 * 821 */ 822 sysarg_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode) 813 823 { 814 824 if (!(perm_get(TASK) & PERM_IRQ_REG)) 815 825 return EPERM; 816 826 817 return ipc_irq_subscribe(&TASK->answerbox, inr, devno,imethod, ucode);827 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode); 818 828 } 819 829 … … 826 836 * 827 837 */ 828 sysarg_t sys_ipc_irq_unsubscribe( inr_t inr, devno_t devno)838 sysarg_t sys_ipc_irq_unsubscribe(sysarg_t cap) 829 839 { 830 840 if (!(perm_get(TASK) & PERM_IRQ_REG)) 831 841 return EPERM; 832 842 833 ipc_irq_unsubscribe(&TASK->answerbox, inr, devno);843 ipc_irq_unsubscribe(&TASK->answerbox, cap); 834 844 835 845 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.