Changes in kernel/generic/src/ddi/ddi.c [8cd680c:f72906c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r8cd680c rf72906c 121 121 backend_data.base = phys; 122 122 backend_data.frames = pages; 123 backend_data.anonymous = false;124 123 125 124 /* … … 211 210 NO_TRACE static int physmem_unmap(uintptr_t virt) 212 211 { 213 ASSERT(TASK); 214 215 return as_area_destroy(TASK->as, virt); 212 // TODO: implement unmap 213 return EOK; 216 214 } 217 215 … … 230 228 void *virt_ptr, uintptr_t bound) 231 229 { 232 uintptr_t virt; 233 int rc = copy_from_uspace(&virt, virt_ptr, sizeof(virt)); 234 if (rc != EOK) 235 return rc; 236 237 rc = physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), pages, flags, &virt, 238 bound); 230 uintptr_t virt = (uintptr_t) -1; 231 int rc = physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), pages, flags, 232 &virt, bound); 239 233 if (rc != EOK) 240 234 return rc; … … 256 250 /** Enable range of I/O space for task. 257 251 * 258 * @param id 252 * @param id Task ID of the destination task. 259 253 * @param ioaddr Starting I/O address. 260 * @param size Size of the enabled I/O space.254 * @param size Size of the enabled I/O space.. 261 255 * 262 256 * @return 0 on success, EPERM if the caller lacks capabilities to use this … … 291 285 int rc = ddi_iospace_enable_arch(task, ioaddr, size); 292 286 irq_spinlock_unlock(&task->lock, true); 293 294 return rc;295 }296 297 /** Disable range of I/O space for task.298 *299 * @param id Task ID of the destination task.300 * @param ioaddr Starting I/O address.301 * @param size Size of the enabled I/O space.302 *303 * @return 0 on success, EPERM if the caller lacks capabilities to use this304 * syscall, ENOENT if there is no task matching the specified ID.305 *306 */307 NO_TRACE static int iospace_disable(task_id_t id, uintptr_t ioaddr, size_t size)308 {309 /*310 * Make sure the caller is authorised to make this syscall.311 */312 cap_t caps = cap_get(TASK);313 if (!(caps & CAP_IO_MANAGER))314 return EPERM;315 316 irq_spinlock_lock(&tasks_lock, true);317 318 task_t *task = task_find_by_id(id);319 320 if ((!task) || (!container_check(CONTAINER, task->container))) {321 /*322 * There is no task with the specified ID323 * or the task belongs to a different security324 * context.325 */326 irq_spinlock_unlock(&tasks_lock, true);327 return ENOENT;328 }329 330 /* Lock the task and release the lock protecting tasks_btree. */331 irq_spinlock_exchange(&tasks_lock, &task->lock);332 int rc = ddi_iospace_disable_arch(task, ioaddr, size);333 irq_spinlock_unlock(&task->lock, true);334 287 335 288 return rc; … … 356 309 sysarg_t sys_iospace_disable(ddi_ioarg_t *uspace_io_arg) 357 310 { 358 ddi_ioarg_t arg; 359 int rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 360 if (rc != 0) 361 return (sysarg_t) rc; 362 363 return (sysarg_t) iospace_disable((task_id_t) arg.task_id, 364 (uintptr_t) arg.ioaddr, (size_t) arg.size); 311 // TODO: implement 312 return ENOTSUP; 365 313 } 366 314 … … 381 329 382 330 size_t frames = SIZE2FRAMES(size); 383 *phys = frame_alloc(frames, FRAME_ ATOMIC, constraint);331 *phys = frame_alloc(frames, FRAME_NO_RESERVE, constraint); 384 332 if (*phys == 0) 385 333 return ENOMEM; … … 388 336 backend_data.base = *phys; 389 337 backend_data.frames = frames; 390 backend_data.anonymous = true;391 338 392 339 if (!as_area_create(TASK->as, map_flags, size, 393 340 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { 394 frame_free (*phys, frames);341 frame_free_noreserve(*phys, frames); 395 342 return ENOMEM; 396 343 } … … 407 354 NO_TRACE static int dmamem_unmap_anonymous(uintptr_t virt) 408 355 { 409 return as_area_destroy(TASK->as, virt); 356 // TODO: implement unlocking & unmap 357 return EOK; 410 358 } 411 359 … … 441 389 return rc; 442 390 443 uintptr_t virt;444 rc = copy_from_uspace(&virt, virt_ptr, sizeof(virt));445 if (rc != EOK)446 return rc;447 448 391 uintptr_t phys; 392 uintptr_t virt = (uintptr_t) -1; 449 393 rc = dmamem_map_anonymous(size, constraint, map_flags, flags, 450 394 &phys, &virt, bound);
Note:
See TracChangeset
for help on using the changeset viewer.