Changeset 455241b in mainline
- Timestamp:
- 2025-01-16T19:29:20Z (23 hours ago)
- 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)
- Location:
- kernel/generic
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
rdf721df r455241b 60 60 } kobject_type_t; 61 61 62 struct task; 63 64 struct call; 65 struct irq; 66 struct phone; 67 struct waitq; 62 struct kobject; 68 63 69 64 typedef struct kobject_ops { 70 void (*destroy)( void*);65 void (*destroy)(struct kobject *); 71 66 } kobject_ops_t; 72 67 … … 77 72 /* 78 73 * Everything in kobject_t except for the atomic reference count, the capability 79 * list and its lock is im utable.74 * list and its lock is immutable. 80 75 */ 81 76 typedef struct kobject { … … 87 82 /** List of published capabilities associated with the kobject */ 88 83 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 };97 84 } kobject_t; 98 85 … … 141 128 extern void cap_free(struct task *, cap_handle_t); 142 129 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 *); 130 extern void kobject_initialize(kobject_t *, kobject_type_t); 146 131 extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t); 147 132 extern void kobject_add_ref(kobject_t *); -
kernel/generic/include/ddi/irq.h
rdf721df r455241b 132 132 extern hash_table_t irq_uspace_hash_table; 133 133 134 extern slab_cache_t *irq_cache;135 136 134 extern inr_t last_inr; 137 135 -
kernel/generic/include/ipc/ipc.h
rdf721df r455241b 74 74 /** User-defined label */ 75 75 sysarg_t label; 76 kobject_t *kobject;76 kobject_t kobject; 77 77 } phone_t; 78 78 … … 108 108 109 109 typedef struct call { 110 kobject_t *kobject;110 kobject_t kobject; 111 111 112 112 /** … … 169 169 170 170 extern slab_cache_t *phone_cache; 171 extern slab_cache_t *irq_cache; 171 172 172 173 extern answerbox_t *ipc_box_0; 173 174 174 175 extern kobject_ops_t call_kobject_ops; 176 177 static 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 185 static 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 } 175 192 176 193 extern void ipc_init(void); -
kernel/generic/include/ipc/irq.h
rdf721df r455241b 50 50 extern kobject_ops_t irq_kobject_ops; 51 51 52 typedef struct { 53 kobject_t kobject; 54 irq_t irq; 55 } irq_kobject_t; 56 57 static 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 52 66 extern irq_ownership_t ipc_irq_top_half_claim(irq_t *); 53 67 extern void ipc_irq_top_half_handler(irq_t *); -
kernel/generic/src/cap/cap.c
rdf721df r455241b 97 97 98 98 static slab_cache_t *cap_cache; 99 static slab_cache_t *kobject_cache;100 99 101 100 kobject_ops_t *kobject_ops[KOBJECT_TYPE_MAX] = { … … 156 155 cap_cache = slab_cache_create("cap_t", sizeof(cap_t), 0, NULL, 157 156 NULL, 0); 158 kobject_cache = slab_cache_create("kobject_t", sizeof(kobject_t), 0,159 NULL, NULL, 0);160 157 } 161 158 … … 463 460 } 464 461 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 475 462 /** Initialize kernel object 476 463 * 477 464 * @param kobj Kernel object to initialize. 478 465 * @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 */ 467 void kobject_initialize(kobject_t *kobj, kobject_type_t type) 482 468 { 483 469 refcount_init(&kobj->refcnt); … … 487 473 488 474 kobj->type = type; 489 kobj->raw = raw;490 475 } 491 476 … … 537 522 { 538 523 if (refcount_down(&kobj->refcnt)) { 539 KOBJECT_OP(kobj)->destroy(kobj->raw); 540 kobject_free(kobj); 524 KOBJECT_OP(kobj)->destroy(kobj); 541 525 } 542 526 } -
kernel/generic/src/ddi/irq.c
rdf721df r455241b 50 50 #include <arch.h> 51 51 52 slab_cache_t *irq_cache = NULL;53 54 52 /** Spinlock protecting the kernel IRQ hash table 55 53 * … … 96 94 { 97 95 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);102 96 103 97 hash_table_create(&irq_uspace_hash_table, chains, 0, &irq_ht_ops); -
kernel/generic/src/ipc/ipc.c
rdf721df r455241b 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); -
kernel/generic/src/ipc/ipcrsc.c
rdf721df r455241b 44 44 #include <stdlib.h> 45 45 46 static void phone_destroy( void*arg)46 static void phone_destroy(kobject_t *arg) 47 47 { 48 phone_t *phone = (phone_t *) arg;48 phone_t *phone = phone_from_kobject(arg); 49 49 if (phone->hangup_call) 50 kobject_put( phone->hangup_call->kobject);50 kobject_put(&phone->hangup_call->kobject); 51 51 slab_free(phone_cache, phone); 52 52 } … … 76 76 return ENOMEM; 77 77 } 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 84 79 call_t *hcall = ipc_call_alloc(); 85 80 if (!hcall) { 86 81 cap_free(TASK, handle); 87 82 slab_free(phone_cache, phone); 88 free(kobj);89 83 return ENOMEM; 90 84 } … … 94 88 phone->hangup_call = hcall; 95 89 96 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone);97 phone->kobject = kobj;98 99 90 if (publish) 100 cap_publish(task, handle, kobj);91 cap_publish(task, handle, &phone->kobject); 101 92 102 93 *phandle = handle; 103 94 if (kobject) 104 *kobject = kobj;95 *kobject = &phone->kobject; 105 96 } 106 97 return rc; -
kernel/generic/src/ipc/irq.c
rdf721df r455241b 295 295 } 296 296 297 static void irq_destroy( void*arg)298 { 299 irq_ t *irq = (irq_t *) arg;300 301 irq_hash_out( irq);297 static void irq_destroy(kobject_t *arg) 298 { 299 irq_kobject_t *kobj = (irq_kobject_t *) arg; 300 301 irq_hash_out(&kobj->irq); 302 302 303 303 /* 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); 306 306 } 307 307 … … 350 350 } 351 351 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) { 354 354 cap_free(TASK, handle); 355 355 return ENOMEM; 356 356 } 357 357 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; 364 361 365 362 irq_initialize(irq); … … 385 382 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 386 383 387 kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq); 388 cap_publish(TASK, handle, kobject); 384 cap_publish(TASK, handle, &kobj->kobject); 389 385 390 386 return EOK; … … 405 401 return ENOENT; 406 402 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)); 410 406 411 407 kobject_put(kobj); -
kernel/generic/src/ipc/kbox.c
rdf721df r455241b 242 242 } 243 243 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)); 246 246 /* Connect the newly allocated phone to the kbox */ 247 247 /* 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); 249 249 250 250 mutex_unlock(&task->kb.cleanup_lock); -
kernel/generic/src/ipc/ops/conctmeto.c
rdf721df r455241b 88 88 89 89 /* Set the recipient-assigned label */ 90 p obj->phone->label = ipc_get_arg5(&answer->data);90 phone_from_kobject(pobj)->label = ipc_get_arg5(&answer->data); 91 91 92 92 /* Restore phone handle in answer's ARG5 */ … … 96 96 if (ipc_get_retval(&answer->data) == EOK) { 97 97 /* Hand over reference from pobj to the answerbox */ 98 (void) ipc_phone_connect(p obj->phone, &TASK->answerbox);98 (void) ipc_phone_connect(phone_from_kobject(pobj), &TASK->answerbox); 99 99 } else { 100 100 /* Drop the extra reference */ -
kernel/generic/src/ipc/ops/concttome.c
rdf721df r455241b 49 49 * Set the sender-assigned label to the new phone. 50 50 */ 51 p obj->phone->label = ipc_get_arg5(&call->data);51 phone_from_kobject(pobj)->label = ipc_get_arg5(&call->data); 52 52 } 53 53 call->priv = (sysarg_t) pobj; … … 88 88 kobject_add_ref(pobj); 89 89 90 if (ipc_phone_connect(p obj->phone,90 if (ipc_phone_connect(phone_from_kobject(pobj), 91 91 &answer->sender->answerbox)) { 92 92 /* Pass the reference to the capability */ -
kernel/generic/src/ipc/ops/stchngath.c
rdf721df r455241b 45 45 task_t *other_task_s; 46 46 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) 50 50 return ENOENT; 51 51 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); 56 56 return EINVAL; 57 57 } 58 58 59 other_task_s = sender_ obj->phone->callee->task;59 other_task_s = sender_phone->callee->task; 60 60 61 mutex_unlock(&sender_ obj->phone->lock);61 mutex_unlock(&sender_phone->lock); 62 62 63 63 /* Remember the third party task hash. */ 64 64 ipc_set_arg5(&call->data, (sysarg_t) other_task_s); 65 65 66 kobject_put( sender_obj);66 kobject_put(&sender_phone->kobject); 67 67 return EOK; 68 68 } … … 77 77 task_t *other_task_r; 78 78 79 kobject_t *recipient_obj =kobject_get(TASK,79 phone_t *recipient_phone = phone_from_kobject(kobject_get(TASK, 80 80 (cap_handle_t) ipc_get_arg1(&answer->data), 81 KOBJECT_TYPE_PHONE) ;82 if (!recipient_ obj) {81 KOBJECT_TYPE_PHONE)); 82 if (!recipient_phone) { 83 83 ipc_set_retval(&answer->data, ENOENT); 84 84 return ENOENT; 85 85 } 86 86 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); 90 90 ipc_set_retval(&answer->data, EINVAL); 91 kobject_put( recipient_obj);91 kobject_put(&recipient_phone->kobject); 92 92 return EINVAL; 93 93 } 94 94 95 other_task_r = recipient_ obj->phone->callee->task;95 other_task_r = recipient_phone->callee->task; 96 96 other_task_s = (task_t *) ipc_get_arg5(olddata); 97 97 … … 114 114 } 115 115 116 mutex_unlock(&recipient_ obj->phone->lock);117 kobject_put( recipient_obj);116 mutex_unlock(&recipient_phone->lock); 117 kobject_put(&recipient_phone->kobject); 118 118 } 119 119 -
kernel/generic/src/ipc/sysipc.c
rdf721df r455241b 199 199 list_remove(&phone->link); 200 200 /* Drop callee->connected_phones reference */ 201 kobject_put( phone->kobject);201 kobject_put(&phone->kobject); 202 202 phone->state = IPC_PHONE_SLAMMED; 203 203 phone->label = 0; … … 273 273 ipc_req_internal(cap_phone_handle_t handle, ipc_data_t *data, sysarg_t priv) 274 274 { 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) 277 278 return ENOENT; 278 279 279 280 call_t *call = ipc_call_alloc(); 280 281 if (!call) { 281 kobject_put( kobj);282 kobject_put(&phone->kobject); 282 283 return ENOMEM; 283 284 } … … 286 287 memcpy(call->data.args, data->args, sizeof(data->args)); 287 288 288 errno_t rc = request_preprocess(call, kobj->phone);289 errno_t rc = request_preprocess(call, phone); 289 290 if (!rc) { 290 291 #ifdef CONFIG_UDEBUG … … 292 293 #endif 293 294 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); 296 297 spinlock_lock(&call->forget_lock); 297 298 bool forgotten = call->forget; 298 299 spinlock_unlock(&call->forget_lock); 299 kobject_put( call->kobject);300 kobject_put(&call->kobject); 300 301 301 302 #ifdef CONFIG_UDEBUG … … 312 313 * deallocation. 313 314 */ 314 kobject_put( call->kobject);315 kobject_put(&call->kobject); 315 316 } else { 316 317 /* … … 320 321 assert(rc == EINTR); 321 322 } 322 kobject_put( kobj);323 kobject_put(&phone->kobject); 323 324 return rc; 324 325 } … … 329 330 330 331 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); 333 334 334 335 return EOK; … … 370 371 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t label) 371 372 { 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) 374 377 return ENOENT; 375 378 376 if (check_call_limit( kobj->phone)) {377 kobject_put( kobj);379 if (check_call_limit(phone)) { 380 kobject_put(&phone->kobject); 378 381 return ELIMIT; 379 382 } … … 381 384 call_t *call = ipc_call_alloc(); 382 385 if (!call) { 383 kobject_put( kobj);386 kobject_put(&phone->kobject); 384 387 return ENOMEM; 385 388 } … … 399 402 call->data.answer_label = label; 400 403 401 errno_t res = request_preprocess(call, kobj->phone);404 errno_t res = request_preprocess(call, phone); 402 405 403 406 if (!res) 404 ipc_call( kobj->phone, call);407 ipc_call(phone, call); 405 408 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); 409 412 return EOK; 410 413 } … … 422 425 sysarg_t label) 423 426 { 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) 426 430 return ENOENT; 427 431 428 if (check_call_limit( kobj->phone)) {429 kobject_put( kobj);432 if (check_call_limit(phone)) { 433 kobject_put(&phone->kobject); 430 434 return ELIMIT; 431 435 } … … 433 437 call_t *call = ipc_call_alloc(); 434 438 if (!call) { 435 kobject_put( kobj);439 kobject_put(&phone->kobject); 436 440 return ENOMEM; 437 441 } … … 440 444 sizeof(call->data.args)); 441 445 if (rc != EOK) { 442 kobject_put( call->kobject);443 kobject_put( kobj);446 kobject_put(&call->kobject); 447 kobject_put(&phone->kobject); 444 448 return (sys_errno_t) rc; 445 449 } … … 448 452 call->data.answer_label = label; 449 453 450 errno_t res = request_preprocess(call, kobj->phone);454 errno_t res = request_preprocess(call, phone); 451 455 452 456 if (!res) 453 ipc_call( kobj->phone, call);457 ipc_call(phone, call); 454 458 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); 458 462 return EOK; 459 463 } … … 489 493 return ENOENT; 490 494 491 call_t *call = c kobj->call;495 call_t *call = call_from_kobject(ckobj); 492 496 493 497 ipc_data_t old; … … 551 555 } 552 556 553 rc = ipc_forward(call, p kobj->phone, &TASK->answerbox, mode);557 rc = ipc_forward(call, phone_from_kobject(pkobj), &TASK->answerbox, mode); 554 558 if (rc != EOK) { 555 559 after_forward = true; … … 659 663 return ENOENT; 660 664 661 call_t *call = kobj->call;665 call_t *call = call_from_kobject(kobj); 662 666 assert(!(call->flags & IPC_CALL_ANSWERED)); 663 667 … … 706 710 return ENOENT; 707 711 708 call_t *call = kobj->call;712 call_t *call = call_from_kobject(kobj); 709 713 assert(!(call->flags & IPC_CALL_ANSWERED)); 710 714 … … 751 755 return ENOENT; 752 756 753 errno_t rc = ipc_phone_hangup( kobj->phone);757 errno_t rc = ipc_phone_hangup(phone_from_kobject(kobj)); 754 758 kobject_put(kobj); 755 759 cap_free(TASK, handle); … … 797 801 798 802 STRUCT_TO_USPACE(calldata, &call->data); 799 kobject_put( call->kobject);803 kobject_put(&call->kobject); 800 804 801 805 return EOK; … … 806 810 807 811 if (call->flags & IPC_CALL_DISCARD_ANSWER) { 808 kobject_put( call->kobject);812 kobject_put(&call->kobject); 809 813 goto restart; 810 814 } … … 813 817 814 818 STRUCT_TO_USPACE(calldata, &call->data); 815 kobject_put( call->kobject);819 kobject_put(&call->kobject); 816 820 817 821 return EOK; … … 836 840 goto error; 837 841 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); 840 844 return EOK; 841 845 -
kernel/generic/src/proc/task.c
rdf721df r455241b 251 251 } 252 252 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); 256 256 } 257 257 -
kernel/generic/src/synch/syswaitq.c
rdf721df r455241b 48 48 static slab_cache_t *waitq_cache; 49 49 50 static void waitq_destroy(void *arg) 50 typedef struct { 51 kobject_t kobject; 52 waitq_t waitq; 53 } waitq_kobject_t; 54 55 static void waitq_destroy(kobject_t *arg) 51 56 { 52 waitq_ t *wq = (waitq_t *) arg;57 waitq_kobject_t *wq = (waitq_kobject_t *) arg; 53 58 slab_free(waitq_cache, wq); 54 59 } 55 60 56 61 kobject_ops_t waitq_kobject_ops = { 57 .destroy = waitq_destroy 62 .destroy = waitq_destroy, 58 63 }; 59 64 … … 61 66 void sys_waitq_init(void) 62 67 { 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); 65 70 } 66 71 … … 74 79 sys_errno_t sys_waitq_create(uspace_ptr_cap_waitq_handle_t whandle) 75 80 { 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) 78 83 return (sys_errno_t) ENOMEM; 79 waitq_initialize(wq);80 84 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); 87 87 88 88 cap_handle_t handle; 89 89 errno_t rc = cap_alloc(TASK, &handle); 90 90 if (rc != EOK) { 91 slab_free(waitq_cache, wq); 92 kobject_free(kobj); 91 slab_free(waitq_cache, kobj); 93 92 return (sys_errno_t) rc; 94 93 } … … 97 96 if (rc != EOK) { 98 97 cap_free(TASK, handle); 99 kobject_free(kobj); 100 slab_free(waitq_cache, wq); 98 slab_free(waitq_cache, kobj); 101 99 return (sys_errno_t) rc; 102 100 } 103 101 104 cap_publish(TASK, handle, kobj);102 cap_publish(TASK, handle, &kobj->kobject); 105 103 106 104 return (sys_errno_t) EOK; … … 135 133 unsigned int flags) 136 134 { 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); 138 137 if (!kobj) 139 138 return (sys_errno_t) ENOENT; … … 143 142 #endif 144 143 145 errno_t rc = _waitq_sleep_timeout( kobj->waitq, timeout,144 errno_t rc = _waitq_sleep_timeout(&kobj->waitq, timeout, 146 145 SYNCH_FLAGS_INTERRUPTIBLE | flags); 147 146 … … 150 149 #endif 151 150 152 kobject_put( kobj);151 kobject_put(&kobj->kobject); 153 152 154 153 return (sys_errno_t) rc; … … 163 162 sys_errno_t sys_waitq_wakeup(cap_waitq_handle_t whandle) 164 163 { 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); 166 166 if (!kobj) 167 167 return (sys_errno_t) ENOENT; 168 168 169 waitq_wake_one( kobj->waitq);169 waitq_wake_one(&kobj->waitq); 170 170 171 kobject_put( kobj);171 kobject_put(&kobj->kobject); 172 172 return (sys_errno_t) EOK; 173 173 } -
kernel/generic/src/sysinfo/stats.c
rdf721df r455241b 384 384 static bool produce_stats_ipcc_cb(cap_t *cap, void *arg) 385 385 { 386 phone_t *phone = cap->kobject->phone;386 phone_t *phone = (phone_t *) cap->kobject; 387 387 ipccs_state_t *state = (ipccs_state_t *) arg; 388 388
Note:
See TracChangeset
for help on using the changeset viewer.