Changeset 8565a42 in mainline for uspace/lib/c/generic/device
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (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. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- Location:
- uspace/lib/c/generic/device
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/device/hw_res.c
r3061bc1 r8565a42 42 42 { 43 43 sysarg_t count = 0; 44 44 45 45 async_exch_t *exch = async_exchange_begin(sess); 46 46 47 47 errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 48 48 HW_RES_GET_RESOURCE_LIST, &count); 49 49 50 50 if (rc != EOK) { 51 51 async_exchange_end(exch); 52 52 return rc; 53 53 } 54 54 55 55 size_t size = count * sizeof(hw_resource_t); 56 56 hw_resource_t *resources = (hw_resource_t *) malloc(size); … … 60 60 return ENOMEM; 61 61 } 62 62 63 63 rc = async_data_read_start(exch, resources, size); 64 64 async_exchange_end(exch); 65 65 66 66 if (rc != EOK) { 67 67 free(resources); 68 68 return rc; 69 69 } 70 70 71 71 hw_resources->resources = resources; 72 72 hw_resources->count = count; 73 73 74 74 return EOK; 75 75 } … … 78 78 { 79 79 async_exch_t *exch = async_exchange_begin(sess); 80 80 81 81 errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 82 82 HW_RES_ENABLE_INTERRUPT, irq); 83 83 async_exchange_end(exch); 84 84 85 85 return rc; 86 86 } … … 89 89 { 90 90 async_exch_t *exch = async_exchange_begin(sess); 91 91 92 92 errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 93 93 HW_RES_DISABLE_INTERRUPT, irq); 94 94 async_exchange_end(exch); 95 95 96 96 return rc; 97 97 } … … 100 100 { 101 101 async_exch_t *exch = async_exchange_begin(sess); 102 102 103 103 errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 104 104 HW_RES_CLEAR_INTERRUPT, irq); 105 105 async_exchange_end(exch); 106 106 107 107 return rc; 108 108 } … … 126 126 { 127 127 async_exch_t *exch = async_exchange_begin(sess); 128 128 129 129 const uint32_t packed = (channel & 0xffff) | (mode << 16); 130 130 const errno_t ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 131 131 HW_RES_DMA_CHANNEL_SETUP, packed, pa, size); 132 132 133 133 async_exchange_end(exch); 134 134 135 135 return ret; 136 136 } … … 148 148 { 149 149 async_exch_t *exch = async_exchange_begin(sess); 150 150 151 151 sysarg_t remain; 152 152 const errno_t ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 153 153 HW_RES_DMA_CHANNEL_REMAIN, channel, &remain); 154 154 155 155 async_exchange_end(exch); 156 156 157 157 if (ret == EOK) 158 158 *rem = remain; 159 159 160 160 return ret; 161 161 } -
uspace/lib/c/generic/device/hw_res_parsed.c
r3061bc1 r8565a42 43 43 assert(res); 44 44 assert((res->type == DMA_CHANNEL_8) || (res->type == DMA_CHANNEL_16)); 45 45 46 46 const unsigned channel = (res->type == DMA_CHANNEL_8) ? 47 47 res->res.dma_channel.dma8 : res->res.dma_channel.dma16; 48 48 const size_t count = out->dma_channels.count; 49 49 const int keep_duplicit = flags & HW_RES_KEEP_DUPLICIT; 50 50 51 51 if (!keep_duplicit) { 52 52 for (size_t i = 0; i < count; ++i) { … … 55 55 } 56 56 } 57 57 58 58 out->dma_channels.channels[count] = channel; 59 59 ++out->dma_channels.count; … … 64 64 { 65 65 assert(res && (res->type == INTERRUPT)); 66 66 67 67 int irq = res->res.interrupt.irq; 68 68 size_t count = out->irqs.count; 69 69 int keep_duplicit = flags & HW_RES_KEEP_DUPLICIT; 70 70 71 71 if (!keep_duplicit) { 72 72 for (size_t i = 0; i < count; i++) { … … 75 75 } 76 76 } 77 77 78 78 out->irqs.irqs[count] = irq; 79 79 out->irqs.count++; … … 105 105 106 106 assert(res && (res->type == IO_RANGE)); 107 107 108 108 absolute = absolutize(res->res.io_range.address, 109 109 res->res.io_range.relative, win->io.base); … … 112 112 size = res->res.io_range.size; 113 113 endianness = res->res.io_range.endianness; 114 114 115 115 if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA))) 116 116 return; 117 117 118 118 int keep_duplicit = flags & HW_RES_KEEP_DUPLICIT; 119 119 size_t count = out->io_ranges.count; 120 120 121 121 if (!keep_duplicit) { 122 122 for (size_t i = 0; i < count; i++) { … … 126 126 s_address = RNGABS(out->io_ranges.ranges[i]); 127 127 s_size = RNGSZ(out->io_ranges.ranges[i]); 128 128 129 129 if ((absolute == s_address) && (size == s_size)) 130 130 return; 131 131 } 132 132 } 133 133 134 134 RNGABS(out->io_ranges.ranges[count]) = absolute; 135 135 RNGREL(out->io_ranges.ranges[count]) = relative; … … 146 146 uint64_t relative; 147 147 size_t size; 148 148 149 149 assert(res && (res->type == MEM_RANGE)); 150 150 151 151 absolute = absolutize(res->res.mem_range.address, 152 152 res->res.mem_range.relative, win->mem.base); … … 155 155 size = res->res.mem_range.size; 156 156 endianness = res->res.mem_range.endianness; 157 157 158 158 if ((size == 0) && (!(flags & HW_RES_KEEP_ZERO_AREA))) 159 159 return; 160 160 161 161 int keep_duplicit = flags & HW_RES_KEEP_DUPLICIT; 162 162 size_t count = out->mem_ranges.count; 163 163 164 164 if (!keep_duplicit) { 165 165 for (size_t i = 0; i < count; ++i) { … … 169 169 s_address = RNGABS(out->mem_ranges.ranges[i]);; 170 170 s_size = RNGSZ(out->mem_ranges.ranges[i]); 171 171 172 172 if ((absolute == s_address) && (size == s_size)) 173 173 return; 174 174 } 175 175 } 176 176 177 177 RNGABS(out->mem_ranges.ranges[count]) = absolute; 178 178 RNGREL(out->mem_ranges.ranges[count]) = relative; … … 199 199 if (!res || !out) 200 200 return EINVAL; 201 201 202 202 size_t res_count = res->count; 203 203 hw_res_list_parsed_clean(out); 204 204 205 205 out->irqs.irqs = calloc(res_count, sizeof(int)); 206 206 out->dma_channels.channels = calloc(res_count, sizeof(int)); … … 212 212 return ENOMEM; 213 213 } 214 214 215 215 for (size_t i = 0; i < res_count; ++i) { 216 216 const hw_resource_t *resource = &res->resources[i]; 217 217 218 218 switch (resource->type) { 219 219 case INTERRUPT: … … 235 235 } 236 236 } 237 237 238 238 return EOK; 239 239 }; … … 261 261 if (!hw_res_parsed) 262 262 return EBADMEM; 263 263 264 264 hw_resource_list_t hw_resources; 265 265 hw_res_list_parsed_clean(hw_res_parsed); … … 269 269 if (rc != EOK) 270 270 return rc; 271 271 272 272 rc = hw_res_get_resource_list(sess, &hw_resources); 273 273 if (rc != EOK) … … 277 277 flags); 278 278 hw_res_clean_resource_list(&hw_resources); 279 279 280 280 return rc; 281 281 }; -
uspace/lib/c/generic/device/led_dev.c
r3061bc1 r8565a42 42 42 { 43 43 async_exch_t *exch = async_exchange_begin(sess); 44 44 45 45 aid_t req = async_send_2(exch, DEV_IFACE_ID(LED_DEV_IFACE), 46 46 LED_DEV_COLOR_SET, (sysarg_t) pixel, NULL); 47 47 48 48 async_exchange_end(exch); 49 49 50 50 errno_t rc; 51 51 async_wait_for(req, &rc); 52 52 53 53 return (errno_t) rc; 54 54 } -
uspace/lib/c/generic/device/pio_window.c
r3061bc1 r8565a42 51 51 return rc; 52 52 } 53 53 54 54 rc = async_data_read_start(exch, pio_win, sizeof(*pio_win)); 55 55 async_exchange_end(exch); 56 56 57 57 return rc; 58 58 }
Note:
See TracChangeset
for help on using the changeset viewer.