Changeset 48bcf49 in mainline for kernel/generic/src/ipc/irq.c
- Timestamp:
- 2017-09-28T22:08:15Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6636fb19
- Parents:
- dd20cbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/irq.c
rdd20cbb r48bcf49 271 271 } 272 272 273 static void irq_destroy(void *arg) 274 { 275 irq_t *irq = (irq_t *) arg; 276 277 /* Free up the IRQ code and associated structures. */ 278 code_free(irq->notif_cfg.code); 279 slab_free(irq_slab, irq); 280 } 281 282 static kobject_ops_t irq_kobject_ops = { 283 .destroy = irq_destroy 284 }; 285 273 286 /** Subscribe an answerbox as a receiving end for IRQ notifications. 274 287 * … … 304 317 * Allocate and populate the IRQ kernel object. 305 318 */ 306 int handle = cap_alloc(TASK);319 cap_handle_t handle = cap_alloc(TASK); 307 320 if (handle < 0) 308 321 return handle; … … 311 324 if (!irq) { 312 325 cap_free(TASK, handle); 326 return ENOMEM; 327 } 328 329 kobject_t *kobject = malloc(sizeof(kobject_t), FRAME_ATOMIC); 330 if (!kobject) { 331 cap_free(TASK, handle); 332 slab_free(irq_slab, irq); 313 333 return ENOMEM; 314 334 } … … 330 350 irq_spinlock_lock(&irq->lock, false); 331 351 352 irq->notif_cfg.hashed_in = true; 332 353 hash_table_insert(&irq_uspace_hash_table, key, &irq->link); 333 354 … … 335 356 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 336 357 337 cap_publish(TASK, handle, CAP_TYPE_IRQ, irq); 358 kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq, &irq_kobject_ops); 359 cap_publish(TASK, handle, kobject); 338 360 339 361 return handle; … … 350 372 int ipc_irq_unsubscribe(answerbox_t *box, int handle) 351 373 { 352 cap_t *cap = cap_unpublish(TASK, handle, CAP_TYPE_IRQ);353 if (! cap)374 kobject_t *kobj = cap_unpublish(TASK, handle, KOBJECT_TYPE_IRQ); 375 if (!kobj) 354 376 return ENOENT; 355 377 356 irq_t *irq = (irq_t *) cap->kobject;357 378 assert(kobj->irq->notif_cfg.answerbox == box); 379 358 380 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); 359 irq_spinlock_lock(&irq->lock, false); 360 361 assert(irq->notif_cfg.answerbox == box); 362 363 /* Remove the IRQ from the uspace IRQ hash table. */ 364 hash_table_remove_item(&irq_uspace_hash_table, &irq->link); 365 366 /* irq->lock unlocked by the hash table remove_callback */ 381 irq_spinlock_lock(&kobj->irq->lock, false); 382 383 if (kobj->irq->notif_cfg.hashed_in) { 384 /* Remove the IRQ from the uspace IRQ hash table. */ 385 hash_table_remove_item(&irq_uspace_hash_table, 386 &kobj->irq->link); 387 kobj->irq->notif_cfg.hashed_in = false; 388 } 389 390 /* kobj->irq->lock unlocked by the hash table remove_callback */ 367 391 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 368 369 /* Free up the IRQ code and associated structures. */ 370 code_free(irq->notif_cfg.code); 371 372 /* Free up the IRQ capability and the underlying kernel object. */ 373 slab_free(irq_slab, cap->kobject); 392 393 kobject_put(kobj); 374 394 cap_free(TASK, handle); 375 395
Note:
See TracChangeset
for help on using the changeset viewer.