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