Changeset eeb5cc2 in mainline for uspace/lib/c/generic/ddi.c


Ignore:
Timestamp:
2013-09-12T12:24:09Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46eb2c4
Parents:
9e470c0
Message:

Add pio_enable_resource() to slightly simplify enabling of PIO and also
to abstract away from relative/absolute ranges in HW resources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ddi.c

    r9e470c0 reeb5cc2  
    136136}
    137137
     138/** Enable PIO for specified HW resource.
     139 *
     140 * @param win      PIO window. May be NULL if the resources are known to be
     141 *                 absolute.
     142 * @param res      Resources specifying the I/O range wrt. to the PIO window.
     143 * @param virt     Virtual address for application's PIO operations.
     144 *
     145 * @return EOK on success.
     146 * @return Negative error code on failure.
     147 *
     148 */
     149int pio_enable_resource(pio_window_t *win, hw_resource_t *res, void **virt)
     150{
     151        uintptr_t addr;
     152        size_t size;
     153
     154        switch (res->type) {
     155        case IO_RANGE:
     156                addr = res->res.io_range.address;
     157                if (res->res.io_range.relative) {
     158                        if (!win)
     159                                return EINVAL;
     160                        addr += win->io.base;
     161                }
     162                size = res->res.io_range.size;
     163                break;
     164        case MEM_RANGE:
     165                addr = res->res.mem_range.address;
     166                if (res->res.mem_range.relative) {
     167                        if (!win)
     168                                return EINVAL;
     169                        addr += win->mem.base;
     170                }
     171                size = res->res.mem_range.size;
     172                break;
     173        default:
     174                return EINVAL;
     175        }
     176
     177        return pio_enable((void *) addr, size, virt);   
     178}
     179
    138180/** Enable PIO for specified I/O range.
    139181 *
Note: See TracChangeset for help on using the changeset viewer.