Changeset 455241b in mainline


Ignore:
Timestamp:
2025-01-16T19:29:20Z (23 hours ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
6caf5fb
Parents:
df721df
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-16 19:23:14)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-16 19:29:20)
Message:

Integrate kobject_t into target structures

This just means fewer allocations and indirections.

Location:
kernel/generic
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/cap/cap.h

    rdf721df r455241b  
    6060} kobject_type_t;
    6161
    62 struct task;
    63 
    64 struct call;
    65 struct irq;
    66 struct phone;
    67 struct waitq;
     62struct kobject;
    6863
    6964typedef struct kobject_ops {
    70         void (*destroy)(void *);
     65        void (*destroy)(struct kobject *);
    7166} kobject_ops_t;
    7267
     
    7772/*
    7873 * Everything in kobject_t except for the atomic reference count, the capability
    79  * list and its lock is imutable.
     74 * list and its lock is immutable.
    8075 */
    8176typedef struct kobject {
     
    8782        /** List of published capabilities associated with the kobject */
    8883        list_t caps_list;
    89 
    90         union {
    91                 void *raw;
    92                 struct call *call;
    93                 struct irq *irq;
    94                 struct phone *phone;
    95                 struct waitq *waitq;
    96         };
    9784} kobject_t;
    9885
     
    141128extern void cap_free(struct task *, cap_handle_t);
    142129
    143 extern kobject_t *kobject_alloc(unsigned int);
    144 extern void kobject_free(kobject_t *);
    145 extern void kobject_initialize(kobject_t *, kobject_type_t, void *);
     130extern void kobject_initialize(kobject_t *, kobject_type_t);
    146131extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t);
    147132extern void kobject_add_ref(kobject_t *);
  • kernel/generic/include/ddi/irq.h

    rdf721df r455241b  
    132132extern hash_table_t irq_uspace_hash_table;
    133133
    134 extern slab_cache_t *irq_cache;
    135 
    136134extern inr_t last_inr;
    137135
  • kernel/generic/include/ipc/ipc.h

    rdf721df r455241b  
    7474        /** User-defined label */
    7575        sysarg_t label;
    76         kobject_t *kobject;
     76        kobject_t kobject;
    7777} phone_t;
    7878
     
    108108
    109109typedef struct call {
    110         kobject_t *kobject;
     110        kobject_t kobject;
    111111
    112112        /**
     
    169169
    170170extern slab_cache_t *phone_cache;
     171extern slab_cache_t *irq_cache;
    171172
    172173extern answerbox_t *ipc_box_0;
    173174
    174175extern kobject_ops_t call_kobject_ops;
     176
     177static inline phone_t *phone_from_kobject(kobject_t *kobject)
     178{
     179        if (kobject)
     180                return ((void *) kobject) - offsetof(phone_t, kobject);
     181        else
     182                return NULL;
     183}
     184
     185static inline call_t *call_from_kobject(kobject_t *kobject)
     186{
     187        if (kobject)
     188                return ((void *) kobject) - offsetof(call_t, kobject);
     189        else
     190                return NULL;
     191}
    175192
    176193extern void ipc_init(void);
  • kernel/generic/include/ipc/irq.h

    rdf721df r455241b  
    5050extern kobject_ops_t irq_kobject_ops;
    5151
     52typedef struct {
     53        kobject_t kobject;
     54        irq_t irq;
     55} irq_kobject_t;
     56
     57static inline irq_t *irq_from_kobject(kobject_t *kobject)
     58{
     59        if (kobject) {
     60                return &((irq_kobject_t *) kobject)->irq;
     61        } else {
     62                return NULL;
     63        }
     64}
     65
    5266extern irq_ownership_t ipc_irq_top_half_claim(irq_t *);
    5367extern void ipc_irq_top_half_handler(irq_t *);
  • kernel/generic/src/cap/cap.c

    rdf721df r455241b  
    9797
    9898static slab_cache_t *cap_cache;
    99 static slab_cache_t *kobject_cache;
    10099
    101100kobject_ops_t *kobject_ops[KOBJECT_TYPE_MAX] = {
     
    156155        cap_cache = slab_cache_create("cap_t", sizeof(cap_t), 0, NULL,
    157156            NULL, 0);
    158         kobject_cache = slab_cache_create("kobject_t", sizeof(kobject_t), 0,
    159             NULL, NULL, 0);
    160157}
    161158
     
    463460}
    464461
    465 kobject_t *kobject_alloc(unsigned int flags)
    466 {
    467         return slab_alloc(kobject_cache, flags);
    468 }
    469 
    470 void kobject_free(kobject_t *kobj)
    471 {
    472         slab_free(kobject_cache, kobj);
    473 }
    474 
    475462/** Initialize kernel object
    476463 *
    477464 * @param kobj  Kernel object to initialize.
    478465 * @param type  Type of the kernel object.
    479  * @param raw   Raw pointer to the encapsulated object.
    480  */
    481 void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw)
     466 */
     467void kobject_initialize(kobject_t *kobj, kobject_type_t type)
    482468{
    483469        refcount_init(&kobj->refcnt);
     
    487473
    488474        kobj->type = type;
    489         kobj->raw = raw;
    490475}
    491476
     
    537522{
    538523        if (refcount_down(&kobj->refcnt)) {
    539                 KOBJECT_OP(kobj)->destroy(kobj->raw);
    540                 kobject_free(kobj);
     524                KOBJECT_OP(kobj)->destroy(kobj);
    541525        }
    542526}
  • kernel/generic/src/ddi/irq.c

    rdf721df r455241b  
    5050#include <arch.h>
    5151
    52 slab_cache_t *irq_cache = NULL;
    53 
    5452/** Spinlock protecting the kernel IRQ hash table
    5553 *
     
    9694{
    9795        last_inr = inrs - 1;
    98 
    99         irq_cache = slab_cache_create("irq_t", sizeof(irq_t), 0, NULL, NULL,
    100             FRAME_ATOMIC);
    101         assert(irq_cache);
    10296
    10397        hash_table_create(&irq_uspace_hash_table, chains, 0, &irq_ht_ops);
  • kernel/generic/src/ipc/ipc.c

    rdf721df 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);
  • kernel/generic/src/ipc/ipcrsc.c

    rdf721df r455241b  
    4444#include <stdlib.h>
    4545
    46 static void phone_destroy(void *arg)
     46static void phone_destroy(kobject_t *arg)
    4747{
    48         phone_t *phone = (phone_t *) arg;
     48        phone_t *phone = phone_from_kobject(arg);
    4949        if (phone->hangup_call)
    50                 kobject_put(phone->hangup_call->kobject);
     50                kobject_put(&phone->hangup_call->kobject);
    5151        slab_free(phone_cache, phone);
    5252}
     
    7676                        return ENOMEM;
    7777                }
    78                 kobject_t *kobj = kobject_alloc(FRAME_ATOMIC);
    79                 if (!kobj) {
    80                         cap_free(TASK, handle);
    81                         slab_free(phone_cache, phone);
    82                         return ENOMEM;
    83                 }
     78
    8479                call_t *hcall = ipc_call_alloc();
    8580                if (!hcall) {
    8681                        cap_free(TASK, handle);
    8782                        slab_free(phone_cache, phone);
    88                         free(kobj);
    8983                        return ENOMEM;
    9084                }
     
    9488                phone->hangup_call = hcall;
    9589
    96                 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone);
    97                 phone->kobject = kobj;
    98 
    9990                if (publish)
    100                         cap_publish(task, handle, kobj);
     91                        cap_publish(task, handle, &phone->kobject);
    10192
    10293                *phandle = handle;
    10394                if (kobject)
    104                         *kobject = kobj;
     95                        *kobject = &phone->kobject;
    10596        }
    10697        return rc;
  • kernel/generic/src/ipc/irq.c

    rdf721df r455241b  
    295295}
    296296
    297 static void irq_destroy(void *arg)
    298 {
    299         irq_t *irq = (irq_t *) arg;
    300 
    301         irq_hash_out(irq);
     297static void irq_destroy(kobject_t *arg)
     298{
     299        irq_kobject_t *kobj = (irq_kobject_t *) arg;
     300
     301        irq_hash_out(&kobj->irq);
    302302
    303303        /* Free up the IRQ code and associated structures. */
    304         code_free(irq->notif_cfg.code);
    305         slab_free(irq_cache, irq);
     304        code_free(kobj->irq.notif_cfg.code);
     305        slab_free(irq_cache, kobj);
    306306}
    307307
     
    350350        }
    351351
    352         irq_t *irq = (irq_t *) slab_alloc(irq_cache, FRAME_ATOMIC);
    353         if (!irq) {
     352        irq_kobject_t *kobj = slab_alloc(irq_cache, FRAME_ATOMIC);
     353        if (!kobj) {
    354354                cap_free(TASK, handle);
    355355                return ENOMEM;
    356356        }
    357357
    358         kobject_t *kobject = kobject_alloc(FRAME_ATOMIC);
    359         if (!kobject) {
    360                 cap_free(TASK, handle);
    361                 slab_free(irq_cache, irq);
    362                 return ENOMEM;
    363         }
     358        kobject_initialize(&kobj->kobject, KOBJECT_TYPE_IRQ);
     359
     360        irq_t *irq = &kobj->irq;
    364361
    365362        irq_initialize(irq);
     
    385382        irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
    386383
    387         kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq);
    388         cap_publish(TASK, handle, kobject);
     384        cap_publish(TASK, handle, &kobj->kobject);
    389385
    390386        return EOK;
     
    405401                return ENOENT;
    406402
    407         assert(kobj->irq->notif_cfg.answerbox == box);
    408 
    409         irq_hash_out(kobj->irq);
     403        assert(irq_from_kobject(kobj)->notif_cfg.answerbox == box);
     404
     405        irq_hash_out(irq_from_kobject(kobj));
    410406
    411407        kobject_put(kobj);
  • kernel/generic/src/ipc/kbox.c

    rdf721df r455241b  
    242242        }
    243243
    244         kobject_t *phone_obj = kobject_get(TASK, phone_handle,
    245             KOBJECT_TYPE_PHONE);
     244        phone_t *phone = phone_from_kobject(
     245            kobject_get(TASK, phone_handle, KOBJECT_TYPE_PHONE));
    246246        /* Connect the newly allocated phone to the kbox */
    247247        /* Hand over phone_obj's reference to ipc_phone_connect() */
    248         (void) ipc_phone_connect(phone_obj->phone, &task->kb.box);
     248        (void) ipc_phone_connect(phone, &task->kb.box);
    249249
    250250        mutex_unlock(&task->kb.cleanup_lock);
  • kernel/generic/src/ipc/ops/conctmeto.c

    rdf721df r455241b  
    8888
    8989        /* Set the recipient-assigned label */
    90         pobj->phone->label = ipc_get_arg5(&answer->data);
     90        phone_from_kobject(pobj)->label = ipc_get_arg5(&answer->data);
    9191
    9292        /* Restore phone handle in answer's ARG5 */
     
    9696        if (ipc_get_retval(&answer->data) == EOK) {
    9797                /* Hand over reference from pobj to the answerbox */
    98                 (void) ipc_phone_connect(pobj->phone, &TASK->answerbox);
     98                (void) ipc_phone_connect(phone_from_kobject(pobj), &TASK->answerbox);
    9999        } else {
    100100                /* Drop the extra reference */
  • kernel/generic/src/ipc/ops/concttome.c

    rdf721df r455241b  
    4949                 * Set the sender-assigned label to the new phone.
    5050                 */
    51                 pobj->phone->label = ipc_get_arg5(&call->data);
     51                phone_from_kobject(pobj)->label = ipc_get_arg5(&call->data);
    5252        }
    5353        call->priv = (sysarg_t) pobj;
     
    8888                kobject_add_ref(pobj);
    8989
    90                 if (ipc_phone_connect(pobj->phone,
     90                if (ipc_phone_connect(phone_from_kobject(pobj),
    9191                    &answer->sender->answerbox)) {
    9292                        /* Pass the reference to the capability */
  • kernel/generic/src/ipc/ops/stchngath.c

    rdf721df r455241b  
    4545        task_t *other_task_s;
    4646
    47         kobject_t *sender_obj = kobject_get(TASK,
    48             (cap_handle_t) ipc_get_arg5(&call->data), KOBJECT_TYPE_PHONE);
    49         if (!sender_obj)
     47        phone_t *sender_phone = phone_from_kobject(kobject_get(TASK,
     48            (cap_handle_t) ipc_get_arg5(&call->data), KOBJECT_TYPE_PHONE));
     49        if (!sender_phone)
    5050                return ENOENT;
    5151
    52         mutex_lock(&sender_obj->phone->lock);
    53         if (sender_obj->phone->state != IPC_PHONE_CONNECTED) {
    54                 mutex_unlock(&sender_obj->phone->lock);
    55                 kobject_put(sender_obj);
     52        mutex_lock(&sender_phone->lock);
     53        if (sender_phone->state != IPC_PHONE_CONNECTED) {
     54                mutex_unlock(&sender_phone->lock);
     55                kobject_put(&sender_phone->kobject);
    5656                return EINVAL;
    5757        }
    5858
    59         other_task_s = sender_obj->phone->callee->task;
     59        other_task_s = sender_phone->callee->task;
    6060
    61         mutex_unlock(&sender_obj->phone->lock);
     61        mutex_unlock(&sender_phone->lock);
    6262
    6363        /* Remember the third party task hash. */
    6464        ipc_set_arg5(&call->data, (sysarg_t) other_task_s);
    6565
    66         kobject_put(sender_obj);
     66        kobject_put(&sender_phone->kobject);
    6767        return EOK;
    6868}
     
    7777                task_t *other_task_r;
    7878
    79                 kobject_t *recipient_obj = kobject_get(TASK,
     79                phone_t *recipient_phone = phone_from_kobject(kobject_get(TASK,
    8080                    (cap_handle_t) ipc_get_arg1(&answer->data),
    81                     KOBJECT_TYPE_PHONE);
    82                 if (!recipient_obj) {
     81                    KOBJECT_TYPE_PHONE));
     82                if (!recipient_phone) {
    8383                        ipc_set_retval(&answer->data, ENOENT);
    8484                        return ENOENT;
    8585                }
    8686
    87                 mutex_lock(&recipient_obj->phone->lock);
    88                 if (recipient_obj->phone->state != IPC_PHONE_CONNECTED) {
    89                         mutex_unlock(&recipient_obj->phone->lock);
     87                mutex_lock(&recipient_phone->lock);
     88                if (recipient_phone->state != IPC_PHONE_CONNECTED) {
     89                        mutex_unlock(&recipient_phone->lock);
    9090                        ipc_set_retval(&answer->data, EINVAL);
    91                         kobject_put(recipient_obj);
     91                        kobject_put(&recipient_phone->kobject);
    9292                        return EINVAL;
    9393                }
    9494
    95                 other_task_r = recipient_obj->phone->callee->task;
     95                other_task_r = recipient_phone->callee->task;
    9696                other_task_s = (task_t *) ipc_get_arg5(olddata);
    9797
     
    114114                }
    115115
    116                 mutex_unlock(&recipient_obj->phone->lock);
    117                 kobject_put(recipient_obj);
     116                mutex_unlock(&recipient_phone->lock);
     117                kobject_put(&recipient_phone->kobject);
    118118        }
    119119
  • kernel/generic/src/ipc/sysipc.c

    rdf721df r455241b  
    199199                        list_remove(&phone->link);
    200200                        /* Drop callee->connected_phones reference */
    201                         kobject_put(phone->kobject);
     201                        kobject_put(&phone->kobject);
    202202                        phone->state = IPC_PHONE_SLAMMED;
    203203                        phone->label = 0;
     
    273273ipc_req_internal(cap_phone_handle_t handle, ipc_data_t *data, sysarg_t priv)
    274274{
    275         kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE);
    276         if (!kobj->phone)
     275        phone_t *phone = phone_from_kobject(
     276            kobject_get(TASK, handle, KOBJECT_TYPE_PHONE));
     277        if (!phone)
    277278                return ENOENT;
    278279
    279280        call_t *call = ipc_call_alloc();
    280281        if (!call) {
    281                 kobject_put(kobj);
     282                kobject_put(&phone->kobject);
    282283                return ENOMEM;
    283284        }
     
    286287        memcpy(call->data.args, data->args, sizeof(data->args));
    287288
    288         errno_t rc = request_preprocess(call, kobj->phone);
     289        errno_t rc = request_preprocess(call, phone);
    289290        if (!rc) {
    290291#ifdef CONFIG_UDEBUG
     
    292293#endif
    293294
    294                 kobject_add_ref(call->kobject);
    295                 rc = ipc_call_sync(kobj->phone, call);
     295                kobject_add_ref(&call->kobject);
     296                rc = ipc_call_sync(phone, call);
    296297                spinlock_lock(&call->forget_lock);
    297298                bool forgotten = call->forget;
    298299                spinlock_unlock(&call->forget_lock);
    299                 kobject_put(call->kobject);
     300                kobject_put(&call->kobject);
    300301
    301302#ifdef CONFIG_UDEBUG
     
    312313                                 * deallocation.
    313314                                 */
    314                                 kobject_put(call->kobject);
     315                                kobject_put(&call->kobject);
    315316                        } else {
    316317                                /*
     
    320321                                assert(rc == EINTR);
    321322                        }
    322                         kobject_put(kobj);
     323                        kobject_put(&phone->kobject);
    323324                        return rc;
    324325                }
     
    329330
    330331        memcpy(data->args, call->data.args, sizeof(data->args));
    331         kobject_put(call->kobject);
    332         kobject_put(kobj);
     332        kobject_put(&call->kobject);
     333        kobject_put(&phone->kobject);
    333334
    334335        return EOK;
     
    370371    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t label)
    371372{
    372         kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE);
    373         if (!kobj)
     373        phone_t *phone = phone_from_kobject(
     374            kobject_get(TASK, handle, KOBJECT_TYPE_PHONE));
     375
     376        if (!phone)
    374377                return ENOENT;
    375378
    376         if (check_call_limit(kobj->phone)) {
    377                 kobject_put(kobj);
     379        if (check_call_limit(phone)) {
     380                kobject_put(&phone->kobject);
    378381                return ELIMIT;
    379382        }
     
    381384        call_t *call = ipc_call_alloc();
    382385        if (!call) {
    383                 kobject_put(kobj);
     386                kobject_put(&phone->kobject);
    384387                return ENOMEM;
    385388        }
     
    399402        call->data.answer_label = label;
    400403
    401         errno_t res = request_preprocess(call, kobj->phone);
     404        errno_t res = request_preprocess(call, phone);
    402405
    403406        if (!res)
    404                 ipc_call(kobj->phone, call);
     407                ipc_call(phone, call);
    405408        else
    406                 ipc_backsend_err(kobj->phone, call, res);
    407 
    408         kobject_put(kobj);
     409                ipc_backsend_err(phone, call, res);
     410
     411        kobject_put(&phone->kobject);
    409412        return EOK;
    410413}
     
    422425    sysarg_t label)
    423426{
    424         kobject_t *kobj = kobject_get(TASK, handle, KOBJECT_TYPE_PHONE);
    425         if (!kobj)
     427        phone_t *phone = phone_from_kobject(
     428            kobject_get(TASK, handle, KOBJECT_TYPE_PHONE));
     429        if (!phone)
    426430                return ENOENT;
    427431
    428         if (check_call_limit(kobj->phone)) {
    429                 kobject_put(kobj);
     432        if (check_call_limit(phone)) {
     433                kobject_put(&phone->kobject);
    430434                return ELIMIT;
    431435        }
     
    433437        call_t *call = ipc_call_alloc();
    434438        if (!call) {
    435                 kobject_put(kobj);
     439                kobject_put(&phone->kobject);
    436440                return ENOMEM;
    437441        }
     
    440444            sizeof(call->data.args));
    441445        if (rc != EOK) {
    442                 kobject_put(call->kobject);
    443                 kobject_put(kobj);
     446                kobject_put(&call->kobject);
     447                kobject_put(&phone->kobject);
    444448                return (sys_errno_t) rc;
    445449        }
     
    448452        call->data.answer_label = label;
    449453
    450         errno_t res = request_preprocess(call, kobj->phone);
     454        errno_t res = request_preprocess(call, phone);
    451455
    452456        if (!res)
    453                 ipc_call(kobj->phone, call);
     457                ipc_call(phone, call);
    454458        else
    455                 ipc_backsend_err(kobj->phone, call, res);
    456 
    457         kobject_put(kobj);
     459                ipc_backsend_err(phone, call, res);
     460
     461        kobject_put(&phone->kobject);
    458462        return EOK;
    459463}
     
    489493                return ENOENT;
    490494
    491         call_t *call = ckobj->call;
     495        call_t *call = call_from_kobject(ckobj);
    492496
    493497        ipc_data_t old;
     
    551555        }
    552556
    553         rc = ipc_forward(call, pkobj->phone, &TASK->answerbox, mode);
     557        rc = ipc_forward(call, phone_from_kobject(pkobj), &TASK->answerbox, mode);
    554558        if (rc != EOK) {
    555559                after_forward = true;
     
    659663                return ENOENT;
    660664
    661         call_t *call = kobj->call;
     665        call_t *call = call_from_kobject(kobj);
    662666        assert(!(call->flags & IPC_CALL_ANSWERED));
    663667
     
    706710                return ENOENT;
    707711
    708         call_t *call = kobj->call;
     712        call_t *call = call_from_kobject(kobj);
    709713        assert(!(call->flags & IPC_CALL_ANSWERED));
    710714
     
    751755                return ENOENT;
    752756
    753         errno_t rc = ipc_phone_hangup(kobj->phone);
     757        errno_t rc = ipc_phone_hangup(phone_from_kobject(kobj));
    754758        kobject_put(kobj);
    755759        cap_free(TASK, handle);
     
    797801
    798802                STRUCT_TO_USPACE(calldata, &call->data);
    799                 kobject_put(call->kobject);
     803                kobject_put(&call->kobject);
    800804
    801805                return EOK;
     
    806810
    807811                if (call->flags & IPC_CALL_DISCARD_ANSWER) {
    808                         kobject_put(call->kobject);
     812                        kobject_put(&call->kobject);
    809813                        goto restart;
    810814                }
     
    813817
    814818                STRUCT_TO_USPACE(calldata, &call->data);
    815                 kobject_put(call->kobject);
     819                kobject_put(&call->kobject);
    816820
    817821                return EOK;
     
    836840                goto error;
    837841
    838         kobject_add_ref(call->kobject);
    839         cap_publish(TASK, handle, call->kobject);
     842        kobject_add_ref(&call->kobject);
     843        cap_publish(TASK, handle, &call->kobject);
    840844        return EOK;
    841845
  • kernel/generic/src/proc/task.c

    rdf721df r455241b  
    251251                }
    252252
    253                 kobject_t *phone_obj = kobject_get(task, phone_handle,
    254                     KOBJECT_TYPE_PHONE);
    255                 (void) ipc_phone_connect(phone_obj->phone, ipc_box_0);
     253                phone_t *phone = phone_from_kobject(
     254                    kobject_get(task, phone_handle, KOBJECT_TYPE_PHONE));
     255                (void) ipc_phone_connect(phone, ipc_box_0);
    256256        }
    257257
  • kernel/generic/src/synch/syswaitq.c

    rdf721df r455241b  
    4848static slab_cache_t *waitq_cache;
    4949
    50 static void waitq_destroy(void *arg)
     50typedef struct {
     51        kobject_t kobject;
     52        waitq_t waitq;
     53} waitq_kobject_t;
     54
     55static void waitq_destroy(kobject_t *arg)
    5156{
    52         waitq_t *wq = (waitq_t *) arg;
     57        waitq_kobject_t *wq = (waitq_kobject_t *) arg;
    5358        slab_free(waitq_cache, wq);
    5459}
    5560
    5661kobject_ops_t waitq_kobject_ops = {
    57         .destroy = waitq_destroy
     62        .destroy = waitq_destroy,
    5863};
    5964
     
    6166void sys_waitq_init(void)
    6267{
    63         waitq_cache = slab_cache_create("waitq_t", sizeof(waitq_t), 0, NULL,
    64             NULL, 0);
     68        waitq_cache = slab_cache_create("syswaitq_t", sizeof(waitq_kobject_t),
     69            0, NULL, NULL, 0);
    6570}
    6671
     
    7479sys_errno_t sys_waitq_create(uspace_ptr_cap_waitq_handle_t whandle)
    7580{
    76         waitq_t *wq = slab_alloc(waitq_cache, FRAME_ATOMIC);
    77         if (!wq)
     81        waitq_kobject_t *kobj = slab_alloc(waitq_cache, FRAME_ATOMIC);
     82        if (!kobj)
    7883                return (sys_errno_t) ENOMEM;
    79         waitq_initialize(wq);
    8084
    81         kobject_t *kobj = kobject_alloc(0);
    82         if (!kobj) {
    83                 slab_free(waitq_cache, wq);
    84                 return (sys_errno_t) ENOMEM;
    85         }
    86         kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq);
     85        kobject_initialize(&kobj->kobject, KOBJECT_TYPE_WAITQ);
     86        waitq_initialize(&kobj->waitq);
    8787
    8888        cap_handle_t handle;
    8989        errno_t rc = cap_alloc(TASK, &handle);
    9090        if (rc != EOK) {
    91                 slab_free(waitq_cache, wq);
    92                 kobject_free(kobj);
     91                slab_free(waitq_cache, kobj);
    9392                return (sys_errno_t) rc;
    9493        }
     
    9796        if (rc != EOK) {
    9897                cap_free(TASK, handle);
    99                 kobject_free(kobj);
    100                 slab_free(waitq_cache, wq);
     98                slab_free(waitq_cache, kobj);
    10199                return (sys_errno_t) rc;
    102100        }
    103101
    104         cap_publish(TASK, handle, kobj);
     102        cap_publish(TASK, handle, &kobj->kobject);
    105103
    106104        return (sys_errno_t) EOK;
     
    135133    unsigned int flags)
    136134{
    137         kobject_t *kobj = kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ);
     135        waitq_kobject_t *kobj =
     136            (waitq_kobject_t *) kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ);
    138137        if (!kobj)
    139138                return (sys_errno_t) ENOENT;
     
    143142#endif
    144143
    145         errno_t rc = _waitq_sleep_timeout(kobj->waitq, timeout,
     144        errno_t rc = _waitq_sleep_timeout(&kobj->waitq, timeout,
    146145            SYNCH_FLAGS_INTERRUPTIBLE | flags);
    147146
     
    150149#endif
    151150
    152         kobject_put(kobj);
     151        kobject_put(&kobj->kobject);
    153152
    154153        return (sys_errno_t) rc;
     
    163162sys_errno_t sys_waitq_wakeup(cap_waitq_handle_t whandle)
    164163{
    165         kobject_t *kobj = kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ);
     164        waitq_kobject_t *kobj =
     165            (waitq_kobject_t *) kobject_get(TASK, whandle, KOBJECT_TYPE_WAITQ);
    166166        if (!kobj)
    167167                return (sys_errno_t) ENOENT;
    168168
    169         waitq_wake_one(kobj->waitq);
     169        waitq_wake_one(&kobj->waitq);
    170170
    171         kobject_put(kobj);
     171        kobject_put(&kobj->kobject);
    172172        return (sys_errno_t) EOK;
    173173}
  • kernel/generic/src/sysinfo/stats.c

    rdf721df r455241b  
    384384static bool produce_stats_ipcc_cb(cap_t *cap, void *arg)
    385385{
    386         phone_t *phone = cap->kobject->phone;
     386        phone_t *phone = (phone_t *) cap->kobject;
    387387        ipccs_state_t *state = (ipccs_state_t *) arg;
    388388
Note: See TracChangeset for help on using the changeset viewer.