Changes in uspace/lib/c/generic/ddi.c [c6ae4c2:c0699467] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ddi.c
rc6ae4c2 rc0699467 33 33 */ 34 34 35 #include <assert.h>36 #include <unistd.h>37 #include <errno.h>38 35 #include <sys/types.h> 39 36 #include <abi/ddi/arg.h> … … 56 53 } 57 54 58 /** Map apiece of physical memory to task.55 /** Map piece of physical memory to task. 59 56 * 60 57 * Caller of this function must have the CAP_MEM_MANAGER capability. 61 58 * 62 * @param p hysPhysical address of the starting frame.63 * @param v irtVirtual address of the starting page.64 * @param pages 65 * @param flags 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. 66 63 * 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. 73 68 */ 74 int physmem_map(void *p hys, void *virt, size_t pages, unsignedint flags)69 int physmem_map(void *pf, void *vp, unsigned long pages, int flags) 75 70 { 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); 109 73 } 110 74 … … 113 77 * Caller of this function must have the IO_MEM_MANAGER capability. 114 78 * 115 * @param id 116 * @param ioaddr 117 * @param size 79 * @param id Task ID. 80 * @param ioaddr Starting address of the I/O range. 81 * @param size Size of the range. 118 82 * 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. 124 87 */ 125 88 int iospace_enable(task_id_t id, void *ioaddr, unsigned long size) 126 89 { 127 90 ddi_ioarg_t arg; 128 91 129 92 arg.task_id = id; 130 93 arg.ioaddr = ioaddr; 131 94 arg.size = size; 132 95 133 96 return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg); 134 97 } … … 136 99 /** Enable PIO for specified I/O range. 137 100 * 138 * @param pio_addr 139 * @param size 140 * @param use_addr Address where the final address for141 * application's PIOwill 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. 142 105 * 143 * @return Zero on success or negative error code. 144 * 106 * @return Zero on success or negative error code. 145 107 */ 146 108 int pio_enable(void *pio_addr, size_t size, void **use_addr) … … 150 112 size_t offset; 151 113 unsigned int pages; 152 114 153 115 #ifdef IO_SPACE_BOUNDARY 154 116 if (pio_addr < IO_SPACE_BOUNDARY) { … … 157 119 } 158 120 #endif 159 121 160 122 phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 161 123 offset = pio_addr - phys;
Note:
See TracChangeset
for help on using the changeset viewer.