Changes in kernel/generic/src/ipc/ipc.c [455241b:07d4271] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipc.c
r455241b r07d4271 71 71 static slab_cache_t *answerbox_cache; 72 72 73 slab_cache_t *irq_cache = NULL;74 73 slab_cache_t *phone_cache = NULL; 75 74 … … 88 87 call->callerbox = NULL; 89 88 call->buffer = NULL; 90 kobject_initialize(&call->kobject, KOBJECT_TYPE_CALL); 91 } 92 93 static void call_destroy(kobject_t *arg) 94 { 95 call_t *call = call_from_kobject(arg); 89 } 90 91 static void call_destroy(void *arg) 92 { 93 call_t *call = (call_t *) arg; 96 94 97 95 if (call->buffer) 98 96 free(call->buffer); 99 97 if (call->caller_phone) 100 kobject_put( &call->caller_phone->kobject);98 kobject_put(call->caller_phone->kobject); 101 99 slab_free(call_cache, call); 102 100 } … … 116 114 call_t *ipc_call_alloc(void) 117 115 { 116 // TODO: Allocate call and kobject in single allocation 117 118 118 call_t *call = slab_alloc(call_cache, FRAME_ATOMIC); 119 119 if (!call) 120 120 return NULL; 121 121 122 kobject_t *kobj = kobject_alloc(0); 123 if (!kobj) { 124 slab_free(call_cache, call); 125 return NULL; 126 } 127 122 128 _ipc_call_init(call); 129 kobject_initialize(kobj, KOBJECT_TYPE_CALL, call); 130 call->kobject = kobj; 123 131 124 132 return call; … … 173 181 if (!connected) { 174 182 /* We still have phone->kobject's reference; drop it */ 175 kobject_put( &phone->kobject);183 kobject_put(phone->kobject); 176 184 } 177 185 … … 193 201 atomic_store(&phone->active_calls, 0); 194 202 phone->label = 0; 195 kobject_initialize(&phone->kobject, KOBJECT_TYPE_PHONE);203 phone->kobject = NULL; 196 204 } 197 205 … … 286 294 /* This is a forgotten call and call->sender is not valid. */ 287 295 spinlock_unlock(&call->forget_lock); 288 kobject_put( &call->kobject);296 kobject_put(call->kobject); 289 297 return; 290 298 } else { … … 344 352 345 353 call->caller_phone = phone; 346 kobject_add_ref( &phone->kobject);354 kobject_add_ref(phone->kobject); 347 355 348 356 if (preforget) { … … 354 362 else 355 363 atomic_inc(&caller->answerbox.active_calls); 356 kobject_add_ref( &phone->kobject);364 kobject_add_ref(phone->kobject); 357 365 call->sender = caller; 358 366 call->active = true; … … 471 479 472 480 /* Drop the answerbox reference */ 473 kobject_put( &phone->kobject);481 kobject_put(phone->kobject); 474 482 475 483 call_t *call = phone->hangup_call; … … 573 581 atomic_dec(&request->caller_phone->active_calls); 574 582 atomic_dec(&box->active_calls); 575 kobject_put( &request->caller_phone->kobject);583 kobject_put(request->caller_phone->kobject); 576 584 } else if (!list_empty(&box->calls)) { 577 585 /* Count received call */ … … 689 697 task_release(phone->caller); 690 698 691 kobject_put( &phone->kobject);699 kobject_put(phone->kobject); 692 700 693 701 /* Must start again */ … … 696 704 697 705 mutex_unlock(&phone->lock); 698 kobject_put( &phone->kobject);706 kobject_put(phone->kobject); 699 707 } 700 708 … … 720 728 * must hold a reference to it. 721 729 */ 722 kobject_add_ref( &call->kobject);730 kobject_add_ref(call->kobject); 723 731 724 732 spinlock_unlock(&call->forget_lock); … … 727 735 atomic_dec(&call->caller_phone->active_calls); 728 736 atomic_dec(&TASK->answerbox.active_calls); 729 kobject_put( &call->caller_phone->kobject);737 kobject_put(call->caller_phone->kobject); 730 738 731 739 SYSIPC_OP(request_forget, call); 732 740 733 kobject_put( &call->kobject);741 kobject_put(call->kobject); 734 742 } 735 743 … … 769 777 static bool phone_cap_cleanup_cb(cap_t *cap, void *arg) 770 778 { 771 ipc_phone_hangup( phone_from_kobject(cap->kobject));779 ipc_phone_hangup(cap->kobject->phone); 772 780 kobject_t *kobj = cap_unpublish(cap->task, cap->handle, 773 781 KOBJECT_TYPE_PHONE); … … 790 798 SYSIPC_OP(answer_process, call); 791 799 792 kobject_put( &call->kobject);800 kobject_put(call->kobject); 793 801 794 802 /* … … 884 892 answerbox_cache = slab_cache_create("answerbox_t", sizeof(answerbox_t), 885 893 0, NULL, NULL, 0); 886 irq_cache = slab_cache_create("irq_t", sizeof(irq_kobject_t),887 0, NULL, NULL, 0);888 894 } 889 895 … … 921 927 static bool print_task_phone_cb(cap_t *cap, void *arg) 922 928 { 923 phone_t *phone = phone_from_kobject(cap->kobject);929 phone_t *phone = cap->kobject->phone; 924 930 925 931 mutex_lock(&phone->lock);
Note:
See TracChangeset
for help on using the changeset viewer.