Changeset f52e54da in mainline for generic/src/ddi/ddi.c
- Timestamp:
- 2006-04-14T09:08:10Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e1b581
- Parents:
- 9c1ecf9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/ddi/ddi.c
r9c1ecf9 rf52e54da 112 112 } 113 113 114 /** Enable range of I/O space for task. 115 * 116 * @param id Task ID of the destination task. 117 * @param ioaddr Starting I/O address. 118 * @param size Size of the enabled I/O space.. 119 * 120 * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall, 121 * ENOENT if there is no task matching the specified ID. 122 */ 123 static int ddi_enable_iospace(task_id_t id, __address ioaddr, size_t size) 124 { 125 ipl_t ipl; 126 cap_t caps; 127 task_t *t; 128 int rc; 129 130 /* 131 * Make sure the caller is authorised to make this syscall. 132 */ 133 caps = cap_get(TASK); 134 if (!(caps & CAP_IO_MANAGER)) 135 return EPERM; 136 137 ipl = interrupts_disable(); 138 spinlock_lock(&tasks_lock); 139 140 t = task_find_by_id(id); 141 142 if (!t) { 143 /* 144 * There is no task with the specified ID. 145 */ 146 spinlock_unlock(&tasks_lock); 147 interrupts_restore(ipl); 148 return ENOENT; 149 } 150 151 /* 152 * TODO: We are currently lacking support for task destroying. 153 * Once it is added to the kernel, we must take care to 154 * synchronize in a way that prevents race conditions here. 155 */ 156 157 /* Lock the task and release the lock protecting tasks_btree. */ 158 spinlock_lock(&t->lock); 159 spinlock_unlock(&tasks_lock); 160 161 rc = ddi_enable_iospace_arch(t, ioaddr, size); 162 163 spinlock_unlock(&t->lock); 164 interrupts_restore(ipl); 165 return rc; 166 } 167 114 168 /** Wrapper for SYS_MAP_PHYSMEM syscall. 169 * 170 * @param User space address of memory DDI argument structure. 171 * 172 * @return 0 on success, otherwise it returns error code found in errno.h 173 */ 174 __native sys_map_physmem(ddi_memarg_t *uspace_mem_arg) 175 { 176 ddi_memarg_t arg; 177 178 copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); 179 return (__native) ddi_map_physmem((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE), 180 ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages, 181 (bool) arg.writable); 182 } 183 184 /** Wrapper for SYS_ENABLE_IOSPACE syscall. 115 185 * 116 186 * @param User space address of DDI argument structure. … … 118 188 * @return 0 on success, otherwise it returns error code found in errno.h 119 189 */ 120 __native sys_ map_physmem(ddi_arg_t *uspace_ddi_arg)190 __native sys_enable_iospace(ddi_ioarg_t *uspace_io_arg) 121 191 { 122 ddi_ arg_t arg;192 ddi_ioarg_t arg; 123 193 124 copy_from_uspace(&arg, uspace_ddi_arg, sizeof(ddi_arg_t)); 125 return (__native) ddi_map_physmem((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE), 126 ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages, 127 (bool) arg.writable); 194 copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 195 return (__native) ddi_enable_iospace((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size); 128 196 }
Note:
See TracChangeset
for help on using the changeset viewer.