Changeset f93ba6d in mainline
- Timestamp:
- 2014-08-31T19:01:29Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c62a8275
- Parents:
- af0a2c7 (diff), 6eeb4a3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 5 deleted
- 15 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
raf0a2c7 rf93ba6d 346 346 ! [PLATFORM=amd64] CONFIG_FENCES_P4 (y) 347 347 348 % IOMAP bitmap support 349 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_IOMAP_BITMAP (y) 350 351 % IOMAP dummy support 352 ! [PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32|PLATFORM=sparc64] CONFIG_IOMAP_DUMMY (y) 353 348 354 % ACPI support 349 355 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_ACPI (y) -
kernel/arch/abs32le/Makefile.inc
raf0a2c7 rf93ba6d 50 50 arch/$(KARCH)/src/userspace.c \ 51 51 arch/$(KARCH)/src/cpu/cpu.c \ 52 arch/$(KARCH)/src/ddi/ddi.c \53 52 arch/$(KARCH)/src/smp/smp.c \ 54 53 arch/$(KARCH)/src/smp/ipi.c \ -
kernel/arch/amd64/src/ddi/ddi.c
raf0a2c7 rf93ba6d 45 45 #include <arch.h> 46 46 #include <align.h> 47 48 /** Enable I/O space range for task.49 *50 * Interrupts are disabled and task is locked.51 *52 * @param task Task.53 * @param ioaddr Startign I/O space address.54 * @param size Size of the enabled I/O range.55 *56 * @return 0 on success or an error code from errno.h.57 *58 */59 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)60 {61 size_t elements = ioaddr + size;62 if (elements > IO_PORTS)63 return ENOENT;64 65 if (task->arch.iomap.elements < elements) {66 /*67 * The I/O permission bitmap is too small and needs to be grown.68 */69 70 void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);71 if (!store)72 return ENOMEM;73 74 bitmap_t oldiomap;75 bitmap_initialize(&oldiomap, task->arch.iomap.elements,76 task->arch.iomap.bits);77 78 bitmap_initialize(&task->arch.iomap, elements, store);79 80 /*81 * Mark the new range inaccessible.82 */83 bitmap_set_range(&task->arch.iomap, oldiomap.elements,84 elements - oldiomap.elements);85 86 /*87 * In case there really existed smaller iomap,88 * copy its contents and deallocate it.89 */90 if (oldiomap.bits) {91 bitmap_copy(&task->arch.iomap, &oldiomap,92 oldiomap.elements);93 94 free(oldiomap.bits);95 }96 }97 98 /*99 * Enable the range and we are done.100 */101 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);102 103 /*104 * Increment I/O Permission bitmap generation counter.105 */106 task->arch.iomapver++;107 108 return 0;109 }110 47 111 48 /** Install I/O Permission bitmap. -
kernel/arch/arm32/Makefile.inc
raf0a2c7 rf93ba6d 54 54 arch/$(KARCH)/src/dummy.S \ 55 55 arch/$(KARCH)/src/cpu/cpu.c \ 56 arch/$(KARCH)/src/ddi/ddi.c \57 56 arch/$(KARCH)/src/interrupt.c \ 58 57 arch/$(KARCH)/src/exception.c \ -
kernel/arch/ia32/src/ddi/ddi.c
raf0a2c7 rf93ba6d 45 45 #include <arch.h> 46 46 #include <align.h> 47 48 /** Enable I/O space range for task.49 *50 * Interrupts are disabled and task is locked.51 *52 * @param task Task.53 * @param ioaddr Startign I/O space address.54 * @param size Size of the enabled I/O range.55 *56 * @return 0 on success or an error code from errno.h.57 *58 */59 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)60 {61 size_t elements = ioaddr + size;62 if (elements > IO_PORTS)63 return ENOENT;64 65 if (task->arch.iomap.elements < elements) {66 /*67 * The I/O permission bitmap is too small and needs to be grown.68 */69 70 void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);71 if (!store)72 return ENOMEM;73 74 bitmap_t oldiomap;75 bitmap_initialize(&oldiomap, task->arch.iomap.elements,76 task->arch.iomap.bits);77 78 bitmap_initialize(&task->arch.iomap, elements, store);79 80 /*81 * Mark the new range inaccessible.82 */83 bitmap_set_range(&task->arch.iomap, oldiomap.elements,84 elements - oldiomap.elements);85 86 /*87 * In case there really existed smaller iomap,88 * copy its contents and deallocate it.89 */90 if (oldiomap.bits) {91 bitmap_copy(&task->arch.iomap, &oldiomap,92 oldiomap.elements);93 94 free(oldiomap.bits);95 }96 }97 98 /*99 * Enable the range and we are done.100 */101 bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);102 103 /*104 * Increment I/O Permission bitmap generation counter.105 */106 task->arch.iomapver++;107 108 return 0;109 }110 47 111 48 /** Install I/O Permission bitmap. -
kernel/arch/ia64/src/ddi/ddi.c
raf0a2c7 rf93ba6d 47 47 * Interrupts are disabled and task is locked. 48 48 * 49 * @param task 50 * @param ioaddr 51 * @param size 49 * @param task Task. 50 * @param ioaddr Starting I/O space address. 51 * @param size Size of the enabled I/O range. 52 52 * 53 * @return 0on success or an error code from errno.h.53 * @return EOK on success or an error code from errno.h. 54 54 */ 55 55 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) … … 72 72 bitmap_set_range(task->arch.iomap, iopage, size / 4); 73 73 74 return 0; 74 return EOK; 75 } 76 77 /** Disable I/O space range for task. 78 * 79 * Interrupts are disabled and task is locked. 80 * 81 * @param task Task. 82 * @param ioaddr Starting I/O space address. 83 * @param size Size of the disabled I/O range. 84 * 85 * @return EOK on success or an error code from errno.h. 86 */ 87 int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size) 88 { 89 if (!task->arch.iomap) 90 return EINVAL; 91 92 uintptr_t iopage = ioaddr / PORTS_PER_PAGE; 93 size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE); 94 bitmap_clear_range(task->arch.iomap, iopage, size / 4); 95 96 return EOK; 75 97 } 76 98 -
kernel/arch/mips32/Makefile.inc
raf0a2c7 rf93ba6d 70 70 arch/$(KARCH)/src/mm/as.c \ 71 71 arch/$(KARCH)/src/fpu_context.c \ 72 arch/$(KARCH)/src/ddi/ddi.c \73 72 arch/$(KARCH)/src/smp/smp.c \ 74 73 arch/$(KARCH)/src/machine_func.c -
kernel/arch/ppc32/Makefile.inc
raf0a2c7 rf93ba6d 51 51 arch/$(KARCH)/src/cpu/cpu.c \ 52 52 arch/$(KARCH)/src/proc/scheduler.c \ 53 arch/$(KARCH)/src/ddi/ddi.c \54 53 arch/$(KARCH)/src/mm/km.c \ 55 54 arch/$(KARCH)/src/mm/as.c \ -
kernel/arch/sparc32/Makefile.inc
raf0a2c7 rf93ba6d 45 45 arch/$(KARCH)/src/exception.c \ 46 46 arch/$(KARCH)/src/cpu/cpu.c \ 47 arch/$(KARCH)/src/ddi/ddi.c \48 47 arch/$(KARCH)/src/smp/smp.c \ 49 48 arch/$(KARCH)/src/smp/ipi.c \ -
kernel/arch/sparc64/Makefile.inc
raf0a2c7 rf93ba6d 81 81 arch/$(KARCH)/src/trap/exception.c \ 82 82 arch/$(KARCH)/src/trap/interrupt.c \ 83 arch/$(KARCH)/src/ddi/ddi.c \84 83 arch/$(KARCH)/src/drivers/tick.c \ 85 84 arch/$(KARCH)/src/drivers/kbd.c \ -
kernel/genarch/Makefile.inc
raf0a2c7 rf93ba6d 181 181 genarch/src/drivers/ega/ega.c 182 182 endif 183 184 ifeq ($(CONFIG_IOMAP_BITMAP), y) 185 GENARCH_SOURCES += \ 186 genarch/src/ddi/ddi-bitmap.c 187 endif 188 189 ifeq ($(CONFIG_IOMAP_DUMMY), y) 190 GENARCH_SOURCES += \ 191 genarch/src/ddi/ddi-dummy.c 192 endif 193 -
kernel/genarch/src/ddi/ddi-dummy.c
raf0a2c7 rf93ba6d 27 27 */ 28 28 29 /** @addtogroup sparc64ddi29 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief DDI. 33 34 */ 34 35 … … 41 42 * Interrupts are disabled and task is locked. 42 43 * 43 * @param task Task.44 * @param task Task. 44 45 * @param ioaddr Starting I/O space address. 45 * @param size Size of the enabled I/O range.46 * @param size Size of the enabled I/O range. 46 47 * 47 * @return 0on success or an error code from errno.h.48 * @return EOK on success or an error code from errno.h. 48 49 */ 49 50 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size) … … 52 53 } 53 54 55 /** Disable I/O space range for task. 56 * 57 * Interrupts are disabled and task is locked. 58 * 59 * @param task Task. 60 * @param ioaddr Starting I/O space address. 61 * @param size Size of the disabled I/O range. 62 * 63 * @return EOK on success or an error code from errno.h. 64 */ 65 int ddi_iospace_disable_arch(task_t *task, uintptr_t ioaddr, size_t size) 66 { 67 return 0; 68 } 69 54 70 /** @} 55 71 */ -
kernel/generic/include/ddi/ddi.h
raf0a2c7 rf93ba6d 70 70 */ 71 71 extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t); 72 extern int ddi_iospace_disable_arch(task_t *, uintptr_t, size_t); 72 73 73 74 #endif -
kernel/generic/src/ddi/ddi.c
raf0a2c7 rf93ba6d 211 211 NO_TRACE static int physmem_unmap(uintptr_t virt) 212 212 { 213 // TODO: implement unmap 214 return EOK; 213 ASSERT(TASK); 214 215 return as_area_destroy(TASK->as, virt); 215 216 } 216 217 … … 255 256 /** Enable range of I/O space for task. 256 257 * 257 * @param id Task ID of the destination task.258 * @param id Task ID of the destination task. 258 259 * @param ioaddr Starting I/O address. 259 * @param size Size of the enabled I/O space..260 * @param size Size of the enabled I/O space. 260 261 * 261 262 * @return 0 on success, EPERM if the caller lacks capabilities to use this … … 290 291 int rc = ddi_iospace_enable_arch(task, ioaddr, size); 291 292 irq_spinlock_unlock(&task->lock, true); 293 294 return rc; 295 } 296 297 /** Disable range of I/O space for task. 298 * 299 * @param id Task ID of the destination task. 300 * @param ioaddr Starting I/O address. 301 * @param size Size of the enabled I/O space. 302 * 303 * @return 0 on success, EPERM if the caller lacks capabilities to use this 304 * syscall, ENOENT if there is no task matching the specified ID. 305 * 306 */ 307 NO_TRACE static int iospace_disable(task_id_t id, uintptr_t ioaddr, size_t size) 308 { 309 /* 310 * Make sure the caller is authorised to make this syscall. 311 */ 312 cap_t caps = cap_get(TASK); 313 if (!(caps & CAP_IO_MANAGER)) 314 return EPERM; 315 316 irq_spinlock_lock(&tasks_lock, true); 317 318 task_t *task = task_find_by_id(id); 319 320 if ((!task) || (!container_check(CONTAINER, task->container))) { 321 /* 322 * There is no task with the specified ID 323 * or the task belongs to a different security 324 * context. 325 */ 326 irq_spinlock_unlock(&tasks_lock, true); 327 return ENOENT; 328 } 329 330 /* Lock the task and release the lock protecting tasks_btree. */ 331 irq_spinlock_exchange(&tasks_lock, &task->lock); 332 int rc = ddi_iospace_disable_arch(task, ioaddr, size); 333 irq_spinlock_unlock(&task->lock, true); 292 334 293 335 return rc; … … 314 356 sysarg_t sys_iospace_disable(ddi_ioarg_t *uspace_io_arg) 315 357 { 316 // TODO: implement 317 return ENOTSUP; 358 ddi_ioarg_t arg; 359 int rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 360 if (rc != 0) 361 return (sysarg_t) rc; 362 363 return (sysarg_t) iospace_disable((task_id_t) arg.task_id, 364 (uintptr_t) arg.ioaddr, (size_t) arg.size); 318 365 } 319 366 -
uspace/lib/c/generic/ddi.c
raf0a2c7 rf93ba6d 87 87 } 88 88 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 */ 99 int physmem_unmap(void *virt) 100 { 101 return __SYSCALL1(SYS_PHYSMEM_UNMAP, (sysarg_t) virt); 102 } 103 89 104 /** Lock a piece physical memory for DMA transfers. 90 105 * … … 179 194 180 195 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 */ 211 static 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); 181 220 } 182 221 … … 273 312 } 274 313 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 */ 323 int 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 275 334 void pio_write_8(ioport8_t *reg, uint8_t val) 276 335 { -
uspace/lib/c/include/ddi.h
raf0a2c7 rf93ba6d 51 51 52 52 extern int physmem_map(uintptr_t, size_t, unsigned int, void **); 53 extern int physmem_unmap(void *); 53 54 54 55 extern int dmamem_map(void *, size_t, unsigned int, unsigned int, uintptr_t *); … … 61 62 extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **); 62 63 extern int pio_enable(void *, size_t, void **); 64 extern int pio_disable(void *, size_t); 63 65 64 66 typedef void (*trace_fnc)(const volatile void *place, uint32_t val,
Note:
See TracChangeset
for help on using the changeset viewer.