Changes in kernel/generic/src/ipc/sysipc.c [addbce4:a53ed3a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
raddbce4 ra53ed3a 155 155 * @param olddata Saved data of the request. 156 156 * 157 * @return Return EOK on success or a negativeerror code.158 * 159 */ 160 int answer_preprocess(call_t *answer, ipc_data_t *olddata)161 { 162 int rc = EOK;157 * @return Return EOK on success or an error code. 158 * 159 */ 160 errno_t answer_preprocess(call_t *answer, ipc_data_t *olddata) 161 { 162 errno_t rc = EOK; 163 163 164 164 spinlock_lock(&answer->forget_lock); … … 194 194 spinlock_unlock(&answer->forget_lock); 195 195 196 if (( native_t) IPC_GET_RETVAL(answer->data) == EHANGUP) {196 if ((errno_t) IPC_GET_RETVAL(answer->data) == EHANGUP) { 197 197 phone_t *phone = answer->caller_phone; 198 198 mutex_lock(&phone->lock); … … 222 222 * 223 223 */ 224 static int request_preprocess(call_t *call, phone_t *phone)224 static errno_t request_preprocess(call_t *call, phone_t *phone) 225 225 { 226 226 call->request_method = IPC_GET_IMETHOD(call->data); … … 239 239 static void process_answer(call_t *call) 240 240 { 241 if ((( native_t) IPC_GET_RETVAL(call->data) == EHANGUP) &&241 if (((errno_t) IPC_GET_RETVAL(call->data) == EHANGUP) && 242 242 (call->flags & IPC_CALL_FORWARDED)) 243 243 IPC_SET_RETVAL(call->data, EFORWARD); … … 271 271 * 272 272 */ 273 int ipc_req_internal(cap_handle_t handle, ipc_data_t *data, sysarg_t priv)273 errno_t ipc_req_internal(cap_handle_t handle, ipc_data_t *data, sysarg_t priv) 274 274 { 275 275 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); … … 281 281 memcpy(call->data.args, data->args, sizeof(data->args)); 282 282 283 int rc = request_preprocess(call, kobj->phone);283 errno_t rc = request_preprocess(call, kobj->phone); 284 284 if (!rc) { 285 285 #ifdef CONFIG_UDEBUG … … 359 359 * 360 360 * @return EOK on success. 361 * @return Negativeerror code on error.362 * 363 */ 364 sys arg_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod,361 * @return An error code on error. 362 * 363 */ 364 sys_errno_t sys_ipc_call_async_fast(sysarg_t handle, sysarg_t imethod, 365 365 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t label) 366 366 { … … 389 389 call->data.label = label; 390 390 391 int res = request_preprocess(call, kobj->phone);391 errno_t res = request_preprocess(call, kobj->phone); 392 392 393 393 if (!res) … … 409 409 * 410 410 */ 411 sys arg_t sys_ipc_call_async_slow(sysarg_t handle, ipc_data_t *data,411 sys_errno_t sys_ipc_call_async_slow(sysarg_t handle, ipc_data_t *data, 412 412 sysarg_t label) 413 413 { … … 422 422 423 423 call_t *call = ipc_call_alloc(0); 424 int rc = copy_from_uspace(&call->data.args, &data->args,424 errno_t rc = copy_from_uspace(&call->data.args, &data->args, 425 425 sizeof(call->data.args)); 426 if (rc != 0) {426 if (rc != EOK) { 427 427 kobject_put(call->kobject); 428 428 kobject_put(kobj); 429 return (sys arg_t) rc;429 return (sys_errno_t) rc; 430 430 } 431 431 … … 433 433 call->data.label = label; 434 434 435 int res = request_preprocess(call, kobj->phone);435 errno_t res = request_preprocess(call, kobj->phone); 436 436 437 437 if (!res) … … 466 466 * 467 467 */ 468 static sys arg_t sys_ipc_forward_common(sysarg_t chandle, sysarg_t phandle,468 static sys_errno_t sys_ipc_forward_common(sysarg_t chandle, sysarg_t phandle, 469 469 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 470 470 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) … … 482 482 483 483 bool after_forward = false; 484 int rc;484 errno_t rc; 485 485 486 486 kobject_t *pkobj = kobject_get(TASK, phandle, KOBJECT_TYPE_PHONE); … … 577 577 * 578 578 */ 579 sys arg_t sys_ipc_forward_fast(sysarg_t chandle, sysarg_t phandle,579 sys_errno_t sys_ipc_forward_fast(sysarg_t chandle, sysarg_t phandle, 580 580 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 581 581 { … … 601 601 * 602 602 */ 603 sys arg_t sys_ipc_forward_slow(sysarg_t chandle, sysarg_t phandle,603 sys_errno_t sys_ipc_forward_slow(sysarg_t chandle, sysarg_t phandle, 604 604 ipc_data_t *data, unsigned int mode) 605 605 { 606 606 ipc_data_t newdata; 607 int rc = copy_from_uspace(&newdata.args, &data->args,607 errno_t rc = copy_from_uspace(&newdata.args, &data->args, 608 608 sizeof(newdata.args)); 609 if (rc != 0)610 return (sys arg_t) rc;609 if (rc != EOK) 610 return (sys_errno_t) rc; 611 611 612 612 return sys_ipc_forward_common(chandle, phandle, … … 631 631 * 632 632 */ 633 sys arg_t sys_ipc_answer_fast(sysarg_t chandle, sysarg_t retval, sysarg_t arg1,633 sys_errno_t sys_ipc_answer_fast(sysarg_t chandle, sysarg_t retval, sysarg_t arg1, 634 634 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 635 635 { … … 660 660 */ 661 661 IPC_SET_ARG5(call->data, 0); 662 int rc = answer_preprocess(call, saved ? &saved_data : NULL);662 errno_t rc = answer_preprocess(call, saved ? &saved_data : NULL); 663 663 664 664 ipc_answer(&TASK->answerbox, call); … … 678 678 * 679 679 */ 680 sys arg_t sys_ipc_answer_slow(sysarg_t chandle, ipc_data_t *data)680 sys_errno_t sys_ipc_answer_slow(sysarg_t chandle, ipc_data_t *data) 681 681 { 682 682 kobject_t *kobj = cap_unpublish(TASK, chandle, KOBJECT_TYPE_CALL); … … 695 695 saved = false; 696 696 697 int rc = copy_from_uspace(&call->data.args, &data->args,697 errno_t rc = copy_from_uspace(&call->data.args, &data->args, 698 698 sizeof(call->data.args)); 699 if (rc != 0) {699 if (rc != EOK) { 700 700 /* 701 701 * Republish the capability so that the call does not get lost. … … 722 722 * 723 723 */ 724 sys arg_t sys_ipc_hangup(sysarg_t handle)724 sys_errno_t sys_ipc_hangup(sysarg_t handle) 725 725 { 726 726 kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE); … … 728 728 return ENOENT; 729 729 730 if (ipc_phone_hangup(kobj->phone)) { 731 kobject_put(kobj); 732 return -1; 733 } 734 730 errno_t rc = ipc_phone_hangup(kobj->phone); 735 731 kobject_put(kobj); 736 return 0;732 return rc; 737 733 } 738 734 … … 744 740 * for explanation. 745 741 * 746 * @return Capability handle of the received request. 747 * @return CAP_NIL for answers, notifications and when there is no call. 748 * @return Negative error code on error. 749 */ 750 sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 742 * @return An error code on error. 743 */ 744 sys_errno_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 751 745 unsigned int flags) 752 746 { … … 767 761 768 762 if (!call) { 769 STRUCT_TO_USPACE(calldata, &(ipc_data_t){}); 770 return CAP_NIL; 771 } 772 763 ipc_data_t data = {}; 764 data.cap_handle = CAP_NIL; 765 STRUCT_TO_USPACE(calldata, &data); 766 return EOK; 767 } 768 769 call->data.flags = call->flags; 773 770 if (call->flags & IPC_CALL_NOTIF) { 774 771 /* Set in_phone_hash to the interrupt counter */ 775 772 call->data.phone = (void *) call->priv; 776 773 777 call->data. flags = IPC_CALL_NOTIF;774 call->data.cap_handle = CAP_NIL; 778 775 779 776 STRUCT_TO_USPACE(calldata, &call->data); 780 777 kobject_put(call->kobject); 781 778 782 return CAP_NIL;779 return EOK; 783 780 } 784 781 … … 791 788 } 792 789 793 call->data. flags = IPC_CALL_ANSWERED;790 call->data.cap_handle = CAP_NIL; 794 791 795 792 STRUCT_TO_USPACE(calldata, &call->data); 796 793 kobject_put(call->kobject); 797 794 798 return CAP_NIL;795 return EOK; 799 796 } 800 797 … … 802 799 goto restart; 803 800 804 int rc; 805 cap_handle_t handle = cap_alloc(TASK); 806 if (handle < 0) { 807 rc = handle; 801 cap_handle_t handle; 802 errno_t rc = cap_alloc(TASK, &handle); 803 if (rc != EOK) { 808 804 goto error; 809 805 } 810 806 807 call->data.cap_handle = handle; 808 811 809 /* 812 810 * Include phone hash of the caller in the request, copy the whole … … 819 817 kobject_add_ref(call->kobject); 820 818 cap_publish(TASK, handle, call->kobject); 821 return handle;819 return EOK; 822 820 823 821 error: … … 827 825 /* 828 826 * The callee will not receive this call and no one else has a chance to 829 * answer it. Reply with the EPARTY error code. 827 * answer it. Set the IPC_CALL_AUTO_REPLY flag and return the EPARTY 828 * error code. 830 829 */ 831 830 ipc_data_t saved_data; … … 840 839 IPC_SET_RETVAL(call->data, EPARTY); 841 840 (void) answer_preprocess(call, saved ? &saved_data : NULL); 841 call->flags |= IPC_CALL_AUTO_REPLY; 842 842 ipc_answer(&TASK->answerbox, call); 843 843 … … 848 848 * 849 849 */ 850 sys arg_t sys_ipc_poke(void)850 sys_errno_t sys_ipc_poke(void) 851 851 { 852 852 waitq_unsleep(&TASK->answerbox.wq); … … 860 860 * @param ucode Uspace pointer to the top-half pseudocode. 861 861 * 862 * @return IRQ kernel object capability 862 * @param[out] uspace_handle Uspace pointer to IRQ kernel object capability 863 * 863 864 * @return EPERM 864 865 * @return Error code returned by ipc_irq_subscribe(). 865 866 * 866 867 */ 867 sysarg_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode) 868 sys_errno_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod, irq_code_t *ucode, 869 cap_handle_t *uspace_handle) 868 870 { 869 871 if (!(perm_get(TASK) & PERM_IRQ_REG)) 870 872 return EPERM; 871 873 872 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode );874 return ipc_irq_subscribe(&TASK->answerbox, inr, imethod, ucode, uspace_handle); 873 875 } 874 876 … … 881 883 * 882 884 */ 883 sys arg_t sys_ipc_irq_unsubscribe(sysarg_t cap)885 sys_errno_t sys_ipc_irq_unsubscribe(sysarg_t cap) 884 886 { 885 887 if (!(perm_get(TASK) & PERM_IRQ_REG)) … … 891 893 } 892 894 893 #ifdef __32_BITS__ 894 895 /** Syscall connect to a task by ID (32 bits) 896 * 897 * @return Phone id on success, or negative error code. 898 * 899 */ 900 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid) 895 /** Syscall connect to a task by ID 896 * 897 * @return Error code. 898 * 899 */ 900 sys_errno_t sys_ipc_connect_kbox(task_id_t *uspace_taskid, cap_handle_t *uspace_phone) 901 901 { 902 902 #ifdef CONFIG_UDEBUG 903 sysarg64_t taskid; 904 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 905 if (rc != 0) 906 return (sysarg_t) rc; 907 908 return ipc_connect_kbox((task_id_t) taskid); 903 task_id_t taskid; 904 cap_handle_t phone; 905 906 errno_t rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(task_id_t)); 907 if (rc == EOK) { 908 rc = ipc_connect_kbox((task_id_t) taskid, &phone); 909 } 910 911 if (rc == EOK) { 912 rc = copy_to_uspace(uspace_phone, &phone, sizeof(cap_handle_t)); 913 if (rc != EOK) { 914 // Clean up the phone on failure. 915 sys_ipc_hangup(phone); 916 } 917 } 918 919 return (sys_errno_t) rc; 909 920 #else 910 return (sys arg_t) ENOTSUP;921 return (sys_errno_t) ENOTSUP; 911 922 #endif 912 923 } 913 924 914 #endif /* __32_BITS__ */915 916 #ifdef __64_BITS__917 918 /** Syscall connect to a task by ID (64 bits)919 *920 * @return Phone id on success, or negative error code.921 *922 */923 sysarg_t sys_ipc_connect_kbox(sysarg_t taskid)924 {925 #ifdef CONFIG_UDEBUG926 return ipc_connect_kbox((task_id_t) taskid);927 #else928 return (sysarg_t) ENOTSUP;929 #endif930 }931 932 #endif /* __64_BITS__ */933 934 925 /** @} 935 926 */
Note:
See TracChangeset
for help on using the changeset viewer.