Changeset a5b3de6 in mainline
- Timestamp:
- 2017-10-25T11:55:15Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2b35478
- Parents:
- c3d926f3
- Location:
- uspace
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_rh.c
rc3d926f3 ra5b3de6 144 144 assert(instance); 145 145 assert(batch); 146 const usb_target_t target = batch->ep->target; 147 batch->error = virthub_base_request(&instance->base, target, 146 batch->error = virthub_base_request(&instance->base, batch->target, 148 147 batch->dir, (void*) batch->setup.buffer, 149 148 batch->buffer, batch->buffer_size, &batch->transfered_size); … … 179 178 instance, batch); 180 179 if (batch) { 181 const usb_target_t target = batch->ep->target; 182 batch->error = virthub_base_request(&instance->base, target, 180 batch->error = virthub_base_request(&instance->base, batch->target, 183 181 batch->dir, (void*) batch->setup.buffer, 184 182 batch->buffer, batch->buffer_size, &batch->transfered_size); -
uspace/drv/bus/usb/ehci/hc.c
rc3d926f3 ra5b3de6 215 215 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 216 216 usb_log_debug("HC(%p) enqueue EP(%d:%d:%s:%s)\n", instance, 217 ep-> target.address, ep->target.endpoint,217 ep->device->address, ep->endpoint, 218 218 usb_str_transfer_type_short(ep->transfer_type), 219 219 usb_str_direction(ep->direction)); … … 239 239 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 240 240 usb_log_debug("HC(%p) dequeue EP(%d:%d:%s:%s)\n", instance, 241 ep-> target.address, ep->target.endpoint,241 ep->device->address, ep->endpoint, 242 242 usb_str_transfer_type_short(ep->transfer_type), 243 243 usb_str_direction(ep->direction)); … … 291 291 292 292 /* Check for root hub communication */ 293 if (batch-> ep->target.address == ehci_rh_get_address(&instance->rh)) {293 if (batch->target.address == ehci_rh_get_address(&instance->rh)) { 294 294 usb_log_debug("HC(%p): Scheduling BATCH(%p) for RH(%p)", 295 295 instance, batch, &instance->rh); -
uspace/drv/bus/usb/ehci/hw_struct/queue_head.c
rc3d926f3 ra5b3de6 66 66 assert(ep->speed < ARRAY_SIZE(speed)); 67 67 EHCI_MEM32_WR(instance->ep_char, 68 QH_EP_CHAR_ADDR_SET(ep-> target.address) |69 QH_EP_CHAR_EP_SET(ep-> target.endpoint) |68 QH_EP_CHAR_ADDR_SET(ep->device->address) | 69 QH_EP_CHAR_EP_SET(ep->endpoint) | 70 70 speed[ep->speed] | 71 71 QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size) -
uspace/drv/bus/usb/ohci/hc.c
rc3d926f3 ra5b3de6 287 287 288 288 /* Check for root hub communication */ 289 if (batch-> ep->target.address == ohci_rh_get_address(&instance->rh)) {289 if (batch->target.address == ohci_rh_get_address(&instance->rh)) { 290 290 usb_log_debug("OHCI root hub request.\n"); 291 291 return ohci_rh_schedule(&instance->rh, batch); -
uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c
rc3d926f3 ra5b3de6 40 40 #include <usb/usb.h> 41 41 #include <usb/host/utils/malloc32.h> 42 #include <usb/host/endpoint.h> 43 #include <usb/host/bus.h> 42 44 43 45 #include "mem_access.h" … … 79 81 /* Status: address, endpoint nr, direction mask and max packet size. */ 80 82 OHCI_MEM32_WR(instance->status, 81 ((ep-> target.address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)82 | ((ep-> target.endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)83 ((ep->device->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT) 84 | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT) 83 85 | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT) 84 86 | ((ep->max_packet_size & ED_STATUS_MPS_MASK) -
uspace/drv/bus/usb/ohci/ohci_rh.c
rc3d926f3 ra5b3de6 178 178 assert(instance); 179 179 assert(batch); 180 const usb_target_t target = batch->ep->target; 181 batch->error = virthub_base_request(&instance->base, target, 180 batch->error = virthub_base_request(&instance->base, batch->target, 182 181 batch->dir, &batch->setup.packet, 183 182 batch->buffer, batch->buffer_size, &batch->transfered_size); … … 207 206 instance->unfinished_interrupt_transfer = NULL; 208 207 if (batch) { 209 const usb_target_t target = batch->ep->target; 210 batch->error = virthub_base_request(&instance->base, target, 208 batch->error = virthub_base_request(&instance->base, batch->target, 211 209 batch->dir, &batch->setup.packet, 212 210 batch->buffer, batch->buffer_size, &batch->transfered_size); -
uspace/drv/bus/usb/uhci/hc.c
rc3d926f3 ra5b3de6 461 461 assert(batch); 462 462 463 if (batch-> ep->target.address == uhci_rh_get_address(&instance->rh))463 if (batch->target.address == uhci_rh_get_address(&instance->rh)) 464 464 return uhci_rh_schedule(&instance->rh, batch); 465 465 -
uspace/drv/bus/usb/uhci/uhci_batch.c
rc3d926f3 ra5b3de6 222 222 uhci_batch->base.ep->speed == USB_SPEED_LOW; 223 223 const size_t mps = uhci_batch->base.ep->max_packet_size; 224 const usb_target_t target = uhci_batch->base.ep->target;225 224 226 225 int toggle = endpoint_toggle_get(uhci_batch->base.ep); … … 240 239 td_init( 241 240 &uhci_batch->tds[td], DEFAULT_ERROR_COUNT, packet_size, 242 toggle, false, low_speed, target, pid, buffer, next_td);241 toggle, false, low_speed, uhci_batch->base.target, pid, buffer, next_td); 243 242 244 243 ++td; … … 285 284 uhci_batch->base.ep->speed == USB_SPEED_LOW; 286 285 const size_t mps = uhci_batch->base.ep->max_packet_size; 287 const usb_target_t target = uhci_batch->base. ep->target;286 const usb_target_t target = uhci_batch->base.target; 288 287 289 288 /* setup stage */ -
uspace/drv/bus/usb/uhci/uhci_rh.c
rc3d926f3 ra5b3de6 104 104 assert(batch); 105 105 106 const usb_target_t target = batch->ep->target;107 106 do { 108 batch->error = virthub_base_request(&instance->base, target,107 batch->error = virthub_base_request(&instance->base, batch->target, 109 108 batch->dir, (void*) batch->setup.buffer, 110 109 batch->buffer, batch->buffer_size, &batch->transfered_size); -
uspace/drv/bus/usb/vhc/transfer.c
rc3d926f3 ra5b3de6 38 38 static bool is_set_address_transfer(vhc_transfer_t *transfer) 39 39 { 40 if (transfer->batch-> ep->target.endpoint != 0) {40 if (transfer->batch->target.endpoint != 0) { 41 41 return false; 42 42 } … … 81 81 if (dir == USB_DIRECTION_IN) { 82 82 rc = usbvirt_data_in(dev, batch->ep->transfer_type, 83 batch->ep-> target.endpoint,83 batch->ep->endpoint, 84 84 batch->buffer, batch->buffer_size, 85 85 actual_data_size); … … 87 87 assert(dir == USB_DIRECTION_OUT); 88 88 rc = usbvirt_data_out(dev, batch->ep->transfer_type, 89 batch->ep-> target.endpoint,89 batch->ep->endpoint, 90 90 batch->buffer, batch->buffer_size); 91 91 } … … 116 116 } else { 117 117 if (dir == USB_DIRECTION_IN) { 118 rc = usbvirt_ipc_send_data_in(sess, batch->ep-> target.endpoint,118 rc = usbvirt_ipc_send_data_in(sess, batch->ep->endpoint, 119 119 batch->ep->transfer_type, 120 120 batch->buffer, batch->buffer_size, … … 122 122 } else { 123 123 assert(dir == USB_DIRECTION_OUT); 124 rc = usbvirt_ipc_send_data_out(sess, batch->ep-> target.endpoint,124 rc = usbvirt_ipc_send_data_out(sess, batch->ep->endpoint, 125 125 batch->ep->transfer_type, 126 126 batch->buffer, batch->buffer_size); … … 184 184 list_foreach(vhc->devices, link, vhc_virtdev_t, dev) { 185 185 fibril_mutex_lock(&dev->guard); 186 if (dev->address == transfer->batch-> ep->target.address) {186 if (dev->address == transfer->batch->target.address) { 187 187 if (!targets) { 188 188 list_append(&transfer->link, &dev->transfer_queue); -
uspace/drv/bus/usb/xhci/bus.c
rc3d926f3 ra5b3de6 63 63 { 64 64 /* Extract information from endpoint_desc */ 65 ep->base.target = (usb_target_t) {{ 66 .address = ep->base.device->address, 67 .endpoint = desc->endpoint_no, 68 }}; 65 ep->base.endpoint = desc->endpoint_no; 69 66 ep->base.direction = desc->direction; 70 67 ep->base.transfer_type = desc->transfer_type; … … 109 106 110 107 /* Register EP0, passing Temporary reference */ 111 ep0->base.target.address = dev->base.address;112 108 dev->endpoints[0] = ep0; 113 109 … … 254 250 return err; 255 251 256 usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep-> target.address, ep->target.endpoint);252 usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->device->address, ep->endpoint); 257 253 return xhci_device_add_endpoint(xhci_dev, xhci_ep); 258 254 } … … 263 259 assert(bus); 264 260 265 usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", ep-> target.address, ep->target.endpoint);261 usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", ep->device->address, ep->endpoint); 266 262 267 263 xhci_device_t *xhci_dev = xhci_device_get(ep->device); -
uspace/drv/bus/usb/xhci/endpoint.c
rc3d926f3 ra5b3de6 94 94 /* Set up primary stream context array if needed. */ 95 95 const size_t size = primary_stream_ctx_array_size(xhci_ep); 96 usb_log_debug2("Allocating primary stream context array of size %lu for endpoint %d:%d.",97 size, xhci_ep->base.target.address, xhci_ep->base.target.endpoint);96 usb_log_debug2("Allocating primary stream context array of size %lu for endpoint " XHCI_EP_FMT, 97 size, XHCI_EP_ARGS(*xhci_ep)); 98 98 99 99 xhci_ep->primary_stream_ctx_array = malloc32(size * sizeof(xhci_stream_ctx_t)); … … 104 104 memset(xhci_ep->primary_stream_ctx_array, 0, size * sizeof(xhci_stream_ctx_t)); 105 105 } else { 106 usb_log_debug2("Allocating main transfer ring for endpoint %d:%d.", 107 xhci_ep->base.target.address, xhci_ep->base.target.endpoint); 106 usb_log_debug2("Allocating main transfer ring for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep)); 108 107 109 108 xhci_ep->primary_stream_ctx_array = NULL; … … 121 120 { 122 121 if (endpoint_uses_streams(xhci_ep)) { 123 usb_log_debug2("Freeing primary stream context array for endpoint %d:%d.", 124 xhci_ep->base.target.address, xhci_ep->base.target.endpoint); 122 usb_log_debug2("Freeing primary stream context array for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep)); 125 123 126 124 // maybe check if LSA, then skip? … … 135 133 free32(xhci_ep->primary_stream_ctx_array); 136 134 } else { 137 usb_log_debug2("Freeing main transfer ring for endpoint %d:%d.", 138 xhci_ep->base.target.address, xhci_ep->base.target.endpoint); 135 usb_log_debug2("Freeing main transfer ring for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep)); 139 136 140 137 int err; … … 151 148 uint8_t xhci_endpoint_dci(xhci_endpoint_t *ep) 152 149 { 153 return (2 * ep->base. target.endpoint) +150 return (2 * ep->base.endpoint) + 154 151 (ep->base.transfer_type == USB_TRANSFER_CONTROL 155 152 || ep->base.direction == USB_DIRECTION_IN); … … 280 277 } 281 278 282 const usb_endpoint_t ep_num = ep->base. target.endpoint;279 const usb_endpoint_t ep_num = ep->base.endpoint; 283 280 284 281 assert(&dev->base == ep->base.device); 285 assert(dev->base.address == ep->base.target.address);286 282 287 283 // TODO Do not fail hard on runtime conditions … … 307 303 { 308 304 assert(&dev->base == ep->base.device); 309 assert(dev->base.address == ep->base.target.address); 310 assert(dev->endpoints[ep->base.target.endpoint]); 305 assert(dev->endpoints[ep->base.endpoint]); 311 306 312 307 int err = ENOMEM; 313 const usb_endpoint_t ep_num = ep->base. target.endpoint;314 315 dev->endpoints[ep->base. target.endpoint] = NULL;308 const usb_endpoint_t ep_num = ep->base.endpoint; 309 310 dev->endpoints[ep->base.endpoint] = NULL; 316 311 --dev->active_endpoint_count; 317 312 -
uspace/drv/bus/usb/xhci/endpoint.h
rc3d926f3 ra5b3de6 86 86 } xhci_endpoint_t; 87 87 88 #define XHCI_EP_FMT "(%d:%d %s)" 89 #define XHCI_EP_ARGS(ep) \ 90 ((ep).base.device->address), \ 91 ((ep).base.endpoint), \ 92 (usb_str_transfer_type((ep).base.transfer_type)) 93 88 94 typedef struct xhci_device { 89 95 device_t base; /**< Inheritance. Keep this first. */ -
uspace/drv/bus/usb/xhci/hc.c
rc3d926f3 ra5b3de6 453 453 assert(batch->ep); 454 454 455 usb_log_debug2("Endpoint(%d:%d) started %s transfer of size %lu.", 456 batch->ep->target.address, batch->ep->target.endpoint, 457 usb_str_transfer_type(batch->ep->transfer_type), 458 batch->buffer_size); 459 460 if (!batch->ep->target.address) { 455 if (!batch->target.address) { 461 456 usb_log_error("Attempted to schedule transfer to address 0."); 462 457 return EINVAL; -
uspace/drv/bus/usb/xhci/rh.c
rc3d926f3 ra5b3de6 216 216 " endpoint %d of detached device '%s': %s", 217 217 usb_str_transfer_type(ep->base.transfer_type), 218 ep->base. target.endpoint, ddf_fun_get_name(dev->base.fun),218 ep->base.endpoint, ddf_fun_get_name(dev->base.fun), 219 219 str_error(err)); 220 220 } -
uspace/drv/bus/usb/xhci/transfers.c
rc3d926f3 ra5b3de6 316 316 317 317 /* Offline devices don't schedule transfers other than on EP0. */ 318 if (!xhci_dev->online && xhci_ep->base. target.endpoint) {318 if (!xhci_dev->online && xhci_ep->base.endpoint) { 319 319 return EAGAIN; 320 320 } -
uspace/lib/usbhost/include/usb/host/endpoint.h
rc3d926f3 ra5b3de6 60 60 /** USB device */ 61 61 device_t *device; 62 /** USB address.*/63 usb_ target_t target;62 /** Enpoint number */ 63 usb_endpoint_t endpoint; 64 64 /** Communication direction. */ 65 65 usb_direction_t direction; … … 108 108 return item ? list_get_instance(item, endpoint_t, link) : NULL; 109 109 } 110 110 111 #endif 111 112 -
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
rc3d926f3 ra5b3de6 55 55 /** Structure stores additional data needed for communication with EP */ 56 56 typedef struct usb_transfer_batch { 57 /** Target for communication */ 58 usb_target_t target; 59 57 60 /** Endpoint used for communication */ 58 61 endpoint_t *ep; 62 59 63 /** Size reported to be sent */ 60 64 size_t expected_size; … … 96 100 */ 97 101 #define USB_TRANSFER_BATCH_ARGS(batch) \ 98 (batch). ep->target.address, (batch).ep->target.endpoint, \102 (batch).target.address, (batch).target.endpoint, \ 99 103 usb_str_speed((batch).ep->speed), \ 100 104 usb_str_transfer_type_short((batch).ep->transfer_type), \ -
uspace/lib/usbhost/src/hcd.c
rc3d926f3 ra5b3de6 109 109 usb_log_error("Endpoint(%d:%d) %s needs %zu bw " 110 110 "but only %zu is reserved.\n", 111 ep->target.address, ep->target.endpoint, name, bw, ep->bandwidth);111 device->address, ep->endpoint, name, bw, ep->bandwidth); 112 112 return ENOSPC; 113 113 } … … 119 119 } 120 120 121 batch->target = target; 121 122 batch->buffer = data; 122 123 batch->buffer_size = size; -
uspace/lib/usbhost/src/usb2_bus.c
rc3d926f3 ra5b3de6 273 273 usb2_bus_t *bus = bus_to_usb2_bus(bus_base); 274 274 275 if (!usb_address_is_valid(target.address)) 276 return NULL; 275 assert(device->address == target.address); 277 276 278 277 list_foreach(*get_list(bus, target.address), link, endpoint_t, ep) { … … 280 279 || (ep->direction == USB_DIRECTION_BOTH) 281 280 || (direction == USB_DIRECTION_BOTH)) 282 && (target. packed == ep->target.packed))281 && (target.endpoint == ep->endpoint)) 283 282 return ep; 284 283 } … … 296 295 } 297 296 297 static usb_target_t usb2_ep_to_target(endpoint_t *ep) 298 { 299 assert(ep); 300 assert(ep->device); 301 302 return (usb_target_t) {{ 303 .address = ep->device->address, 304 .endpoint = ep->endpoint, 305 }}; 306 } 307 298 308 /** Register an endpoint to the bus. Reserves bandwidth. 299 309 * @param bus usb_bus structure, non-null. … … 308 318 309 319 /* Extract USB2-related information from endpoint_desc */ 310 ep->target = (usb_target_t) {{ 311 .address = ep->device->address, 312 .endpoint = desc->endpoint_no, 313 }}; 320 ep->endpoint = desc->endpoint_no; 314 321 ep->direction = desc->direction; 315 322 ep->transfer_type = desc->transfer_type; … … 320 327 321 328 /* Check for existence */ 322 if (usb2_bus_find_ep(bus_base, ep->device, ep->target, ep->direction))329 if (usb2_bus_find_ep(bus_base, ep->device, usb2_ep_to_target(ep), ep->direction)) 323 330 return EEXIST; 324 331 … … 356 363 357 364 list_foreach(*get_list(bus, target.address), link, endpoint_t, ep) { 358 if ((ep->target.address == target.address) 359 && (all || ep->target.endpoint == target.endpoint)) { 365 assert(ep->device->address == target.address); 366 367 if (all || ep->endpoint == target.endpoint) { 360 368 endpoint_toggle_set(ep, 0); 361 369 ret = EOK; … … 386 394 endpoint_t *ep = list_get_instance(link, endpoint_t, link); 387 395 link = list_next(link, list); 388 assert(ep->target.address == address); 396 397 assert(ep->device->address == address); 389 398 list_remove(&ep->link); 390 399 391 400 usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n", 392 ep->target.address, ep->target.endpoint, usb_str_direction(ep->direction));401 address, ep->endpoint, usb_str_direction(ep->direction)); 393 402 394 403 /* Drop bus reference */ -
uspace/lib/usbhost/src/usb_transfer_batch.c
rc3d926f3 ra5b3de6 81 81 82 82 if (batch->error == EOK && batch->toggle_reset_mode != RESET_NONE) { 83 usb_log_debug2(" Reseting %s due to transaction of %d:%d.\n",84 batch ->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle",85 batch-> ep->target.address, batch->ep->target.endpoint);86 bus_reset_toggle(batch->ep->bus, 87 batch-> ep->target, batch->toggle_reset_mode == RESET_ALL);83 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " resets %s", 84 batch, USB_TRANSFER_BATCH_ARGS(*batch), 85 batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle"); 86 bus_reset_toggle(batch->ep->bus, 87 batch->target, batch->toggle_reset_mode == RESET_ALL); 88 88 } 89 89
Note:
See TracChangeset
for help on using the changeset viewer.