Changeset 0d5a50c in mainline
- Timestamp:
- 2009-03-01T20:25:23Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f94c3d
- Parents:
- bf25efb
- Location:
- uspace/lib/libc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/arch/ia32/include/ddi.h
rbf25efb r0d5a50c 33 33 #ifndef LIBC_ia32_DDI_H_ 34 34 #define LIBC_ia32_DDI_H_ 35 36 #define IO_SPACE_BOUNDARY ((void *) (64 * 1024)) 35 37 36 38 static inline void outb(int16_t port, uint8_t b) -
uspace/lib/libc/generic/ddi.c
rbf25efb r0d5a50c 36 36 #include <libc.h> 37 37 #include <task.h> 38 #include <as.h> 39 #include <align.h> 40 #include <libarch/config.h> 38 41 #include <kernel/ddi/ddi_arg.h> 39 42 … … 42 45 * Caller of this function must have the CAP_MEM_MANAGER capability. 43 46 * 44 * @param pf 45 * @param vp Virtual address of the sterting page.46 * @param pages 47 * @param flags 47 * @param pf Physical address of the starting frame. 48 * @param vp Virtual address of the starting page. 49 * @param pages Number of pages to map. 50 * @param flags Flags for the new address space area. 48 51 * 49 * @return 0 on success, EPERM if the caller lacks the CAP_MEM_MANAGER capability, 50 * ENOENT if there is no task with specified ID and ENOMEM if there 51 * was some problem in creating address space area. 52 * @return 0 on success, EPERM if the caller lacks the 53 * CAP_MEM_MANAGER capability, ENOENT if there is no task 54 * with specified ID and ENOMEM if there was some problem 55 * in creating address space area. 52 56 */ 53 57 int physmem_map(void *pf, void *vp, unsigned long pages, int flags) 54 58 { 55 return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages, flags); 59 return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages, 60 flags); 56 61 } 57 62 … … 60 65 * Caller of this function must have the IO_MEM_MANAGER capability. 61 66 * 62 * @param id 63 * @param ioaddr 64 * @param size 67 * @param id Task ID. 68 * @param ioaddr Starting address of the I/O range. 69 * @param size Size of the range. 65 70 * 66 * @return 0 on success, EPERM if the caller lacks the CAP_IO_MANAGER capability, 67 * ENOENT if there is no task with specified ID and ENOMEM if there 68 * was some problem in allocating memory. 71 * @return 0 on success, EPERM if the caller lacks the 72 * CAP_IO_MANAGER capability, ENOENT if there is no task 73 * with specified ID and ENOMEM if there was some problem 74 * in allocating memory. 69 75 */ 70 76 int iospace_enable(task_id_t id, void *ioaddr, unsigned long size) … … 81 87 /** Interrupt control 82 88 * 83 * @param enable 89 * @param enable 1 - enable interrupts, 0 - disable interrupts 84 90 */ 85 91 int preemption_control(int enable) … … 88 94 } 89 95 96 /** Enable PIO for specified I/O range. 97 * 98 * @param pio_addr I/O start address. 99 * @param size Size of the I/O region. 100 * @param use_addr Address where the final address for application's PIO 101 * will be stored. 102 * 103 * @return Zero on success or negative error code. 104 */ 105 int pio_enable(void *pio_addr, size_t size, void **use_addr) 106 { 107 void *phys; 108 void *virt; 109 size_t offset; 110 unsigned int pages; 111 112 #ifdef IO_SPACE_BOUNDARY 113 if (pio_addr < IO_SPACE_BOUNDARY) { 114 *use_addr = pio_addr; 115 return iospace_enable(task_get_id(), pio_addr, size); 116 } 117 #endif 118 119 phys = ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 120 offset = pio_addr - phys; 121 pages = ALIGN_UP(offset + size, PAGE_SIZE) >> PAGE_WIDTH; 122 virt = as_get_mappable_page(pages); 123 *use_addr = virt + offset; 124 return physmem_map(phys, virt, pages, AS_AREA_READ | AS_AREA_WRITE); 125 } 126 90 127 /** @} 91 128 */ -
uspace/lib/libc/include/ddi.h
rbf25efb r0d5a50c 38 38 #include <task.h> 39 39 40 extern int physmem_map(void *pf, void *vp, unsigned long pages, int flags); 41 extern int iospace_enable(task_id_t id, void *ioaddr, unsigned long size); 42 extern int preemption_control(int enable); 40 extern int physmem_map(void *, void *, unsigned long, int); 41 extern int iospace_enable(task_id_t, void *, unsigned long); 42 extern int preemption_control(int); 43 extern int pio_enable(void *, size_t, void **); 43 44 44 45 #endif
Note:
See TracChangeset
for help on using the changeset viewer.