Ignore:
File:
1 edited

Legend:

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

    rc6ae4c2 rc0699467  
    3333 */
    3434
    35 #include <assert.h>
    36 #include <unistd.h>
    37 #include <errno.h>
    3835#include <sys/types.h>
    3936#include <abi/ddi/arg.h>
     
    5653}
    5754
    58 /** Map a piece of physical memory to task.
     55/** Map piece of physical memory to task.
    5956 *
    6057 * Caller of this function must have the CAP_MEM_MANAGER capability.
    6158 *
    62  * @param phys  Physical address of the starting frame.
    63  * @param virt  Virtual address of the starting page.
    64  * @param pages Number of pages to map.
    65  * @param flags Flags for the new address space area.
     59 * @param pf            Physical address of the starting frame.
     60 * @param vp            Virtual address of the starting page.
     61 * @param pages         Number of pages to map.
     62 * @param flags         Flags for the new address space area.
    6663 *
    67  * @return EOK on success
    68  * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability
    69  * @return ENOENT if there is no task with specified ID
    70  * @return ENOMEM if there was some problem in creating
    71  *         the address space area.
    72  *
     64 * @return              0 on success, EPERM if the caller lacks the
     65 *                      CAP_MEM_MANAGER capability, ENOENT if there is no task
     66 *                      with specified ID and ENOMEM if there was some problem
     67 *                      in creating address space area.
    7368 */
    74 int physmem_map(void *phys, void *virt, size_t pages, unsigned int flags)
     69int physmem_map(void *pf, void *vp, unsigned long pages, int flags)
    7570{
    76         return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) phys,
    77             (sysarg_t) virt, pages, flags);
    78 }
    79 
    80 int dmamem_map(void *virt, size_t size, unsigned int map_flags,
    81     unsigned int flags, void **phys)
    82 {
    83         return (int) __SYSCALL5(SYS_DMAMEM_MAP, (sysarg_t) virt,
    84             (sysarg_t) size, (sysarg_t) map_flags, (sysarg_t) flags,
    85             (sysarg_t) phys);
    86 }
    87 
    88 int dmamem_map_anonymous(size_t size, unsigned int map_flags,
    89     unsigned int flags, void **phys, void **virt)
    90 {
    91         *virt = as_get_mappable_page(size);
    92         if (*virt == NULL)
    93                 return ENOMEM;
    94        
    95         return dmamem_map(*virt, size, map_flags,
    96             flags | DMAMEM_FLAGS_ANONYMOUS, phys);
    97 }
    98 
    99 int dmamem_unmap(void *virt, size_t size, unsigned int flags)
    100 {
    101         return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, (sysarg_t) size,
    102             (sysarg_t) flags);
    103 }
    104 
    105 int dmamem_unmap_anonymous(void *virt)
    106 {
    107         return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, 0,
    108             DMAMEM_FLAGS_ANONYMOUS);
     71        return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages,
     72            flags);
    10973}
    11074
     
    11377 * Caller of this function must have the IO_MEM_MANAGER capability.
    11478 *
    115  * @param id     Task ID.
    116  * @param ioaddr Starting address of the I/O range.
    117  * @param size   Size of the range.
     79 * @param id            Task ID.
     80 * @param ioaddr        Starting address of the I/O range.
     81 * @param size          Size of the range.
    11882 *
    119  * @return EOK on success
    120  * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
    121  * @return ENOENT if there is no task with specified ID
    122  * @return ENOMEM if there was some problem in allocating memory.
    123  *
     83 * @return              0 on success, EPERM if the caller lacks the
     84 *                      CAP_IO_MANAGER capability, ENOENT if there is no task
     85 *                      with specified ID and ENOMEM if there was some problem
     86 *                      in allocating memory.
    12487 */
    12588int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
    12689{
    12790        ddi_ioarg_t arg;
    128        
     91
    12992        arg.task_id = id;
    13093        arg.ioaddr = ioaddr;
    13194        arg.size = size;
    132        
     95
    13396        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
    13497}
     
    13699/** Enable PIO for specified I/O range.
    137100 *
    138  * @param pio_addr I/O start address.
    139  * @param size     Size of the I/O region.
    140  * @param use_addr Address where the final address for
    141  *                 application's PIO will be stored.
     101 * @param pio_addr      I/O start address.
     102 * @param size          Size of the I/O region.
     103 * @param use_addr      Address where the final address for application's PIO
     104 *                      will be stored.
    142105 *
    143  * @return Zero on success or negative error code.
    144  *
     106 * @return              Zero on success or negative error code.
    145107 */
    146108int pio_enable(void *pio_addr, size_t size, void **use_addr)
     
    150112        size_t offset;
    151113        unsigned int pages;
    152        
     114
    153115#ifdef IO_SPACE_BOUNDARY
    154116        if (pio_addr < IO_SPACE_BOUNDARY) {
     
    157119        }
    158120#endif
    159        
     121
    160122        phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
    161123        offset = pio_addr - phys;
Note: See TracChangeset for help on using the changeset viewer.