Rev 1212 | Rev 1239 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1212 | Rev 1227 | ||
|---|---|---|---|
| Line 48... | Line 48... | ||
| 48 | * |
48 | * |
| 49 | * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall, |
49 | * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall, |
| 50 | * ENOENT if there is no task matching the specified ID and ENOMEM if |
50 | * ENOENT if there is no task matching the specified ID and ENOMEM if |
| 51 | * there was a problem in creating address space area. |
51 | * there was a problem in creating address space area. |
| 52 | */ |
52 | */ |
| 53 | static int ddi_map_physmem(task_id_t id, __address pf, __address vp, count_t pages, bool writable) |
53 | static int ddi_physmem_map(task_id_t id, __address pf, __address vp, count_t pages, bool writable) |
| 54 | { |
54 | { |
| 55 | ipl_t ipl; |
55 | ipl_t ipl; |
| 56 | cap_t caps; |
56 | cap_t caps; |
| 57 | task_t *t; |
57 | task_t *t; |
| 58 | int flags; |
58 | int flags; |
| Line 118... | Line 118... | ||
| 118 | * @param size Size of the enabled I/O space.. |
118 | * @param size Size of the enabled I/O space.. |
| 119 | * |
119 | * |
| 120 | * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall, |
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. |
121 | * ENOENT if there is no task matching the specified ID. |
| 122 | */ |
122 | */ |
| 123 | static int ddi_enable_iospace(task_id_t id, __address ioaddr, size_t size) |
123 | static int ddi_iospace_enable(task_id_t id, __address ioaddr, size_t size) |
| 124 | { |
124 | { |
| 125 | ipl_t ipl; |
125 | ipl_t ipl; |
| 126 | cap_t caps; |
126 | cap_t caps; |
| 127 | task_t *t; |
127 | task_t *t; |
| 128 | int rc; |
128 | int rc; |
| Line 156... | Line 156... | ||
| 156 | 156 | ||
| 157 | /* Lock the task and release the lock protecting tasks_btree. */ |
157 | /* Lock the task and release the lock protecting tasks_btree. */ |
| 158 | spinlock_lock(&t->lock); |
158 | spinlock_lock(&t->lock); |
| 159 | spinlock_unlock(&tasks_lock); |
159 | spinlock_unlock(&tasks_lock); |
| 160 | 160 | ||
| 161 | rc = ddi_enable_iospace_arch(t, ioaddr, size); |
161 | rc = ddi_iospace_enable_arch(t, ioaddr, size); |
| 162 | 162 | ||
| 163 | spinlock_unlock(&t->lock); |
163 | spinlock_unlock(&t->lock); |
| 164 | interrupts_restore(ipl); |
164 | interrupts_restore(ipl); |
| 165 | return rc; |
165 | return rc; |
| 166 | } |
166 | } |
| Line 169... | Line 169... | ||
| 169 | * |
169 | * |
| 170 | * @param User space address of memory DDI argument structure. |
170 | * @param User space address of memory DDI argument structure. |
| 171 | * |
171 | * |
| 172 | * @return 0 on success, otherwise it returns error code found in errno.h |
172 | * @return 0 on success, otherwise it returns error code found in errno.h |
| 173 | */ |
173 | */ |
| 174 | __native sys_map_physmem(ddi_memarg_t *uspace_mem_arg) |
174 | __native sys_physmem_map(ddi_memarg_t *uspace_mem_arg) |
| 175 | { |
175 | { |
| 176 | ddi_memarg_t arg; |
176 | ddi_memarg_t arg; |
| 177 | 177 | ||
| 178 | copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); |
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), |
179 | return (__native) ddi_physmem_map((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, |
180 | ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages, |
| 181 | (bool) arg.writable); |
181 | (bool) arg.writable); |
| 182 | } |
182 | } |
| 183 | 183 | ||
| 184 | /** Wrapper for SYS_ENABLE_IOSPACE syscall. |
184 | /** Wrapper for SYS_ENABLE_IOSPACE syscall. |
| 185 | * |
185 | * |
| 186 | * @param User space address of DDI argument structure. |
186 | * @param User space address of DDI argument structure. |
| 187 | * |
187 | * |
| 188 | * @return 0 on success, otherwise it returns error code found in errno.h |
188 | * @return 0 on success, otherwise it returns error code found in errno.h |
| 189 | */ |
189 | */ |
| 190 | __native sys_enable_iospace(ddi_ioarg_t *uspace_io_arg) |
190 | __native sys_iospace_enable(ddi_ioarg_t *uspace_io_arg) |
| 191 | { |
191 | { |
| 192 | ddi_ioarg_t arg; |
192 | ddi_ioarg_t arg; |
| 193 | 193 | ||
| 194 | copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); |
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); |
195 | return (__native) ddi_iospace_enable((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size); |
| 196 | } |
196 | } |
| 197 | 197 | ||
| 198 | __native ddi_int_control(__native enable, __native *flags) |
198 | __native ddi_int_control(__native enable, __native *flags) |
| 199 | { |
199 | { |
| 200 | if (! cap_get(TASK) & CAP_INT_CONTROL) |
200 | if (! cap_get(TASK) & CAP_INT_CONTROL) |
| 201 | return EPERM; |
201 | return EPERM; |
| 202 | return ddi_int_control_arch(enable, flags); |
202 | return ddi_int_control_arch(enable, flags); |
| 203 | } |
203 | } |
| 204 | - | ||