Changeset a35b458 in mainline for kernel/generic/src/ipc/sysipc.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
r3061bc1 ra35b458 69 69 if (imethod <= IPC_M_LAST_SYSTEM) 70 70 return true; 71 71 72 72 return false; 73 73 } … … 207 207 mutex_unlock(&phone->lock); 208 208 } 209 209 210 210 if (!olddata) 211 211 return rc; … … 242 242 (call->flags & IPC_CALL_FORWARDED)) 243 243 IPC_SET_RETVAL(call->data, EFORWARD); 244 244 245 245 SYSIPC_OP(answer_process, call); 246 246 } … … 276 276 if (!kobj->phone) 277 277 return ENOENT; 278 278 279 279 call_t *call = ipc_call_alloc(0); 280 280 call->priv = priv; 281 281 memcpy(call->data.args, data->args, sizeof(data->args)); 282 282 283 283 errno_t rc = request_preprocess(call, kobj->phone); 284 284 if (!rc) { … … 322 322 } else 323 323 IPC_SET_RETVAL(call->data, rc); 324 324 325 325 memcpy(data->args, call->data.args, sizeof(data->args)); 326 326 kobject_put(call->kobject); 327 327 kobject_put(kobj); 328 328 329 329 return EOK; 330 330 } … … 342 342 if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS) 343 343 return -1; 344 344 345 345 return 0; 346 346 } … … 368 368 if (!kobj) 369 369 return ENOENT; 370 370 371 371 if (check_call_limit(kobj->phone)) { 372 372 kobject_put(kobj); 373 373 return ELIMIT; 374 374 } 375 375 376 376 call_t *call = ipc_call_alloc(0); 377 377 IPC_SET_IMETHOD(call->data, imethod); … … 379 379 IPC_SET_ARG2(call->data, arg2); 380 380 IPC_SET_ARG3(call->data, arg3); 381 381 382 382 /* 383 383 * To achieve deterministic behavior, zero out arguments that are beyond … … 388 388 /* Set the user-defined label */ 389 389 call->data.label = label; 390 390 391 391 errno_t res = request_preprocess(call, kobj->phone); 392 392 393 393 if (!res) 394 394 ipc_call(kobj->phone, call); 395 395 else 396 396 ipc_backsend_err(kobj->phone, call, res); 397 397 398 398 kobject_put(kobj); 399 399 return EOK; … … 432 432 /* Set the user-defined label */ 433 433 call->data.label = label; 434 434 435 435 errno_t res = request_preprocess(call, kobj->phone); 436 436 437 437 if (!res) 438 438 ipc_call(kobj->phone, call); 439 439 else 440 440 ipc_backsend_err(kobj->phone, call, res); 441 441 442 442 kobject_put(kobj); 443 443 return EOK; … … 473 473 if (!ckobj) 474 474 return ENOENT; 475 475 476 476 call_t *call = ckobj->call; 477 477 … … 480 480 if (need_old) 481 481 old = call->data; 482 482 483 483 bool after_forward = false; 484 484 errno_t rc; … … 489 489 goto error; 490 490 } 491 491 492 492 if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) { 493 493 rc = EPERM; 494 494 goto error; 495 495 } 496 496 497 497 call->flags |= IPC_CALL_FORWARDED; 498 498 499 499 /* 500 500 * User space is not allowed to change interface and method of system … … 507 507 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) 508 508 phone_dealloc(IPC_GET_ARG5(call->data)); 509 509 510 510 IPC_SET_ARG1(call->data, imethod); 511 511 IPC_SET_ARG2(call->data, arg1); 512 512 IPC_SET_ARG3(call->data, arg2); 513 513 514 514 if (slow) 515 515 IPC_SET_ARG4(call->data, arg3); 516 516 517 517 /* 518 518 * For system methods we deliberately don't … … 530 530 } 531 531 } 532 532 533 533 rc = ipc_forward(call, pkobj->phone, &TASK->answerbox, mode); 534 534 if (rc != EOK) { … … 609 609 if (rc != EOK) 610 610 return (sys_errno_t) rc; 611 611 612 612 return sys_ipc_forward_common(chandle, phandle, 613 613 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), … … 637 637 if (!kobj) 638 638 return ENOENT; 639 639 640 640 call_t *call = kobj->call; 641 641 642 642 ipc_data_t saved_data; 643 643 bool saved; 644 644 645 645 if (answer_need_old(call)) { 646 646 memcpy(&saved_data, &call->data, sizeof(call->data)); … … 648 648 } else 649 649 saved = false; 650 650 651 651 IPC_SET_RETVAL(call->data, retval); 652 652 IPC_SET_ARG1(call->data, arg1); … … 654 654 IPC_SET_ARG3(call->data, arg3); 655 655 IPC_SET_ARG4(call->data, arg4); 656 656 657 657 /* 658 658 * To achieve deterministic behavior, zero out arguments that are beyond … … 661 661 IPC_SET_ARG5(call->data, 0); 662 662 errno_t rc = answer_preprocess(call, saved ? &saved_data : NULL); 663 663 664 664 ipc_answer(&TASK->answerbox, call); 665 665 … … 683 683 if (!kobj) 684 684 return ENOENT; 685 685 686 686 call_t *call = kobj->call; 687 687 688 688 ipc_data_t saved_data; 689 689 bool saved; 690 690 691 691 if (answer_need_old(call)) { 692 692 memcpy(&saved_data, &call->data, sizeof(call->data)); … … 694 694 } else 695 695 saved = false; 696 696 697 697 errno_t rc = copy_from_uspace(&call->data.args, &data->args, 698 698 sizeof(call->data.args)); … … 704 704 return rc; 705 705 } 706 706 707 707 rc = answer_preprocess(call, saved ? &saved_data : NULL); 708 708 709 709 ipc_answer(&TASK->answerbox, call); 710 710 … … 727 727 if (!kobj) 728 728 return ENOENT; 729 729 730 730 errno_t rc = ipc_phone_hangup(kobj->phone); 731 731 kobject_put(kobj); … … 746 746 { 747 747 call_t *call; 748 748 749 749 restart: 750 750 751 751 #ifdef CONFIG_UDEBUG 752 752 udebug_stoppable_begin(); 753 753 #endif 754 754 755 755 call = ipc_wait_for_call(&TASK->answerbox, usec, 756 756 flags | SYNCH_FLAGS_INTERRUPTIBLE); 757 757 758 758 #ifdef CONFIG_UDEBUG 759 759 udebug_stoppable_end(); … … 766 766 return EOK; 767 767 } 768 768 769 769 call->data.flags = call->flags; 770 770 if (call->flags & IPC_CALL_NOTIF) { 771 771 /* Set in_phone_hash to the interrupt counter */ 772 772 call->data.phone = (void *) call->priv; 773 773 774 774 call->data.cap_handle = CAP_NIL; 775 775 776 776 STRUCT_TO_USPACE(calldata, &call->data); 777 777 kobject_put(call->kobject); 778 778 779 779 return EOK; 780 780 } 781 781 782 782 if (call->flags & IPC_CALL_ANSWERED) { 783 783 process_answer(call); 784 784 785 785 if (call->flags & IPC_CALL_DISCARD_ANSWER) { 786 786 kobject_put(call->kobject); … … 789 789 790 790 call->data.cap_handle = CAP_NIL; 791 791 792 792 STRUCT_TO_USPACE(calldata, &call->data); 793 793 kobject_put(call->kobject); 794 794 795 795 return EOK; 796 796 } 797 797 798 798 if (process_request(&TASK->answerbox, call)) 799 799 goto restart; 800 800 801 801 cap_handle_t handle; 802 802 errno_t rc = cap_alloc(TASK, &handle); … … 804 804 goto error; 805 805 } 806 806 807 807 call->data.cap_handle = handle; 808 808 … … 871 871 if (!(perm_get(TASK) & PERM_IRQ_REG)) 872 872 return EPERM; 873 873 874 874 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode, uspace_handle); 875 875 } … … 887 887 if (!(perm_get(TASK) & PERM_IRQ_REG)) 888 888 return EPERM; 889 889 890 890 ipc_irq_unsubscribe(&TASK->answerbox, cap); 891 891 892 892 return 0; 893 893 } … … 903 903 task_id_t taskid; 904 904 cap_handle_t phone; 905 905 906 906 errno_t rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(task_id_t)); 907 907 if (rc == EOK) { 908 908 rc = ipc_connect_kbox((task_id_t) taskid, &phone); 909 909 } 910 910 911 911 if (rc == EOK) { 912 912 rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t)); … … 916 916 } 917 917 } 918 918 919 919 return (sys_errno_t) rc; 920 920 #else
Note:
See TracChangeset
for help on using the changeset viewer.