Changeset 7aaed09 in mainline for uspace/lib/c/generic/ddi.c
- Timestamp:
- 2011-12-18T14:02:30Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c868e2d
- Parents:
- 3b71e84d (diff), 1761268 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ddi.c
r3b71e84d r7aaed09 33 33 */ 34 34 35 #include <assert.h> 36 #include <unistd.h> 37 #include <errno.h> 35 38 #include <sys/types.h> 36 39 #include <abi/ddi/arg.h> … … 53 56 } 54 57 55 /** Map piece of physical memory to task.58 /** Map a piece of physical memory to task. 56 59 * 57 60 * Caller of this function must have the CAP_MEM_MANAGER capability. 58 61 * 59 * @param p fPhysical address of the starting frame.60 * @param v pVirtual address of the starting page.61 * @param pages 62 * @param flags 62 * @param phys Physical address of the starting frame. 63 * @param virt Virtual address of the starting page. 64 * @param pages Number of pages to map. 65 * @param flags Flags for the new address space area. 63 66 * 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. 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 * 68 73 */ 69 int physmem_map(void *p f, void *vp, unsigned long pages,int flags)74 int physmem_map(void *phys, void *virt, size_t pages, unsigned int flags) 70 75 { 71 return __SYSCALL4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp, pages, 72 flags); 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); 73 109 } 74 110 … … 77 113 * Caller of this function must have the IO_MEM_MANAGER capability. 78 114 * 79 * @param id 80 * @param ioaddr 81 * @param size 115 * @param id Task ID. 116 * @param ioaddr Starting address of the I/O range. 117 * @param size Size of the range. 82 118 * 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. 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 * 87 124 */ 88 125 int iospace_enable(task_id_t id, void *ioaddr, unsigned long size) 89 126 { 90 127 ddi_ioarg_t arg; 91 128 92 129 arg.task_id = id; 93 130 arg.ioaddr = ioaddr; 94 131 arg.size = size; 95 132 96 133 return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg); 97 134 } … … 99 136 /** Enable PIO for specified I/O range. 100 137 * 101 * @param pio_addr 102 * @param size 103 * @param use_addr Address where the final address for application's PIO104 * 138 * @param pio_addr I/O start address. 139 * @param size Size of the I/O region. 140 * @param use_addr Address where the final address for 141 * application's PIO will be stored. 105 142 * 106 * @return Zero on success or negative error code. 143 * @return Zero on success or negative error code. 144 * 107 145 */ 108 146 int pio_enable(void *pio_addr, size_t size, void **use_addr) … … 112 150 size_t offset; 113 151 unsigned int pages; 114 152 115 153 #ifdef IO_SPACE_BOUNDARY 116 154 if (pio_addr < IO_SPACE_BOUNDARY) { … … 119 157 } 120 158 #endif 121 159 122 160 phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 123 161 offset = pio_addr - phys;
Note:
See TracChangeset
for help on using the changeset viewer.