Changeset c1f68b0 in mainline
- Timestamp:
- 2017-10-28T11:40:41Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eca820c
- Parents:
- 15d9fe6
- Location:
- kernel/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
r15d9fe6 rc1f68b0 121 121 extern void cap_publish(struct task *, cap_handle_t, kobject_t *); 122 122 extern kobject_t *cap_unpublish(struct task *, cap_handle_t, kobject_type_t); 123 extern kobject_t *cap_unpublish_locked(struct task *, cap_handle_t,124 kobject_type_t);125 123 extern void cap_free(struct task *, cap_handle_t); 126 extern void cap_free_locked(struct task *, cap_handle_t);127 124 128 125 extern void kobject_initialize(kobject_t *, kobject_type_t, void *, -
kernel/generic/src/cap/cap.c
r15d9fe6 rc1f68b0 148 148 void caps_task_init(task_t *task) 149 149 { 150 mutex_initialize(&task->cap_info->lock, MUTEX_ PASSIVE);150 mutex_initialize(&task->cap_info->lock, MUTEX_RECURSIVE); 151 151 152 152 for (kobject_type_t t = 0; t < KOBJECT_TYPE_MAX; t++) … … 238 238 if (cap->state == CAP_STATE_PUBLISHED && cap->kobject->ops->reclaim && 239 239 cap->kobject->ops->reclaim(cap->kobject)) { 240 kobject_t *kobj = cap_unpublish _locked(cap->task, cap->handle,240 kobject_t *kobj = cap_unpublish(cap->task, cap->handle, 241 241 cap->kobject->type); 242 242 kobject_put(kobj); … … 318 318 } 319 319 320 /** @copydoc cap_unpublish() 321 * 322 * Can only be called internally by the capability subsytem or from a 323 * caps_apply_to_kobject_type() callback. 324 */ 325 kobject_t * 326 cap_unpublish_locked(task_t *task, cap_handle_t handle, kobject_type_t type) 320 /** Unpublish published capability 321 * 322 * The kernel object is moved out of the capability. In other words, the 323 * capability's reference to the objects is handed over to the kernel object 324 * pointer returned by this function. Once unpublished, the capability does not 325 * refer to any kernel object anymore. 326 * 327 * @param task Task in which to unpublish the capability. 328 * @param handle Capability handle. 329 * @param type Kernel object type of the object associated with the 330 * capability. 331 */ 332 kobject_t *cap_unpublish(task_t *task, cap_handle_t handle, kobject_type_t type) 327 333 { 328 334 kobject_t *kobj = NULL; 329 335 336 mutex_lock(&task->cap_info->lock); 330 337 cap_t *cap = cap_get(task, handle, CAP_STATE_PUBLISHED); 331 338 if (cap) { … … 338 345 } 339 346 } 347 mutex_unlock(&task->cap_info->lock); 340 348 341 349 return kobj; 342 350 } 343 351 344 /** Unpublish published capability 345 * 346 * The kernel object is moved out of the capability. In other words, the 347 * capability's reference to the objects is handed over to the kernel object 348 * pointer returned by this function. Once unpublished, the capability does not 349 * refer to any kernel object anymore. 350 * 351 * @param task Task in which to unpublish the capability. 352 /** Free allocated capability 353 * 354 * @param task Task in which to free the capability. 352 355 * @param handle Capability handle. 353 * @param type Kernel object type of the object associated with the 354 * capability. 355 */ 356 kobject_t *cap_unpublish(task_t *task, cap_handle_t handle, kobject_type_t type) 357 { 358 359 mutex_lock(&task->cap_info->lock); 360 kobject_t *kobj = cap_unpublish_locked(task, handle, type); 361 mutex_unlock(&task->cap_info->lock); 362 363 return kobj; 364 } 365 366 /** @copydoc cap_free() 367 * 368 * Can only be called internally by the capability subsytem or from a 369 * caps_apply_to_kobject_type() callback. 370 */ 371 void cap_free_locked(task_t *task, cap_handle_t handle) 356 */ 357 void cap_free(task_t *task, cap_handle_t handle) 372 358 { 373 359 assert(handle >= 0); 374 360 assert(handle < MAX_CAPS); 375 361 362 mutex_lock(&task->cap_info->lock); 376 363 cap_t *cap = cap_get(task, handle, CAP_STATE_ALLOCATED); 377 364 … … 381 368 ra_free(task->cap_info->handles, handle, 1); 382 369 slab_free(cap_slab, cap); 383 }384 385 /** Free allocated capability386 *387 * @param task Task in which to free the capability.388 * @param handle Capability handle.389 */390 void cap_free(task_t *task, cap_handle_t handle)391 {392 mutex_lock(&task->cap_info->lock);393 cap_free_locked(task, handle);394 370 mutex_unlock(&task->cap_info->lock); 395 371 } -
kernel/generic/src/ipc/ipc.c
r15d9fe6 rc1f68b0 829 829 { 830 830 ipc_phone_hangup(cap->kobject->phone); 831 kobject_t *kobj = cap_unpublish _locked(cap->task, cap->handle,831 kobject_t *kobj = cap_unpublish(cap->task, cap->handle, 832 832 KOBJECT_TYPE_PHONE); 833 833 kobject_put(kobj); 834 cap_free _locked(cap->task, cap->handle);834 cap_free(cap->task, cap->handle); 835 835 return true; 836 836 } … … 839 839 { 840 840 ipc_irq_unsubscribe(&TASK->answerbox, cap->handle); 841 kobject_t *kobj = cap_unpublish_locked(cap->task, cap->handle,842 KOBJECT_TYPE_IRQ);843 kobject_put(kobj);844 cap_free_locked(cap->task, cap->handle);845 841 return true; 846 842 } -
kernel/generic/src/ipc/irq.c
r15d9fe6 rc1f68b0 271 271 } 272 272 273 static void irq_hash_out(irq_t *irq) 274 { 275 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); 276 irq_spinlock_lock(&irq->lock, false); 277 278 if (irq->notif_cfg.hashed_in) { 279 /* Remove the IRQ from the uspace IRQ hash table. */ 280 hash_table_remove_item(&irq_uspace_hash_table, &irq->link); 281 irq->notif_cfg.hashed_in = false; 282 } 283 284 irq_spinlock_unlock(&irq->lock, false); 285 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 286 } 287 273 288 static void irq_destroy(void *arg) 274 289 { 275 290 irq_t *irq = (irq_t *) arg; 291 292 irq_hash_out(irq); 276 293 277 294 /* Free up the IRQ code and associated structures. */ … … 373 390 assert(kobj->irq->notif_cfg.answerbox == box); 374 391 375 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); 376 irq_spinlock_lock(&kobj->irq->lock, false); 377 378 if (kobj->irq->notif_cfg.hashed_in) { 379 /* Remove the IRQ from the uspace IRQ hash table. */ 380 hash_table_remove_item(&irq_uspace_hash_table, 381 &kobj->irq->link); 382 kobj->irq->notif_cfg.hashed_in = false; 383 } 384 385 irq_spinlock_unlock(&kobj->irq->lock, false); 386 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 392 irq_hash_out(kobj->irq); 387 393 388 394 kobject_put(kobj);
Note:
See TracChangeset
for help on using the changeset viewer.