Changes in kernel/generic/src/ddi/ddi.c [5a5269d:597fa24] in mainline
- File:
-
- 1 edited
-
kernel/generic/src/ddi/ddi.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r5a5269d r597fa24 54 54 #include <align.h> 55 55 #include <errno.h> 56 #include <mem .h>56 #include <memw.h> 57 57 #include <trace.h> 58 58 #include <bitops.h> … … 60 60 61 61 /** This lock protects the @c pareas ordered dictionary. */ 62 static mutex_t pareas_lock;62 static MUTEX_INITIALIZE(pareas_lock, MUTEX_PASSIVE); 63 63 64 64 /** Ordered dictionary of enabled physical memory areas by base address. */ … … 74 74 { 75 75 odict_initialize(&pareas, pareas_getkey, pareas_cmp); 76 mutex_initialize(&pareas_lock, MUTEX_PASSIVE);77 76 } 78 77 … … 105 104 106 105 mutex_unlock(&pareas_lock); 106 } 107 108 /** Norify physical area has been unmapped. 109 * 110 * @param parea Physical area 111 */ 112 void ddi_parea_unmap_notify(parea_t *parea) 113 { 114 parea->mapped = false; 115 if (parea->mapped_changed != NULL) 116 parea->mapped_changed(parea->arg); 107 117 } 108 118 … … 204 214 205 215 map: 216 backend_data.parea = parea; 217 206 218 if (!as_area_create(TASK->as, flags, FRAMES2SIZE(pages), 207 219 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { … … 323 335 return EPERM; 324 336 325 irq_spinlock_lock(&tasks_lock, true);326 327 337 task_t *task = task_find_by_id(id); 328 338 329 if ((!task) || (!container_check(CONTAINER, task->container))) { 330 /* 331 * There is no task with the specified ID 332 * or the task belongs to a different security 333 * context. 334 */ 335 irq_spinlock_unlock(&tasks_lock, true); 339 if (!task) 336 340 return ENOENT; 337 } 338 339 /* Lock the task and release the lock protecting tasks dictionary. */ 340 irq_spinlock_exchange(&tasks_lock, &task->lock); 341 errno_t rc = ddi_iospace_enable_arch(task, ioaddr, size); 341 342 errno_t rc = ENOENT; 343 344 irq_spinlock_lock(&task->lock, true); 345 346 /* Check that the task belongs to the correct security context. */ 347 if (container_check(CONTAINER, task->container)) 348 rc = ddi_iospace_enable_arch(task, ioaddr, size); 349 342 350 irq_spinlock_unlock(&task->lock, true); 343 351 task_release(task); 344 352 return rc; 345 353 } … … 364 372 return EPERM; 365 373 366 irq_spinlock_lock(&tasks_lock, true);367 368 374 task_t *task = task_find_by_id(id); 369 375 370 if ((!task) || (!container_check(CONTAINER, task->container))) { 371 /* 372 * There is no task with the specified ID 373 * or the task belongs to a different security 374 * context. 375 */ 376 irq_spinlock_unlock(&tasks_lock, true); 376 if (!task) 377 377 return ENOENT; 378 } 379 380 /* Lock the task and release the lock protecting tasks dictionary. */ 381 irq_spinlock_exchange(&tasks_lock, &task->lock); 382 errno_t rc = ddi_iospace_disable_arch(task, ioaddr, size); 378 379 errno_t rc = ENOENT; 380 381 irq_spinlock_lock(&task->lock, true); 382 383 /* Check that the task belongs to the correct security context. */ 384 if (container_check(CONTAINER, task->container)) 385 rc = ddi_iospace_disable_arch(task, ioaddr, size); 386 383 387 irq_spinlock_unlock(&task->lock, true); 384 388 task_release(task); 385 389 return rc; 386 390 } … … 443 447 backend_data.frames = frames; 444 448 backend_data.anonymous = true; 449 backend_data.parea = NULL; 445 450 446 451 if (!as_area_create(TASK->as, map_flags, size,
Note:
See TracChangeset
for help on using the changeset viewer.
