Ignore:
File:
1 edited

Legend:

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

    r9359aae r8cd680c  
    7171 * @param flags Flags for the new address space area.
    7272 * @param virt  Virtual address of the starting page.
    73  *
    74  * @return EOK on success
    75  * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability
    76  * @return ENOENT if there is no task with specified ID
     73 *              If set to AS_AREA_ANY ((void *) -1), a suitable value
     74 *              is found by the kernel, otherwise the kernel tries to
     75 *              obey the desired value.
     76 *
     77 * @return EOK on success.
     78 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
    7779 * @return ENOMEM if there was some problem in creating
    7880 *         the address space area.
     
    8587}
    8688
     89/** Unmap a piece of physical memory to task.
     90 *
     91 * Caller of this function must have the CAP_MEM_MANAGER capability.
     92 *
     93 * @param virt Virtual address from the phys-mapped region.
     94 *
     95 * @return EOK on success.
     96 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     97 *
     98 */
     99int physmem_unmap(void *virt)
     100{
     101        return __SYSCALL1(SYS_PHYSMEM_UNMAP, (sysarg_t) virt);
     102}
     103
     104/** Lock a piece physical memory for DMA transfers.
     105 *
     106 * The mapping of the specified virtual memory address
     107 * to physical memory address is locked in order to
     108 * make it safe for DMA transferts.
     109 *
     110 * Caller of this function must have the CAP_MEM_MANAGER capability.
     111 *
     112 * @param virt      Virtual address of the memory to be locked.
     113 * @param size      Number of bytes to lock.
     114 * @param map_flags Desired virtual memory area flags.
     115 * @param flags     Flags for the physical memory address.
     116 * @param phys      Locked physical memory address.
     117 *
     118 * @return EOK on success.
     119 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     120 * @return ENOMEM if there was some problem in creating
     121 *         the address space area.
     122 *
     123 */
    87124int dmamem_map(void *virt, size_t size, unsigned int map_flags,
    88125    unsigned int flags, uintptr_t *phys)
     
    93130}
    94131
     132/** Map a piece of physical memory suitable for DMA transfers.
     133 *
     134 * Caller of this function must have the CAP_MEM_MANAGER capability.
     135 *
     136 * @param size       Number of bytes to map.
     137 * @param constraint Bit mask defining the contraint on the physical
     138 *                   address to be mapped.
     139 * @param map_flags  Desired virtual memory area flags.
     140 * @param flags      Flags for the physical memory address.
     141 * @param virt       Virtual address of the starting page.
     142 *                   If set to AS_AREA_ANY ((void *) -1), a suitable value
     143 *                   is found by the kernel, otherwise the kernel tries to
     144 *                   obey the desired value.
     145 *
     146 * @return EOK on success.
     147 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     148 * @return ENOMEM if there was some problem in creating
     149 *         the address space area.
     150 *
     151 */
    95152int dmamem_map_anonymous(size_t size, uintptr_t constraint,
    96153    unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt)
     
    137194       
    138195        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
     196}
     197
     198/** Disable I/O space range to task.
     199 *
     200 * Caller of this function must have the IO_MEM_MANAGER capability.
     201 *
     202 * @param id     Task ID.
     203 * @param ioaddr Starting address of the I/O range.
     204 * @param size   Size of the range.
     205 *
     206 * @return EOK on success
     207 * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
     208 * @return ENOENT if there is no task with specified ID
     209 *
     210 */
     211static int iospace_disable(task_id_t id, void *ioaddr, size_t size)
     212{
     213        const ddi_ioarg_t arg = {
     214                .task_id = id,
     215                .ioaddr = ioaddr,
     216                .size = size
     217        };
     218       
     219        return __SYSCALL1(SYS_IOSPACE_DISABLE, (sysarg_t) &arg);
    139220}
    140221
     
    221302        size_t pages = SIZE2PAGES(offset + size);
    222303       
    223         void *virt_page;
     304        void *virt_page = AS_AREA_ANY;
    224305        int rc = physmem_map(phys_frame, pages,
    225306            AS_AREA_READ | AS_AREA_WRITE, &virt_page);
     
    231312}
    232313
     314/** Disable PIO for specified I/O range.
     315 *
     316 * @param virt     I/O start address.
     317 * @param size     Size of the I/O region.
     318 *
     319 * @return EOK on success.
     320 * @return Negative error code on failure.
     321 *
     322 */
     323int pio_disable(void *virt, size_t size)
     324{
     325#ifdef IO_SPACE_BOUNDARY
     326        if (virt < IO_SPACE_BOUNDARY)
     327                return iospace_disable(task_get_id(), virt, size);
     328#else
     329        (void) iospace_disable;
     330#endif
     331        return physmem_unmap(virt);
     332}
     333
    233334void pio_write_8(ioport8_t *reg, uint8_t val)
    234335{
     
    270371}
    271372
    272 /** Register IRQ notification.
    273  *
    274  * @param inr    IRQ number.
    275  * @param devno  Device number of the device generating inr.
    276  * @param method Use this method for notifying me.
    277  * @param ucode  Top-half pseudocode handler.
    278  *
    279  * @return Value returned by the kernel.
    280  *
    281  */
    282 int irq_register(int inr, int devno, int method, const irq_code_t *ucode)
    283 {
    284         return __SYSCALL4(SYS_IRQ_REGISTER, inr, devno, method,
    285             (sysarg_t) ucode);
    286 }
    287 
    288 /** Unregister IRQ notification.
    289  *
    290  * @param inr   IRQ number.
    291  * @param devno Device number of the device generating inr.
    292  *
    293  * @return Value returned by the kernel.
    294  *
    295  */
    296 int irq_unregister(int inr, int devno)
    297 {
    298         return __SYSCALL2(SYS_IRQ_UNREGISTER, inr, devno);
    299 }
    300 
    301373/** @}
    302374 */
Note: See TracChangeset for help on using the changeset viewer.