Changeset fc0de8c in mainline for kernel/generic/src


Ignore:
Timestamp:
2019-10-14T15:30:30Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46a8c3cd
Parents:
f1cd4b0
git-author:
Jakub Jermar <jakub@…> (2019-10-14 15:27:34)
git-committer:
Jakub Jermar <jakub@…> (2019-10-14 15:30:30)
Message:

Move kobject's ops out of kobject

Kobject ops is a property of the kobject type rather than the individual
kernel objects. There is no need to remember the ops in every single
instance.

Location:
kernel/generic/src
Files:
5 edited

Legend:

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

    rf1cd4b0 rfc0de8c  
    8383#include <mm/slab.h>
    8484#include <adt/list.h>
     85#include <synch/syswaitq.h>
     86#include <ipc/ipcrsc.h>
     87#include <ipc/ipc.h>
     88#include <ipc/irq.h>
    8589
    8690#include <limits.h>
     
    9498static slab_cache_t *cap_cache;
    9599static slab_cache_t *kobject_cache;
     100
     101kobject_ops_t *kobject_ops[KOBJECT_TYPE_MAX] = {
     102        [KOBJECT_TYPE_CALL] = &call_kobject_ops,
     103        [KOBJECT_TYPE_IRQ] = &irq_kobject_ops,
     104        [KOBJECT_TYPE_PHONE] = &phone_kobject_ops,
     105        [KOBJECT_TYPE_WAITQ] = &waitq_kobject_ops
     106};
    96107
    97108static size_t caps_hash(const ht_link_t *item)
     
    412423 * @param type  Type of the kernel object.
    413424 * @param raw   Raw pointer to the encapsulated object.
    414  * @param ops   Pointer to kernel object operations for the respective type.
    415  */
    416 void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw,
    417     kobject_ops_t *ops)
     425 */
     426void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw)
    418427{
    419428        atomic_store(&kobj->refcnt, 1);
     
    424433        kobj->type = type;
    425434        kobj->raw = raw;
    426         kobj->ops = ops;
    427435}
    428436
     
    474482{
    475483        if (atomic_postdec(&kobj->refcnt) == 1) {
    476                 kobj->ops->destroy(kobj->raw);
     484                KOBJECT_OP(kobj)->destroy(kobj->raw);
    477485                kobject_free(kobj);
    478486        }
  • kernel/generic/src/ipc/ipc.c

    rf1cd4b0 rfc0de8c  
    100100}
    101101
    102 static kobject_ops_t call_kobject_ops = {
     102kobject_ops_t call_kobject_ops = {
    103103        .destroy = call_destroy
    104104};
     
    127127
    128128        _ipc_call_init(call);
    129         kobject_initialize(kobj, KOBJECT_TYPE_CALL, call, &call_kobject_ops);
     129        kobject_initialize(kobj, KOBJECT_TYPE_CALL, call);
    130130        call->kobject = kobj;
    131131
  • kernel/generic/src/ipc/ipcrsc.c

    rf1cd4b0 rfc0de8c  
    5252}
    5353
    54 static kobject_ops_t phone_kobject_ops = {
     54kobject_ops_t phone_kobject_ops = {
    5555        .destroy = phone_destroy
    5656};
     
    9494                phone->hangup_call = hcall;
    9595
    96                 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone,
    97                     &phone_kobject_ops);
     96                kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone);
    9897                phone->kobject = kobj;
    9998
  • kernel/generic/src/ipc/irq.c

    rf1cd4b0 rfc0de8c  
    306306}
    307307
    308 static kobject_ops_t irq_kobject_ops = {
     308kobject_ops_t irq_kobject_ops = {
    309309        .destroy = irq_destroy
    310310};
     
    385385        irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
    386386
    387         kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq, &irq_kobject_ops);
     387        kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq);
    388388        cap_publish(TASK, handle, kobject);
    389389
  • kernel/generic/src/synch/syswaitq.c

    rf1cd4b0 rfc0de8c  
    5454}
    5555
    56 static kobject_ops_t waitq_kobject_ops = {
     56kobject_ops_t waitq_kobject_ops = {
    5757        .destroy = waitq_destroy
    5858};
     
    100100                return (sys_errno_t) ENOMEM;
    101101        }
    102         kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq, &waitq_kobject_ops);
     102        kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq);
    103103
    104104        cap_handle_t handle;
Note: See TracChangeset for help on using the changeset viewer.