Changeset 15d0046 in mainline for kernel/generic/src/ddi/ddi.c


Ignore:
Timestamp:
2014-09-12T13:22:33Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b20126
Parents:
8db09e4 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    r8db09e4 r15d0046  
    211211NO_TRACE static int physmem_unmap(uintptr_t virt)
    212212{
    213         // TODO: implement unmap
    214         return EOK;
     213        ASSERT(TASK);
     214
     215        return as_area_destroy(TASK->as, virt);
    215216}
    216217
     
    229230    void *virt_ptr, uintptr_t bound)
    230231{
    231         uintptr_t virt = (uintptr_t) -1;
    232         int rc = physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), pages, flags,
    233             &virt, bound);
     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);
    234239        if (rc != EOK)
    235240                return rc;
     
    251256/** Enable range of I/O space for task.
    252257 *
    253  * @param id Task ID of the destination task.
     258 * @param id     Task ID of the destination task.
    254259 * @param ioaddr Starting I/O address.
    255  * @param size Size of the enabled I/O space..
     260 * @param size   Size of the enabled I/O space.
    256261 *
    257262 * @return 0 on success, EPERM if the caller lacks capabilities to use this
     
    286291        int rc = ddi_iospace_enable_arch(task, ioaddr, size);
    287292        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 this
     304 *           syscall, ENOENT if there is no task matching the specified ID.
     305 *
     306 */
     307NO_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 ID
     323                 * or the task belongs to a different security
     324                 * 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);
    288334       
    289335        return rc;
     
    310356sysarg_t sys_iospace_disable(ddi_ioarg_t *uspace_io_arg)
    311357{
    312         // TODO: implement
    313         return ENOTSUP;
     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);
    314365}
    315366
     
    390441                        return rc;
    391442               
     443                uintptr_t virt;
     444                rc = copy_from_uspace(&virt, virt_ptr, sizeof(virt));
     445                if (rc != EOK)
     446                        return rc;
     447               
    392448                uintptr_t phys;
    393                 uintptr_t virt = (uintptr_t) -1;
    394449                rc = dmamem_map_anonymous(size, constraint, map_flags, flags,
    395450                    &phys, &virt, bound);
Note: See TracChangeset for help on using the changeset viewer.