Changeset 7bdcc45 in mainline for kernel/generic/src/ipc
- Timestamp:
- 2010-12-16T16:38:49Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7837101
- Parents:
- 8e58f94 (diff), eb221e5 (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. - Location:
- kernel/generic/src/ipc
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/event.c
r8e58f94 r7bdcc45 57 57 events[i].answerbox = NULL; 58 58 events[i].counter = 0; 59 events[i]. method = 0;59 events[i].imethod = 0; 60 60 } 61 61 } 62 62 63 static int event_subscribe(event_type_t evno, unative_tmethod,63 static int event_subscribe(event_type_t evno, sysarg_t imethod, 64 64 answerbox_t *answerbox) 65 65 { … … 73 73 if (events[evno].answerbox == NULL) { 74 74 events[evno].answerbox = answerbox; 75 events[evno]. method =method;75 events[evno].imethod = imethod; 76 76 events[evno].counter = 0; 77 77 res = EOK; … … 84 84 } 85 85 86 unative_t sys_event_subscribe(unative_t evno, unative_tmethod)86 sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod) 87 87 { 88 return ( unative_t) event_subscribe((event_type_t) evno, (unative_t)89 method, &TASK->answerbox);88 return (sysarg_t) event_subscribe((event_type_t) evno, (sysarg_t) 89 imethod, &TASK->answerbox); 90 90 } 91 91 … … 113 113 events[i].answerbox = NULL; 114 114 events[i].counter = 0; 115 events[i]. method = 0;115 events[i].imethod = 0; 116 116 } 117 117 spinlock_unlock(&events[i].lock); … … 119 119 } 120 120 121 void event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3,122 unative_t a4, unative_t a5)121 void event_notify(event_type_t evno, sysarg_t a1, sysarg_t a2, sysarg_t a3, 122 sysarg_t a4, sysarg_t a5) 123 123 { 124 124 ASSERT(evno < EVENT_END); … … 130 130 call->flags |= IPC_CALL_NOTIF; 131 131 call->priv = ++events[evno].counter; 132 IPC_SET_ METHOD(call->data, events[evno].method);132 IPC_SET_IMETHOD(call->data, events[evno].imethod); 133 133 IPC_SET_ARG1(call->data, a1); 134 134 IPC_SET_ARG2(call->data, a2); -
kernel/generic/src/ipc/ipc.c
r8e58f94 r7bdcc45 270 270 * 271 271 */ 272 void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)272 void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err) 273 273 { 274 274 call->data.phone = phone; … … 367 367 368 368 call_t *call = ipc_call_alloc(0); 369 IPC_SET_ METHOD(call->data, IPC_M_PHONE_HUNGUP);369 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP); 370 370 call->flags |= IPC_CALL_DISCARD_ANSWER; 371 371 _ipc_call(phone, box, call); … … 547 547 * disconnected. 548 548 */ 549 IPC_SET_ METHOD(call->data, IPC_M_PHONE_HUNGUP);549 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP); 550 550 call->flags |= IPC_CALL_DISCARD_ANSWER; 551 551 _ipc_call(phone, box, call); … … 655 655 (call->flags & IPC_CALL_NOTIF)); 656 656 657 /*658 * Record the receipt of this call in the current task's counter659 * of active calls. IPC_M_PHONE_HUNGUP calls do not contribute660 * to this counter so do not record answers to them either.661 */662 if (!(call->flags & IPC_CALL_DISCARD_ANSWER))663 atomic_dec(&TASK->active_calls);664 665 657 ipc_call_free(call); 666 658 } … … 702 694 for (i = 0; i < IPC_MAX_PHONES; i++) { 703 695 if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) { 704 printf("% d: mutex busy\n", i);696 printf("%zu: mutex busy\n", i); 705 697 continue; 706 698 } 707 699 708 700 if (task->phones[i].state != IPC_PHONE_FREE) { 709 printf("% " PRIs ": ", i);701 printf("%zu: ", i); 710 702 711 703 switch (task->phones[i].state) { … … 749 741 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, 750 742 call->sender->taskid, 751 IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),743 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 752 744 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 753 745 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), … … 765 757 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call, 766 758 call->sender->taskid, 767 IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),759 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 768 760 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 769 761 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), … … 779 771 printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun 780 772 " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", 781 call, IPC_GET_ METHOD(call->data), IPC_GET_ARG1(call->data),773 call, IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data), 782 774 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data), 783 775 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data), -
kernel/generic/src/ipc/ipcrsc.c
r8e58f94 r7bdcc45 144 144 * 145 145 */ 146 call_t *get_call( unative_t callid)146 call_t *get_call(sysarg_t callid) 147 147 { 148 148 link_t *lst; … … 153 153 lst != &TASK->answerbox.dispatched_calls; lst = lst->next) { 154 154 call_t *call = list_get_instance(lst, call_t, link); 155 if (( unative_t) call == callid) {155 if ((sysarg_t) call == callid) { 156 156 result = call; 157 157 break; -
kernel/generic/src/ipc/irq.c
r8e58f94 r7bdcc45 42 42 * 43 43 * The structure of a notification message is as follows: 44 * - METHOD: method as registered by the SYS_IPC_REGISTER_IRQ syscall 44 * - IMETHOD: interface and method as registered by the SYS_IPC_REGISTER_IRQ 45 * syscall 45 46 * - ARG1: payload modified by a 'top-half' handler 46 47 * - ARG2: payload modified by a 'top-half' handler … … 49 50 * - ARG5: payload modified by a 'top-half' handler 50 51 * - in_phone_hash: interrupt counter (may be needed to assure correct order 51 * in multithreaded drivers)52 * in multithreaded drivers) 52 53 * 53 54 * Note on synchronization for ipc_irq_register(), ipc_irq_unregister(), … … 130 131 /** Register an answerbox as a receiving end for IRQ notifications. 131 132 * 132 * @param box Receiving answerbox. 133 * @param inr IRQ number. 134 * @param devno Device number. 135 * @param method Method to be associated with the notification. 136 * @param ucode Uspace pointer to top-half pseudocode. 133 * @param box Receiving answerbox. 134 * @param inr IRQ number. 135 * @param devno Device number. 136 * @param imethod Interface and method to be associated 137 * with the notification. 138 * @param ucode Uspace pointer to top-half pseudocode. 137 139 * 138 140 * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success. … … 140 142 */ 141 143 int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, 142 unative_tmethod, irq_code_t *ucode)143 { 144 unative_t key[] = {145 ( unative_t) inr,146 ( unative_t) devno144 sysarg_t imethod, irq_code_t *ucode) 145 { 146 sysarg_t key[] = { 147 (sysarg_t) inr, 148 (sysarg_t) devno 147 149 }; 148 150 … … 167 169 irq->notif_cfg.notify = true; 168 170 irq->notif_cfg.answerbox = box; 169 irq->notif_cfg. method =method;171 irq->notif_cfg.imethod = imethod; 170 172 irq->notif_cfg.code = code; 171 173 irq->notif_cfg.counter = 0; … … 213 215 int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno) 214 216 { 215 unative_t key[] = {216 ( unative_t) inr,217 ( unative_t) devno217 sysarg_t key[] = { 218 (sysarg_t) inr, 219 (sysarg_t) devno 218 220 }; 219 221 … … 290 292 } 291 293 292 unative_t key[2];294 sysarg_t key[2]; 293 295 key[0] = irq->inr; 294 296 key[1] = irq->devno; … … 444 446 445 447 /* Set up args */ 446 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);448 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 447 449 IPC_SET_ARG1(call->data, irq->notif_cfg.scratch[1]); 448 450 IPC_SET_ARG2(call->data, irq->notif_cfg.scratch[2]); … … 465 467 * 466 468 */ 467 void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3,468 unative_t a4, unative_t a5)469 void ipc_irq_send_msg(irq_t *irq, sysarg_t a1, sysarg_t a2, sysarg_t a3, 470 sysarg_t a4, sysarg_t a5) 469 471 { 470 472 irq_spinlock_lock(&irq->lock, true); … … 481 483 call->priv = ++irq->notif_cfg.counter; 482 484 483 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);485 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 484 486 IPC_SET_ARG1(call->data, a1); 485 487 IPC_SET_ARG2(call->data, a2); -
kernel/generic/src/ipc/kbox.c
r8e58f94 r7bdcc45 167 167 continue; /* Try again. */ 168 168 169 switch (IPC_GET_ METHOD(call->data)) {169 switch (IPC_GET_IMETHOD(call->data)) { 170 170 171 171 case IPC_M_DEBUG_ALL: … … 192 192 } 193 193 194 195 194 /** Connect phone to a task kernel-box specified by id. 196 195 * -
kernel/generic/src/ipc/sysipc.c
r8e58f94 r7bdcc45 49 49 #include <syscall/copy.h> 50 50 #include <security/cap.h> 51 #include <console/console.h> 51 52 #include <mm/as.h> 52 53 #include <print.h> … … 68 69 * 69 70 */ 70 static int phone_get( unative_t phoneid, phone_t **phone)71 static int phone_get(sysarg_t phoneid, phone_t **phone) 71 72 { 72 73 if (phoneid >= IPC_MAX_PHONES) … … 77 78 } 78 79 79 /** Decide if the method is a system method. 80 * 81 * @param method Method to be decided. 82 * 83 * @return true if the method is a system method. 84 * 85 */ 86 static inline bool method_is_system(unative_t method) 87 { 88 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) 89 91 return true; 90 92 … … 92 94 } 93 95 94 /** Decide if the message with this method is forwardable.95 * 96 * - some system messages may be forwarded, for some of them97 * it is useless98 * 99 * @param method Method to be decided.100 * 101 * @return true if themethod is forwardable.102 * 103 */ 104 static inline bool method_is_forwardable( unative_tmethod)105 { 106 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) { 107 109 case IPC_M_CONNECTION_CLONE: 108 110 case IPC_M_CONNECT_ME: … … 115 117 } 116 118 117 /** Decide if the message with this method is immutable on forward.118 * 119 * - some system messages may be forwarded but their content cannot be altered120 * 121 * @param method Method to be decided.122 * 123 * @return true if themethod is immutable on forward.124 * 125 */ 126 static inline bool method_is_immutable( unative_tmethod)127 { 128 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) { 129 131 case IPC_M_SHARE_OUT: 130 132 case IPC_M_SHARE_IN: … … 152 154 static inline bool answer_need_old(call_t *call) 153 155 { 154 switch (IPC_GET_ METHOD(call->data)) {156 switch (IPC_GET_IMETHOD(call->data)) { 155 157 case IPC_M_CONNECTION_CLONE: 156 158 case IPC_M_CONNECT_ME: … … 196 198 return 0; 197 199 198 if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECTION_CLONE) {200 if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECTION_CLONE) { 199 201 int phoneid = IPC_GET_ARG1(*olddata); 200 202 phone_t *phone = &TASK->phones[phoneid]; … … 218 220 mutex_unlock(&phone->lock); 219 221 } 220 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME) {222 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME) { 221 223 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 222 224 … … 237 239 mutex_unlock(&phone->lock); 238 240 } 239 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {241 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_TO_ME) { 240 242 int phoneid = IPC_GET_ARG5(*olddata); 241 243 … … 248 250 /* Set 'phone hash' as arg5 of response */ 249 251 IPC_SET_ARG5(answer->data, 250 ( unative_t) &TASK->phones[phoneid]);251 } 252 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {252 (sysarg_t) &TASK->phones[phoneid]); 253 } 254 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME_TO) { 253 255 /* If the users accepted call, connect */ 254 256 if (IPC_GET_RETVAL(answer->data) == EOK) { … … 256 258 &TASK->answerbox); 257 259 } 258 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_OUT) {260 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_OUT) { 259 261 if (!IPC_GET_RETVAL(answer->data)) { 260 262 /* Accepted, handle as_area receipt */ … … 270 272 return rc; 271 273 } 272 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_SHARE_IN) {274 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) { 273 275 if (!IPC_GET_RETVAL(answer->data)) { 274 276 irq_spinlock_lock(&answer->sender->lock, true); … … 281 283 IPC_SET_RETVAL(answer->data, rc); 282 284 } 283 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_READ) {285 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_READ) { 284 286 ASSERT(!answer->buffer); 285 287 if (!IPC_GET_RETVAL(answer->data)) { … … 310 312 } 311 313 } 312 } else if (IPC_GET_ METHOD(*olddata) == IPC_M_DATA_WRITE) {314 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_WRITE) { 313 315 ASSERT(answer->buffer); 314 316 if (!IPC_GET_RETVAL(answer->data)) { … … 363 365 static int request_preprocess(call_t *call, phone_t *phone) 364 366 { 365 switch (IPC_GET_ METHOD(call->data)) {367 switch (IPC_GET_IMETHOD(call->data)) { 366 368 case IPC_M_CONNECTION_CLONE: { 367 369 phone_t *cloned_phone; … … 399 401 } 400 402 case IPC_M_CONNECT_ME: 401 IPC_SET_ARG5(call->data, ( unative_t) phone);403 IPC_SET_ARG5(call->data, (sysarg_t) phone); 402 404 break; 403 405 case IPC_M_CONNECT_ME_TO: { … … 407 409 408 410 /* Set arg5 for server */ 409 IPC_SET_ARG5(call->data, ( unative_t) &TASK->phones[newphid]);411 IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]); 410 412 call->flags |= IPC_CALL_CONN_ME_TO; 411 413 call->priv = newphid; … … 503 505 static int process_request(answerbox_t *box, call_t *call) 504 506 { 505 if (IPC_GET_ METHOD(call->data) == IPC_M_CONNECT_TO_ME) {507 if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) { 506 508 int phoneid = phone_alloc(TASK); 507 509 if (phoneid < 0) { /* Failed to allocate phone */ … … 514 516 } 515 517 516 switch (IPC_GET_ METHOD(call->data)) {518 switch (IPC_GET_IMETHOD(call->data)) { 517 519 case IPC_M_DEBUG_ALL: 518 520 return -1; … … 530 532 * 531 533 * @param phoneid Phone handle for the call. 532 * @param method Method of the call.534 * @param imethod Interface and method of the call. 533 535 * @param arg1 Service-defined payload argument. 534 536 * @param arg2 Service-defined payload argument. 535 537 * @param arg3 Service-defined payload argument. 536 * @param data Address of user space structure where the reply call will538 * @param data Address of user-space structure where the reply call will 537 539 * be stored. 538 540 * … … 541 543 * 542 544 */ 543 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_tmethod,544 unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data)545 sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod, 546 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data) 545 547 { 546 548 phone_t *phone; 547 549 if (phone_get(phoneid, &phone) != EOK) 548 550 return ENOENT; 549 551 550 552 call_t *call = ipc_call_alloc(0); 551 IPC_SET_ METHOD(call->data,method);553 IPC_SET_IMETHOD(call->data, imethod); 552 554 IPC_SET_ARG1(call->data, arg1); 553 555 IPC_SET_ARG2(call->data, arg2); … … 579 581 580 582 process_answer(call); 581 582 583 } else 583 584 IPC_SET_RETVAL(call->data, res); … … 593 594 /** Make a synchronous IPC call allowing to transmit the entire payload. 594 595 * 595 * @param phoneid Phone handle for the call.596 * @param question Userspace address of call data with the request.597 * @param reply Userspace address of call data where to store the598 * answer.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. 599 600 * 600 601 * @return Zero on success or an error code. 601 602 * 602 603 */ 603 unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,604 sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request, 604 605 ipc_data_t *reply) 605 606 { … … 607 608 if (phone_get(phoneid, &phone) != EOK) 608 609 return ENOENT; 609 610 610 611 call_t *call = ipc_call_alloc(0); 611 int rc = copy_from_uspace(&call->data.args, & question->args,612 int rc = copy_from_uspace(&call->data.args, &request->args, 612 613 sizeof(call->data.args)); 613 614 if (rc != 0) { 614 615 ipc_call_free(call); 615 return ( unative_t) rc;616 return (sysarg_t) rc; 616 617 } 617 618 … … 644 645 } 645 646 646 /** Check that the task did not exceed the allowed limit of asynchronous calls. 647 /** Check that the task did not exceed the allowed limit of asynchronous calls 648 * made over a phone. 649 * 650 * @param phone Phone to check the limit against. 647 651 * 648 652 * @return 0 if limit not reached or -1 if limit exceeded. 649 653 * 650 654 */ 651 static int check_call_limit(void) 652 { 653 if (atomic_preinc(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) { 654 atomic_dec(&TASK->active_calls); 655 static int check_call_limit(phone_t *phone) 656 { 657 if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS) 655 658 return -1; 656 }657 659 658 660 return 0; … … 665 667 * 666 668 * @param phoneid Phone handle for the call. 667 * @param method Method of the call.669 * @param imethod Interface and method of the call. 668 670 * @param arg1 Service-defined payload argument. 669 671 * @param arg2 Service-defined payload argument. … … 677 679 * 678 680 */ 679 unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method, 680 unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4) 681 { 682 if (check_call_limit()) 683 return IPC_CALLRET_TEMPORARY; 684 681 sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod, 682 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 683 { 685 684 phone_t *phone; 686 685 if (phone_get(phoneid, &phone) != EOK) 687 686 return IPC_CALLRET_FATAL; 688 687 688 if (check_call_limit(phone)) 689 return IPC_CALLRET_TEMPORARY; 690 689 691 call_t *call = ipc_call_alloc(0); 690 IPC_SET_ METHOD(call->data,method);692 IPC_SET_IMETHOD(call->data, imethod); 691 693 IPC_SET_ARG1(call->data, arg1); 692 694 IPC_SET_ARG2(call->data, arg2); … … 707 709 ipc_backsend_err(phone, call, res); 708 710 709 return ( unative_t) call;711 return (sysarg_t) call; 710 712 } 711 713 … … 718 720 * 719 721 */ 720 unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data) 721 { 722 if (check_call_limit()) 723 return IPC_CALLRET_TEMPORARY; 724 722 sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data) 723 { 725 724 phone_t *phone; 726 725 if (phone_get(phoneid, &phone) != EOK) 727 726 return IPC_CALLRET_FATAL; 727 728 if (check_call_limit(phone)) 729 return IPC_CALLRET_TEMPORARY; 728 730 729 731 call_t *call = ipc_call_alloc(0); … … 732 734 if (rc != 0) { 733 735 ipc_call_free(call); 734 return ( unative_t) rc;736 return (sysarg_t) rc; 735 737 } 736 738 … … 742 744 ipc_backsend_err(phone, call, res); 743 745 744 return ( unative_t) call;746 return (sysarg_t) call; 745 747 } 746 748 … … 751 753 * @param callid Hash of the call to forward. 752 754 * @param phoneid Phone handle to use for forwarding. 753 * @param method Newmethod to use for the forwarded call.755 * @param imethod New interface and method to use for the forwarded call. 754 756 * @param arg1 New value of the first argument for the forwarded call. 755 757 * @param arg2 New value of the second argument for the forwarded call. … … 767 769 * 768 770 */ 769 static unative_t sys_ipc_forward_common(unative_t callid, unative_t phoneid,770 unative_t method, unative_t arg1, unative_t arg2, unative_t arg3,771 unative_t arg4, unative_t arg5, unsigned int mode, bool slow)771 static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid, 772 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 773 sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow) 772 774 { 773 775 call_t *call = get_call(callid); … … 784 786 } 785 787 786 if (!method_is_forwardable(IPC_GET_ METHOD(call->data))) {788 if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) { 787 789 IPC_SET_RETVAL(call->data, EFORWARD); 788 790 ipc_answer(&TASK->answerbox, call); … … 791 793 792 794 /* 793 * Userspace is not allowed to change method of system methods on794 * forward, allow changing ARG1, ARG2, ARG3 and ARG4 by means of method,795 * arg1, arg2 and arg3.796 * 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. 797 799 */ 798 if (!method_is_immutable(IPC_GET_ METHOD(call->data))) {799 if (method_is_system(IPC_GET_ METHOD(call->data))) {800 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) 801 803 phone_dealloc(IPC_GET_ARG5(call->data)); 802 804 803 IPC_SET_ARG1(call->data, method);805 IPC_SET_ARG1(call->data, imethod); 804 806 IPC_SET_ARG2(call->data, arg1); 805 807 IPC_SET_ARG3(call->data, arg2); … … 813 815 } 814 816 } else { 815 IPC_SET_ METHOD(call->data,method);817 IPC_SET_IMETHOD(call->data, imethod); 816 818 IPC_SET_ARG1(call->data, arg1); 817 819 IPC_SET_ARG2(call->data, arg2); … … 829 831 /** Forward a received call to another destination - fast version. 830 832 * 831 * In case the original method is a system method, ARG1, ARG2 and ARG3 are832 * overwritten in the forwarded message with the new method and the new833 * arg1 and arg2, respectively. Otherwise the METHOD, ARG1 and ARG2 are834 * rewritten with the new method, arg1 and arg2, respectively. Also note there835 * is a set of immutable methods, for which the new method and arguments are not836 * 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. 837 839 * 838 840 * @param callid Hash of the call to forward. 839 841 * @param phoneid Phone handle to use for forwarding. 840 * @param method Newmethod to use for the forwarded call.842 * @param imethod New interface and method to use for the forwarded call. 841 843 * @param arg1 New value of the first argument for the forwarded call. 842 844 * @param arg2 New value of the second argument for the forwarded call. … … 846 848 * 847 849 */ 848 unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,849 unative_t method, unative_t arg1, unative_t arg2, unsigned int mode)850 { 851 return sys_ipc_forward_common(callid, phoneid, method, arg1, arg2, 0, 0,850 sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid, 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, 852 854 0, mode, false); 853 855 } … … 856 858 * 857 859 * This function is the slow verision of the sys_ipc_forward_fast interface. 858 * It can copy all five new arguments and the new method from the userspace.859 * It naturally extends the functionality of the fast version. For system860 * methods, it additionally stores the new value of arg3 to ARG4. For non-system861 * methods, it additionally stores the new value of arg3, arg4 and arg5,862 * 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. 863 865 * 864 866 * @param callid Hash of the call to forward. … … 870 872 * 871 873 */ 872 unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,874 sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid, 873 875 ipc_data_t *data, unsigned int mode) 874 876 { … … 877 879 sizeof(newdata.args)); 878 880 if (rc != 0) 879 return ( unative_t) rc;881 return (sysarg_t) rc; 880 882 881 883 return sys_ipc_forward_common(callid, phoneid, 882 IPC_GET_ METHOD(newdata), IPC_GET_ARG1(newdata),884 IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata), 883 885 IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata), 884 886 IPC_GET_ARG4(newdata), IPC_GET_ARG5(newdata), mode, true); … … 900 902 * 901 903 */ 902 unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,903 unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)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) 904 906 { 905 907 /* Do not answer notification callids */ … … 945 947 * 946 948 */ 947 unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data)949 sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data) 948 950 { 949 951 /* Do not answer notification callids */ … … 982 984 * 983 985 */ 984 unative_t sys_ipc_hangup(unative_t phoneid)986 sysarg_t sys_ipc_hangup(sysarg_t phoneid) 985 987 { 986 988 phone_t *phone; … … 1008 1010 * 1009 1011 */ 1010 unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,1012 sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, 1011 1013 unsigned int flags) 1012 1014 { … … 1037 1039 ipc_call_free(call); 1038 1040 1039 return (( unative_t) call) | IPC_CALLID_NOTIFICATION;1041 return ((sysarg_t) call) | IPC_CALLID_NOTIFICATION; 1040 1042 } 1041 1043 … … 1046 1048 ipc_call_free(call); 1047 1049 goto restart; 1048 } else {1049 /*1050 * Decrement the counter of active calls only if the1051 * call is not an answer to IPC_M_PHONE_HUNGUP,1052 * which doesn't contribute to the counter.1053 */1054 atomic_dec(&TASK->active_calls);1055 1050 } 1056 1051 … … 1058 1053 ipc_call_free(call); 1059 1054 1060 return (( unative_t) call) | IPC_CALLID_ANSWERED;1055 return ((sysarg_t) call) | IPC_CALLID_ANSWERED; 1061 1056 } 1062 1057 … … 1086 1081 } 1087 1082 1088 return ( unative_t) call;1083 return (sysarg_t) call; 1089 1084 } 1090 1085 … … 1092 1087 * 1093 1088 */ 1094 unative_t sys_ipc_poke(void)1089 sysarg_t sys_ipc_poke(void) 1095 1090 { 1096 1091 waitq_unsleep(&TASK->answerbox.wq); … … 1100 1095 /** Connect an IRQ handler to a task. 1101 1096 * 1102 * @param inr IRQ number.1103 * @param devno Device number.1104 * @param method Method to be associated with the notification.1105 * @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. 1106 1101 * 1107 1102 * @return EPERM or a return code returned by ipc_irq_register(). 1108 1103 * 1109 1104 */ 1110 unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_tmethod,1105 sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t imethod, 1111 1106 irq_code_t *ucode) 1112 1107 { … … 1114 1109 return EPERM; 1115 1110 1116 return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);1111 return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode); 1117 1112 } 1118 1113 … … 1125 1120 * 1126 1121 */ 1127 unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)1122 sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno) 1128 1123 { 1129 1124 if (!(cap_get(TASK) & CAP_IRQ_REG)) … … 1135 1130 } 1136 1131 1137 #i nclude <console/console.h>1138 1139 /** Syscall connect to a task by id.1132 #ifdef __32_BITS__ 1133 1134 /** Syscall connect to a task by ID (32 bits) 1140 1135 * 1141 1136 * @return Phone id on success, or negative error code. 1142 1137 * 1143 1138 */ 1144 unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)1139 sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid) 1145 1140 { 1146 1141 #ifdef CONFIG_UDEBUG 1147 sysarg64_t taskid _arg;1148 int rc = copy_from_uspace(&taskid _arg, uspace_taskid_arg, sizeof(sysarg64_t));1142 sysarg64_t taskid; 1143 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t)); 1149 1144 if (rc != 0) 1150 return (unative_t) rc; 1151 1152 LOG("sys_ipc_connect_kbox(%" PRIu64 ")", taskid_arg.value); 1153 1154 return ipc_connect_kbox(taskid_arg.value); 1145 return (sysarg_t) rc; 1146 1147 return ipc_connect_kbox((task_id_t) taskid); 1155 1148 #else 1156 return ( unative_t) ENOTSUP;1149 return (sysarg_t) ENOTSUP; 1157 1150 #endif 1158 1151 } 1159 1152 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 1160 1173 /** @} 1161 1174 */
Note:
See TracChangeset
for help on using the changeset viewer.
