Changeset c47e1a8 in mainline for kernel/generic/src/ipc
- Timestamp:
- 2010-05-21T07:50:04Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d51ee2b
- Parents:
- cf8cc36 (diff), 15b592b (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:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/event.c
rcf8cc36 rc47e1a8 38 38 #include <ipc/event_types.h> 39 39 #include <mm/slab.h> 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 #include <synch/spinlock.h> 42 42 #include <console/console.h> -
kernel/generic/src/ipc/ipc.c
rcf8cc36 rc47e1a8 218 218 answerbox_t *callerbox = call->callerbox; 219 219 bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox)); 220 ipl_t ipl; 221 222 /* Count sent answer */ 223 ipl = interrupts_disable(); 224 spinlock_lock(&TASK->lock); 225 TASK->ipc_info.answer_sent++; 226 spinlock_unlock(&TASK->lock); 227 interrupts_restore(ipl); 220 228 221 229 call->flags |= IPC_CALL_ANSWERED; … … 276 284 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) 277 285 { 286 ipl_t ipl; 287 288 /* Count sent ipc call */ 289 ipl = interrupts_disable(); 290 spinlock_lock(&TASK->lock); 291 TASK->ipc_info.call_sent++; 292 spinlock_unlock(&TASK->lock); 293 interrupts_restore(ipl); 294 278 295 if (!(call->flags & IPC_CALL_FORWARDED)) { 279 296 atomic_inc(&phone->active_calls); … … 376 393 int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode) 377 394 { 395 ipl_t ipl; 396 397 /* Count forwarded calls */ 398 ipl = interrupts_disable(); 399 spinlock_lock(&TASK->lock); 400 TASK->ipc_info.forwarded++; 401 spinlock_unlock(&TASK->lock); 402 interrupts_restore(ipl); 403 378 404 spinlock_lock(&oldbox->lock); 379 405 list_remove(&call->link); … … 407 433 call_t *request; 408 434 ipl_t ipl; 435 uint64_t irq_cnt = 0; 436 uint64_t answer_cnt = 0; 437 uint64_t call_cnt = 0; 409 438 int rc; 410 439 … … 416 445 spinlock_lock(&box->lock); 417 446 if (!list_empty(&box->irq_notifs)) { 447 /* Count recieved IRQ notification */ 448 irq_cnt++; 449 418 450 ipl = interrupts_disable(); 419 451 spinlock_lock(&box->irq_lock); … … 425 457 interrupts_restore(ipl); 426 458 } else if (!list_empty(&box->answers)) { 459 /* Count recieved answer */ 460 answer_cnt++; 461 427 462 /* Handle asynchronous answers */ 428 463 request = list_get_instance(box->answers.next, call_t, link); … … 430 465 atomic_dec(&request->data.phone->active_calls); 431 466 } else if (!list_empty(&box->calls)) { 467 /* Count recieved call */ 468 call_cnt++; 469 432 470 /* Handle requests */ 433 471 request = list_get_instance(box->calls.next, call_t, link); … … 441 479 } 442 480 spinlock_unlock(&box->lock); 481 482 ipl = interrupts_disable(); 483 spinlock_lock(&TASK->lock); 484 TASK->ipc_info.irq_notif_recieved += irq_cnt; 485 TASK->ipc_info.answer_recieved += answer_cnt; 486 TASK->ipc_info.call_recieved += call_cnt; 487 spinlock_unlock(&TASK->lock); 488 interrupts_restore(ipl); 489 443 490 return request; 444 491 } … … 644 691 call_t *call; 645 692 link_t *tmp; 693 ipl_t ipl; 646 694 695 ipl = interrupts_disable(); 647 696 spinlock_lock(&tasks_lock); 648 697 task = task_find_by_id(taskid); … … 650 699 spinlock_lock(&task->lock); 651 700 spinlock_unlock(&tasks_lock); 652 if (!task) 701 if (!task) { 702 interrupts_restore(ipl); 653 703 return; 704 } 654 705 655 706 /* Print opened phones & details */ … … 734 785 spinlock_unlock(&task->answerbox.lock); 735 786 spinlock_unlock(&task->lock); 787 interrupts_restore(ipl); 736 788 } 737 789 -
kernel/generic/src/ipc/kbox.c
rcf8cc36 rc47e1a8 47 47 void ipc_kbox_cleanup(void) 48 48 { 49 ipl_t ipl;50 49 bool have_kb_thread; 51 50 … … 78 77 * kbox thread to clean it up since sender != debugger. 79 78 */ 80 ipl = interrupts_disable(); 81 spinlock_lock(&TASK->lock); 79 mutex_lock(&TASK->udebug.lock); 82 80 udebug_task_cleanup(TASK); 83 spinlock_unlock(&TASK->lock); 84 interrupts_restore(ipl); 85 81 mutex_unlock(&TASK->udebug.lock); 82 86 83 if (have_kb_thread) { 87 84 LOG("Join kb.thread."); … … 126 123 ipc_answer(&TASK->kb.box, call); 127 124 125 mutex_lock(&TASK->kb.cleanup_lock); 126 128 127 ipl = interrupts_disable(); 129 128 spinlock_lock(&TASK->lock); … … 136 135 137 136 /* Only detach kbox thread unless already terminating. */ 138 mutex_lock(&TASK->kb.cleanup_lock);139 137 if (TASK->kb.finished == false) { 140 138 /* Detach kbox thread so it gets freed from memory. */ … … 142 140 TASK->kb.thread = NULL; 143 141 } 144 mutex_unlock(&TASK->kb.cleanup_lock);145 142 146 143 LOG("Phone list is empty."); … … 153 150 spinlock_unlock(&TASK->lock); 154 151 interrupts_restore(ipl); 152 153 mutex_unlock(&TASK->kb.cleanup_lock); 155 154 } 156 155 -
kernel/generic/src/ipc/sysipc.c
rcf8cc36 rc47e1a8 58 58 #define DATA_XFER_LIMIT (64 * 1024) 59 59 60 #define GET_CHECK_PHONE(phone, phoneid, err) \ 61 { \ 62 if (phoneid > IPC_MAX_PHONES) { \ 63 err \ 64 } \ 65 phone = &TASK->phones[phoneid]; \ 60 /** Get phone from the current task by ID. 61 * 62 * @param phoneid Phone ID. 63 * @param phone Place to store pointer to phone. 64 * @return EOK on success, EINVAL if ID is invalid. 65 */ 66 static int phone_get(unative_t phoneid, phone_t **phone) 67 { 68 if (phoneid >= IPC_MAX_PHONES) 69 return EINVAL; 70 71 *phone = &TASK->phones[phoneid]; 72 return EOK; 66 73 } 67 74 … … 374 381 case IPC_M_CONNECTION_CLONE: { 375 382 phone_t *cloned_phone; 376 GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data), 377 return ENOENT;); 383 384 if (phone_get(IPC_GET_ARG1(call->data), &cloned_phone) != EOK) 385 return ENOENT; 378 386 phones_lock(cloned_phone, phone); 387 379 388 if ((cloned_phone->state != IPC_PHONE_CONNECTED) || 380 389 phone->state != IPC_PHONE_CONNECTED) { … … 534 543 int res; 535 544 int rc; 536 537 GET_CHECK_PHONE(phone, phoneid, return ENOENT;); 545 546 if (phone_get(phoneid, &phone) != EOK) 547 return ENOENT; 538 548 539 549 call = ipc_call_alloc(0); … … 591 601 int rc; 592 602 593 GET_CHECK_PHONE(phone, phoneid, return ENOENT;); 603 if (phone_get(phoneid, &phone) != EOK) 604 return ENOENT; 594 605 595 606 call = ipc_call_alloc(0); … … 666 677 return IPC_CALLRET_TEMPORARY; 667 678 668 GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;); 679 if (phone_get(phoneid, &phone) != EOK) 680 return IPC_CALLRET_FATAL; 669 681 670 682 call = ipc_call_alloc(0); … … 705 717 return IPC_CALLRET_TEMPORARY; 706 718 707 GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL;); 719 if (phone_get(phoneid, &phone) != EOK) 720 return IPC_CALLRET_FATAL; 708 721 709 722 call = ipc_call_alloc(0); … … 755 768 call->flags |= IPC_CALL_FORWARDED; 756 769 757 GET_CHECK_PHONE(phone, phoneid,{770 if (phone_get(phoneid, &phone) != EOK) { 758 771 IPC_SET_RETVAL(call->data, EFORWARD); 759 772 ipc_answer(&TASK->answerbox, call); 760 773 return ENOENT; 761 } );774 } 762 775 763 776 if (!method_is_forwardable(IPC_GET_METHOD(call->data))) { … … 956 969 * @return Return 0 on success or an error code. 957 970 */ 958 unative_t sys_ipc_hangup( int phoneid)971 unative_t sys_ipc_hangup(unative_t phoneid) 959 972 { 960 973 phone_t *phone; 961 974 962 GET_CHECK_PHONE(phone, phoneid, return ENOENT;); 975 if (phone_get(phoneid, &phone) != EOK) 976 return ENOENT; 963 977 964 978 if (ipc_phone_hangup(phone))
Note:
See TracChangeset
for help on using the changeset viewer.
