Changeset 228e490 in mainline for kernel/generic/src/ipc/sysipc.c
- Timestamp:
- 2010-12-14T17:00:02Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a9b6bec, eb221e5
- Parents:
- dd8d5a7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/sysipc.c
rdd8d5a7 r228e490 78 78 } 79 79 80 /** Decide if the method is a system method. 81 * 82 * @param method Method to be decided. 83 * 84 * @return true if the method is a system method. 85 * 86 */ 87 static inline bool method_is_system(sysarg_t method) 88 { 89 if (method <= IPC_M_LAST_SYSTEM) 80 /** Decide if the interface and method is a system method. 81 * 82 * @param imethod Interface and method to be decided. 83 * 84 * @return True if the interface and method is a system 85 * interface and method. 86 * 87 */ 88 static inline bool method_is_system(sysarg_t imethod) 89 { 90 if (imethod <= IPC_M_LAST_SYSTEM) 90 91 return true; 91 92 … … 93 94 } 94 95 95 /** Decide if the message with this method is forwardable.96 * 97 * - some system messages may be forwarded, for some of them98 * it is useless99 * 100 * @param method Method to be decided.101 * 102 * @return true if themethod is forwardable.103 * 104 */ 105 static inline bool method_is_forwardable(sysarg_t method)106 { 107 switch ( method) {96 /** Decide if the message with this interface and method is forwardable. 97 * 98 * Some system messages may be forwarded, for some of them 99 * it is useless. 100 * 101 * @param imethod Interface and method to be decided. 102 * 103 * @return True if the interface and method is forwardable. 104 * 105 */ 106 static inline bool method_is_forwardable(sysarg_t imethod) 107 { 108 switch (imethod) { 108 109 case IPC_M_CONNECTION_CLONE: 109 110 case IPC_M_CONNECT_ME: … … 116 117 } 117 118 118 /** Decide if the message with this method is immutable on forward.119 * 120 * - some system messages may be forwarded but their content cannot be altered121 * 122 * @param method Method to be decided.123 * 124 * @return true if themethod is immutable on forward.125 * 126 */ 127 static inline bool method_is_immutable(sysarg_t method)128 { 129 switch ( method) {119 /** Decide if the message with this interface and method is immutable on forward. 120 * 121 * Some system messages may be forwarded but their content cannot be altered. 122 * 123 * @param imethod Interface and method to be decided. 124 * 125 * @return True if the interface and method is immutable on forward. 126 * 127 */ 128 static inline bool method_is_immutable(sysarg_t imethod) 129 { 130 switch (imethod) { 130 131 case IPC_M_SHARE_OUT: 131 132 case IPC_M_SHARE_IN: … … 153 154 static inline bool answer_need_old(call_t *call) 154 155 { 155 switch (IPC_GET_ METHOD(call->data)) {156 switch (IPC_GET_IMETHOD(call->data)) { 156 157 case IPC_M_CONNECTION_CLONE: 157 158 case IPC_M_CONNECT_ME: … … 197 198 return 0; 198 199 199 if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECTION_CLONE) {200 if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECTION_CLONE) { 200 201 int phoneid = IPC_GET_ARG1(*olddata); 201 202 phone_t *phone = &TASK->phones[phoneid]; … … 219 220 mutex_unlock(&phone->lock); 220 221 } 221 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME) {222 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME) { 222 223 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 223 224 … … 238 239 mutex_unlock(&phone->lock); 239 240 } 240 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {241 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_TO_ME) { 241 242 int phoneid = IPC_GET_ARG5(*olddata); 242 243 … … 251 252 (sysarg_t) &TASK->phones[phoneid]); 252 253 } 253 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {254 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME_TO) { 254 255 /* If the users accepted call, connect */ 255 256 if (IPC_GET_RETVAL(answer->data) == EOK) { … … 257 258 &TASK->answerbox); 258 259 } 259 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_OUT) {260 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_OUT) { 260 261 if (!IPC_GET_RETVAL(answer->data)) { 261 262 /* Accepted, handle as_area receipt */ … … 271 272 return rc; 272 273 } 273 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_IN) {274 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) { 274 275 if (!IPC_GET_RETVAL(answer->data)) { 275 276 irq_spinlock_lock(&answer->sender->lock, true); … … 282 283 IPC_SET_RETVAL(answer->data, rc); 283 284 } 284 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_READ) {285 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_READ) { 285 286 ASSERT(!answer->buffer); 286 287 if (!IPC_GET_RETVAL(answer->data)) { … … 311 312 } 312 313 } 313 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_WRITE) {314 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_WRITE) { 314 315 ASSERT(answer->buffer); 315 316 if (!IPC_GET_RETVAL(answer->data)) { … … 364 365 static int request_preprocess(call_t *call, phone_t *phone) 365 366 { 366 switch (IPC_GET_ METHOD(call->data)) {367 switch (IPC_GET_IMETHOD(call->data)) { 367 368 case IPC_M_CONNECTION_CLONE: { 368 369 phone_t *cloned_phone; … … 504 505 static int process_request(answerbox_t *box, call_t *call) 505 506 { 506 if (IPC_GET_ METHOD(call->data) == IPC_M_CONNECT_TO_ME) {507 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) { 507 508 int phoneid = phone_alloc(TASK); 508 509 if (phoneid < 0) { /* Failed to allocate phone */ … … 515 516 } 516 517 517 switch (IPC_GET_ METHOD(call->data)) {518 switch (IPC_GET_IMETHOD(call->data)) { 518 519 case IPC_M_DEBUG_ALL: 519 520 return -1; … … 531 532 * 532 533 * @param phoneid Phone handle for the call. 533 * @param method Method of the call.534 * @param imethod Interface and method of the call. 534 535 * @param arg1 Service-defined payload argument. 535 536 * @param arg2 Service-defined payload argument. 536 537 * @param arg3 Service-defined payload argument. 537 * @param data Address of user space structure where the reply call will538 * @param data Address of user-space structure where the reply call will 538 539 * be stored. 539 540 * … … 542 543 * 543 544 */ 544 sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t method,545 sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod, 545 546 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data) 546 547 { … … 548 549 if (phone_get(phoneid, &phone) != EOK) 549 550 return ENOENT; 550 551 551 552 call_t *call = ipc_call_alloc(0); 552 IPC_SET_ METHOD(call->data,method);553 IPC_SET_IMETHOD(call->data, imethod); 553 554 IPC_SET_ARG1(call->data, arg1); 554 555 IPC_SET_ARG2(call->data, arg2); … … 580 581 581 582 process_answer(call); 582 583 583 } else 584 584 IPC_SET_RETVAL(call->data, res); … … 594 594 /** Make a synchronous IPC call allowing to transmit the entire payload. 595 595 * 596 * @param phoneid 597 * @param question Userspace address of call data with the request.598 * @param reply Userspace address of call data where to store the599 * 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. 600 600 * 601 601 * @return Zero on success or an error code. 602 602 * 603 603 */ 604 sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t * question,604 sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request, 605 605 ipc_data_t *reply) 606 606 { … … 608 608 if (phone_get(phoneid, &phone) != EOK) 609 609 return ENOENT; 610 610 611 611 call_t *call = ipc_call_alloc(0); 612 int rc = copy_from_uspace(&call->data.args, & question->args,612 int rc = copy_from_uspace(&call->data.args, &request->args, 613 613 sizeof(call->data.args)); 614 614 if (rc != 0) { … … 648 648 * made over a phone. 649 649 * 650 * @param phone Phone to check the limit against. 650 * @param phone Phone to check the limit against. 651 * 651 652 * @return 0 if limit not reached or -1 if limit exceeded. 652 653 * … … 666 667 * 667 668 * @param phoneid Phone handle for the call. 668 * @param method Method of the call.669 * @param imethod Interface and method of the call. 669 670 * @param arg1 Service-defined payload argument. 670 671 * @param arg2 Service-defined payload argument. … … 678 679 * 679 680 */ 680 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t method,681 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod, 681 682 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 682 683 { … … 684 685 if (phone_get(phoneid, &phone) != EOK) 685 686 return IPC_CALLRET_FATAL; 686 687 687 688 if (check_call_limit(phone)) 688 689 return IPC_CALLRET_TEMPORARY; 689 690 690 691 call_t *call = ipc_call_alloc(0); 691 IPC_SET_ METHOD(call->data,method);692 IPC_SET_IMETHOD(call->data, imethod); 692 693 IPC_SET_ARG1(call->data, arg1); 693 694 IPC_SET_ARG2(call->data, arg2); … … 752 753 * @param callid Hash of the call to forward. 753 754 * @param phoneid Phone handle to use for forwarding. 754 * @param method Newmethod to use for the forwarded call.755 * @param imethod New interface and method to use for the forwarded call. 755 756 * @param arg1 New value of the first argument for the forwarded call. 756 757 * @param arg2 New value of the second argument for the forwarded call. … … 769 770 */ 770 771 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid, 771 sysarg_t method, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,772 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 772 773 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) 773 774 { … … 785 786 } 786 787 787 if (!method_is_forwardable(IPC_GET_ METHOD(call->data))) {788 if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) { 788 789 IPC_SET_RETVAL(call->data, EFORWARD); 789 790 ipc_answer(&TASK->answerbox, call); … … 792 793 793 794 /* 794 * Userspace is not allowed to change method of system methods on795 * forward, allow changing ARG1, ARG2, ARG3 and ARG4 by means of method,796 * arg1, arg2 and arg3.797 * If the method is immutable, don't change anything.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. 798 799 */ 799 if (!method_is_immutable(IPC_GET_ METHOD(call->data))) {800 if (method_is_system(IPC_GET_ METHOD(call->data))) {801 if (IPC_GET_ METHOD(call->data) == IPC_M_CONNECT_TO_ME)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) 802 803 phone_dealloc(IPC_GET_ARG5(call->data)); 803 804 804 IPC_SET_ARG1(call->data, method);805 IPC_SET_ARG1(call->data, imethod); 805 806 IPC_SET_ARG2(call->data, arg1); 806 807 IPC_SET_ARG3(call->data, arg2); … … 814 815 } 815 816 } else { 816 IPC_SET_ METHOD(call->data,method);817 IPC_SET_IMETHOD(call->data, imethod); 817 818 IPC_SET_ARG1(call->data, arg1); 818 819 IPC_SET_ARG2(call->data, arg2); … … 830 831 /** Forward a received call to another destination - fast version. 831 832 * 832 * In case the original method is a system method, ARG1, ARG2 and ARG3 are833 * overwritten in the forwarded message with the new method and the new834 * arg1 and arg2, respectively. Otherwise the METHOD, ARG1 and ARG2 are835 * rewritten with the new method, arg1 and arg2, respectively. Also note there836 * is a set of immutable methods, for which the new method and arguments are not837 * set and these values are ignored.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. 838 839 * 839 840 * @param callid Hash of the call to forward. 840 841 * @param phoneid Phone handle to use for forwarding. 841 * @param method Newmethod to use for the forwarded call.842 * @param imethod New interface and method to use for the forwarded call. 842 843 * @param arg1 New value of the first argument for the forwarded call. 843 844 * @param arg2 New value of the second argument for the forwarded call. … … 848 849 */ 849 850 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid, 850 sysarg_t method, sysarg_t arg1, sysarg_t arg2, unsigned int mode)851 { 852 return sys_ipc_forward_common(callid, phoneid, method, arg1, arg2, 0, 0,851 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 852 { 853 return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0, 853 854 0, mode, false); 854 855 } … … 857 858 * 858 859 * This function is the slow verision of the sys_ipc_forward_fast interface. 859 * It can copy all five new arguments and the new method from the userspace.860 * It naturally extends the functionality of the fast version. For system861 * methods, it additionally stores the new value of arg3 to ARG4. For non-system862 * methods, it additionally stores the new value of arg3, arg4 and arg5,863 * respectively, to ARG3, ARG4 and ARG5, respectively.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. 864 865 * 865 866 * @param callid Hash of the call to forward. … … 881 882 882 883 return sys_ipc_forward_common(callid, phoneid, 883 IPC_GET_ METHOD(newdata), IPC_GET_ARG1(newdata),884 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 884 885 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), 885 886 IPC_GET_ARG4(newdata), IPC_GET_ARG5(newdata), mode, true); … … 1094 1095 /** Connect an IRQ handler to a task. 1095 1096 * 1096 * @param inr IRQ number.1097 * @param devno Device number.1098 * @param method Method to be associated with the notification.1099 * @param ucode Uspace pointer to the top-half pseudocode.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. 1100 1101 * 1101 1102 * @return EPERM or a return code returned by ipc_irq_register(). 1102 1103 * 1103 1104 */ 1104 sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t method,1105 sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t imethod, 1105 1106 irq_code_t *ucode) 1106 1107 { … … 1108 1109 return EPERM; 1109 1110 1110 return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);1111 return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode); 1111 1112 } 1112 1113
Note:
See TracChangeset
for help on using the changeset viewer.