Changeset 153cc76a in mainline for uspace/lib/c/generic/ddi.c
- Timestamp:
- 2011-12-23T16:42:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e1b130
- Parents:
- 4291215 (diff), 2f0dd2a (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
r4291215 r153cc76a 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> … … 42 45 #include <align.h> 43 46 #include <libarch/config.h> 47 #include "private/libc.h" 44 48 45 49 /** Return unique device number. … … 57 61 * Caller of this function must have the CAP_MEM_MANAGER capability. 58 62 * 59 * @param pf Physical address of the starting frame. 60 * @param vp Virtual address of the starting page. 63 * @param phys Physical address of the starting frame. 61 64 * @param pages Number of pages to map. 62 65 * @param flags Flags for the new address space area. 66 * @param virt Virtual address of the starting page. 63 67 * 64 68 * @return EOK on success … … 69 73 * 70 74 */ 71 int physmem_map(void *p f, void *vp, size_t pages, unsigned int flags)75 int physmem_map(void *phys, size_t pages, unsigned int flags, void **virt) 72 76 { 73 return __SYSCALL 4(SYS_PHYSMEM_MAP, (sysarg_t) pf, (sysarg_t) vp,74 pages, flags );77 return __SYSCALL5(SYS_PHYSMEM_MAP, (sysarg_t) phys, 78 pages, flags, (sysarg_t) virt, (sysarg_t) __entry); 75 79 } 76 80 77 int dmamem_map( dmamem_t *dmamem, size_t pages, unsigned int map_flags,78 unsigned int dma_flags)81 int dmamem_map(void *virt, size_t size, unsigned int map_flags, 82 unsigned int flags, void **phys) 79 83 { 80 // FIXME TODO 81 return -1; 84 return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size, 85 (sysarg_t) map_flags, (sysarg_t) flags & ~DMAMEM_FLAGS_ANONYMOUS, 86 (sysarg_t) phys, (sysarg_t) virt, 0); 82 87 } 83 88 84 int dmamem_unmap(dmamem_t *dmamem) 89 int dmamem_map_anonymous(size_t size, unsigned int map_flags, 90 unsigned int flags, void **phys, void **virt) 85 91 { 86 // FIXME TODO 87 return -1; 92 return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size, 93 (sysarg_t) map_flags, (sysarg_t) flags | DMAMEM_FLAGS_ANONYMOUS, 94 (sysarg_t) phys, (sysarg_t) virt, (sysarg_t) __entry); 88 95 } 89 96 90 int dmamem_ lock(void *virt, void **phys, size_t pages)97 int dmamem_unmap(void *virt, size_t size) 91 98 { 92 // FIXME TODO 93 return -1; 99 return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, (sysarg_t) size, 0); 94 100 } 95 101 96 int dmamem_un lock(void *virt, size_t pages)102 int dmamem_unmap_anonymous(void *virt) 97 103 { 98 // FIXME TODO99 return -1;104 return __SYSCALL3(SYS_DMAMEM_UNMAP, (sysarg_t) virt, 0, 105 DMAMEM_FLAGS_ANONYMOUS); 100 106 } 101 107 … … 129 135 * @param pio_addr I/O start address. 130 136 * @param size Size of the I/O region. 131 * @param use_addr Address where the final address for132 * application's PIO will be stored.137 * @param virt Virtual address for application's 138 * PIO operations. 133 139 * 134 * @return Zero on success or negative error code. 140 * @return EOK on success. 141 * @return Negative error code on failure. 135 142 * 136 143 */ 137 int pio_enable(void *pio_addr, size_t size, void ** use_addr)144 int pio_enable(void *pio_addr, size_t size, void **virt) 138 145 { 139 void *phys;140 void *virt;141 size_t offset;142 unsigned int pages;143 144 146 #ifdef IO_SPACE_BOUNDARY 145 147 if (pio_addr < IO_SPACE_BOUNDARY) { 146 * use_addr= pio_addr;148 *virt = pio_addr; 147 149 return iospace_enable(task_get_id(), pio_addr, size); 148 150 } 149 151 #endif 150 152 151 phys = (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 152 offset = pio_addr - phys; 153 pages = ALIGN_UP(offset + size, PAGE_SIZE) >> PAGE_WIDTH; 154 virt = as_get_mappable_page(pages << PAGE_WIDTH); 155 *use_addr = virt + offset; 156 return physmem_map(phys, virt, pages, AS_AREA_READ | AS_AREA_WRITE); 153 void *phys_frame = 154 (void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 155 size_t offset = pio_addr - phys_frame; 156 size_t pages = SIZE2PAGES(offset + size); 157 158 void *virt_page; 159 int rc = physmem_map(phys_frame, pages, 160 AS_AREA_READ | AS_AREA_WRITE, &virt_page); 161 if (rc != EOK) 162 return rc; 163 164 *virt = virt_page + offset; 165 return EOK; 157 166 } 158 167 … … 167 176 * 168 177 */ 169 int register_irq(int inr, int devno, int method, irq_code_t *ucode)178 int irq_register(int inr, int devno, int method, irq_code_t *ucode) 170 179 { 171 return __SYSCALL4(SYS_ REGISTER_IRQ, inr, devno, method,180 return __SYSCALL4(SYS_IRQ_REGISTER, inr, devno, method, 172 181 (sysarg_t) ucode); 173 182 } … … 181 190 * 182 191 */ 183 int unregister_irq(int inr, int devno)192 int irq_unregister(int inr, int devno) 184 193 { 185 return __SYSCALL2(SYS_ UNREGISTER_IRQ, inr, devno);194 return __SYSCALL2(SYS_IRQ_UNREGISTER, inr, devno); 186 195 } 187 196
Note:
See TracChangeset
for help on using the changeset viewer.