Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    r07d4271 r455241b  
    7171static slab_cache_t *answerbox_cache;
    7272
     73slab_cache_t *irq_cache = NULL;
    7374slab_cache_t *phone_cache = NULL;
    7475
     
    8788        call->callerbox = NULL;
    8889        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
     93static void call_destroy(kobject_t *arg)
     94{
     95        call_t *call = call_from_kobject(arg);
    9496
    9597        if (call->buffer)
    9698                free(call->buffer);
    9799        if (call->caller_phone)
    98                 kobject_put(call->caller_phone->kobject);
     100                kobject_put(&call->caller_phone->kobject);
    99101        slab_free(call_cache, call);
    100102}
     
    114116call_t *ipc_call_alloc(void)
    115117{
    116         // TODO: Allocate call and kobject in single allocation
    117 
    118118        call_t *call = slab_alloc(call_cache, FRAME_ATOMIC);
    119119        if (!call)
    120120                return NULL;
    121121
    122         kobject_t *kobj = kobject_alloc(0);
    123         if (!kobj) {
    124                 slab_free(call_cache, call);
    125                 return NULL;
    126         }
    127 
    128122        _ipc_call_init(call);
    129         kobject_initialize(kobj, KOBJECT_TYPE_CALL, call);
    130         call->kobject = kobj;
    131123
    132124        return call;
     
    181173        if (!connected) {
    182174                /* We still have phone->kobject's reference; drop it */
    183                 kobject_put(phone->kobject);
     175                kobject_put(&phone->kobject);
    184176        }
    185177
     
    201193        atomic_store(&phone->active_calls, 0);
    202194        phone->label = 0;
    203         phone->kobject = NULL;
     195        kobject_initialize(&phone->kobject, KOBJECT_TYPE_PHONE);
    204196}
    205197
     
    294286                /* This is a forgotten call and call->sender is not valid. */
    295287                spinlock_unlock(&call->forget_lock);
    296                 kobject_put(call->kobject);
     288                kobject_put(&call->kobject);
    297289                return;
    298290        } else {
     
    352344
    353345        call->caller_phone = phone;
    354         kobject_add_ref(phone->kobject);
     346        kobject_add_ref(&phone->kobject);
    355347
    356348        if (preforget) {
     
    362354                else
    363355                        atomic_inc(&caller->answerbox.active_calls);
    364                 kobject_add_ref(phone->kobject);
     356                kobject_add_ref(&phone->kobject);
    365357                call->sender = caller;
    366358                call->active = true;
     
    479471
    480472                /* Drop the answerbox reference */
    481                 kobject_put(phone->kobject);
     473                kobject_put(&phone->kobject);
    482474
    483475                call_t *call = phone->hangup_call;
     
    581573                atomic_dec(&request->caller_phone->active_calls);
    582574                atomic_dec(&box->active_calls);
    583                 kobject_put(request->caller_phone->kobject);
     575                kobject_put(&request->caller_phone->kobject);
    584576        } else if (!list_empty(&box->calls)) {
    585577                /* Count received call */
     
    697689                        task_release(phone->caller);
    698690
    699                         kobject_put(phone->kobject);
     691                        kobject_put(&phone->kobject);
    700692
    701693                        /* Must start again */
     
    704696
    705697                mutex_unlock(&phone->lock);
    706                 kobject_put(phone->kobject);
     698                kobject_put(&phone->kobject);
    707699        }
    708700
     
    728720         * must hold a reference to it.
    729721         */
    730         kobject_add_ref(call->kobject);
     722        kobject_add_ref(&call->kobject);
    731723
    732724        spinlock_unlock(&call->forget_lock);
     
    735727        atomic_dec(&call->caller_phone->active_calls);
    736728        atomic_dec(&TASK->answerbox.active_calls);
    737         kobject_put(call->caller_phone->kobject);
     729        kobject_put(&call->caller_phone->kobject);
    738730
    739731        SYSIPC_OP(request_forget, call);
    740732
    741         kobject_put(call->kobject);
     733        kobject_put(&call->kobject);
    742734}
    743735
     
    777769static bool phone_cap_cleanup_cb(cap_t *cap, void *arg)
    778770{
    779         ipc_phone_hangup(cap->kobject->phone);
     771        ipc_phone_hangup(phone_from_kobject(cap->kobject));
    780772        kobject_t *kobj = cap_unpublish(cap->task, cap->handle,
    781773            KOBJECT_TYPE_PHONE);
     
    798790                SYSIPC_OP(answer_process, call);
    799791
    800                 kobject_put(call->kobject);
     792                kobject_put(&call->kobject);
    801793
    802794                /*
     
    892884        answerbox_cache = slab_cache_create("answerbox_t", sizeof(answerbox_t),
    893885            0, NULL, NULL, 0);
     886        irq_cache = slab_cache_create("irq_t", sizeof(irq_kobject_t),
     887            0, NULL, NULL, 0);
    894888}
    895889
     
    927921static bool print_task_phone_cb(cap_t *cap, void *arg)
    928922{
    929         phone_t *phone = cap->kobject->phone;
     923        phone_t *phone = phone_from_kobject(cap->kobject);
    930924
    931925        mutex_lock(&phone->lock);
Note: See TracChangeset for help on using the changeset viewer.