Changeset 00aece0 in mainline for uspace/drv/bus/usb/vhc/connhost.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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/drv/bus/usb/vhc/connhost.c
rbd5f3b7 r00aece0 57 57 * @return Error code. 58 58 */ 59 static int request_address(ddf_fun_t *fun, usb_speed_t speed, 60 usb_address_t *address) 61 { 62 VHC_DATA(vhc, fun); 63 64 usb_address_t addr = device_keeper_get_free_address(&vhc->dev_keeper, 65 USB_SPEED_HIGH); 66 if (addr < 0) { 67 return addr; 68 } 69 70 if (address != NULL) { 71 *address = addr; 72 } 73 74 return EOK; 59 static int request_address(ddf_fun_t *fun, usb_address_t *address, bool strict, 60 usb_speed_t speed) 61 { 62 VHC_DATA(vhc, fun); 63 64 assert(address); 65 return usb_device_manager_request_address( 66 &vhc->dev_manager, address, strict, speed); 75 67 } 76 68 … … 88 80 usb_log_debug("Binding handle %" PRIun " to address %d.\n", 89 81 handle, address); 90 usb_device_ keeper_bind(&vhc->dev_keeper, address, handle);82 usb_device_manager_bind_address(&vhc->dev_manager, address, handle); 91 83 92 84 return EOK; … … 104 96 { 105 97 VHC_DATA(vhc, fun); 106 bool found = 107 usb_device_keeper_find_by_address(&vhc->dev_keeper, address, handle); 108 return found ? EOK : ENOENT; 98 return usb_device_manager_get_info_by_address( 99 &vhc->dev_manager, address, handle, NULL); 109 100 } 110 101 … … 119 110 VHC_DATA(vhc, fun); 120 111 usb_log_debug("Releasing address %d...\n", address); 121 usb_device_ keeper_release(&vhc->dev_keeper, address);112 usb_device_manager_release_address(&vhc->dev_manager, address); 122 113 123 114 return ENOTSUP; … … 137 128 */ 138 129 static int register_endpoint(ddf_fun_t *fun, 139 usb_address_t address, usb_ speed_t speed, usb_endpoint_t endpoint,130 usb_address_t address, usb_endpoint_t endpoint, 140 131 usb_transfer_type_t transfer_type, usb_direction_t direction, 141 132 size_t max_packet_size, unsigned int interval) 142 133 { 143 /* TODO: Use usb_endpoint_manager_add_ep */ 144 VHC_DATA(vhc, fun); 145 146 endpoint_t *ep = endpoint_get( 147 address, endpoint, direction, transfer_type, USB_SPEED_FULL, 1); 148 if (ep == NULL) { 149 return ENOMEM; 150 } 151 152 int rc = usb_endpoint_manager_register_ep(&vhc->ep_manager, ep, 1); 153 if (rc != EOK) { 154 endpoint_destroy(ep); 155 return rc; 156 } 157 158 return EOK; 134 VHC_DATA(vhc, fun); 135 136 return usb_endpoint_manager_add_ep(&vhc->ep_manager, 137 address, endpoint, direction, transfer_type, USB_SPEED_FULL, 1, 0, 138 NULL, NULL); 139 159 140 } 160 141 … … 172 153 VHC_DATA(vhc, fun); 173 154 174 endpoint_t *ep = usb_endpoint_manager_get_ep(&vhc->ep_manager, 175 address, endpoint, direction, NULL); 176 if (ep == NULL) { 177 return ENOENT; 178 } 179 180 int rc = usb_endpoint_manager_unregister_ep(&vhc->ep_manager, 181 address, endpoint, direction); 155 int rc = usb_endpoint_manager_remove_ep(&vhc->ep_manager, 156 address, endpoint, direction, NULL, NULL); 182 157 183 158 return rc; 184 159 } 185 160 #if 0 186 161 /** Schedule interrupt out transfer. 187 162 * … … 413 388 return EOK; 414 389 } 415 416 static int tell_address(ddf_fun_t *fun, devman_handle_t handle, 417 usb_address_t *address) 390 #endif 391 static int usb_read(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer, 392 uint8_t *data_buffer, size_t data_buffer_size, 393 usbhc_iface_transfer_in_callback_t callback, void *arg) 394 { 395 VHC_DATA(vhc, fun); 396 397 endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager, 398 target.address, target.endpoint, USB_DIRECTION_IN); 399 if (ep == NULL) { 400 return ENOENT; 401 } 402 const usb_transfer_type_t transfer_type = ep->transfer_type; 403 404 405 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 406 target.endpoint, USB_DIRECTION_IN, transfer_type, 407 fun, arg); 408 if (transfer == NULL) { 409 return ENOMEM; 410 } 411 if (transfer_type == USB_TRANSFER_CONTROL) { 412 transfer->setup_buffer = malloc(sizeof(uint64_t)); 413 assert(transfer->setup_buffer); 414 memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t)); 415 transfer->setup_buffer_size = sizeof(uint64_t); 416 } 417 transfer->data_buffer = data_buffer; 418 transfer->data_buffer_size = data_buffer_size; 419 transfer->callback_in = callback; 420 421 int rc = vhc_virtdev_add_transfer(vhc, transfer); 422 if (rc != EOK) { 423 if (transfer->setup_buffer != NULL) { 424 free(transfer->setup_buffer); 425 } 426 free(transfer); 427 return rc; 428 } 429 430 return EOK; 431 } 432 433 static int usb_write(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer, 434 const uint8_t *data_buffer, size_t data_buffer_size, 435 usbhc_iface_transfer_out_callback_t callback, void *arg) 436 { 437 VHC_DATA(vhc, fun); 438 439 endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager, 440 target.address, target.endpoint, USB_DIRECTION_OUT); 441 if (ep == NULL) { 442 return ENOENT; 443 } 444 const usb_transfer_type_t transfer_type = ep->transfer_type; 445 446 447 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 448 target.endpoint, USB_DIRECTION_OUT, transfer_type, 449 fun, arg); 450 if (transfer == NULL) { 451 return ENOMEM; 452 } 453 if (transfer_type == USB_TRANSFER_CONTROL) { 454 transfer->setup_buffer = malloc(sizeof(uint64_t)); 455 assert(transfer->setup_buffer); 456 memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t)); 457 transfer->setup_buffer_size = sizeof(uint64_t); 458 } 459 transfer->data_buffer = (void*)data_buffer; 460 transfer->data_buffer_size = data_buffer_size; 461 transfer->callback_out = callback; 462 463 int rc = vhc_virtdev_add_transfer(vhc, transfer); 464 if (rc != EOK) { 465 free(transfer->setup_buffer); 466 free(transfer); 467 return rc; 468 } 469 470 return EOK; 471 } 472 473 static int tell_address(ddf_fun_t *fun, usb_address_t *address) 418 474 { 419 475 UNSUPPORTED("tell_address"); … … 432 488 } 433 489 434 static int tell_address_rh(ddf_fun_t *root_hub_fun, devman_handle_t handle, 435 usb_address_t *address) 490 static int tell_address_rh(ddf_fun_t *root_hub_fun, usb_address_t *address) 436 491 { 437 492 VHC_DATA(vhc, root_hub_fun); 438 493 439 if (handle == 0) { 440 handle = root_hub_fun->handle; 441 } 494 devman_handle_t handle = root_hub_fun->handle; 442 495 443 496 usb_log_debug("tell_address_rh(handle=%" PRIun ")\n", handle); 444 usb_address_t addr = usb_device_keeper_find(&vhc->dev_keeper, handle); 497 const usb_address_t addr = 498 usb_device_manager_find_address(&vhc->dev_manager, handle); 445 499 if (addr < 0) { 446 500 return addr; … … 454 508 .request_address = request_address, 455 509 .bind_address = bind_address, 456 . find_by_address= find_by_address,510 .get_handle = find_by_address, 457 511 .release_address = release_address, 458 512 … … 460 514 .unregister_endpoint = unregister_endpoint, 461 515 462 .interrupt_out = interrupt_out, 463 .interrupt_in = interrupt_in, 464 465 .bulk_in = bulk_in, 466 .bulk_out = bulk_out, 467 468 .control_write = control_write, 469 .control_read = control_read 516 .write = usb_write, 517 .read = usb_read, 470 518 }; 471 519 472 520 usb_iface_t vhc_usb_iface = { 473 521 .get_hc_handle = usb_iface_get_hc_handle_hc_impl, 474 .get_ address = tell_address522 .get_my_address = tell_address 475 523 }; 476 524 477 525 usb_iface_t rh_usb_iface = { 478 526 .get_hc_handle = usb_iface_get_hc_handle_rh_impl, 479 .get_ address = tell_address_rh527 .get_my_address = tell_address_rh 480 528 }; 481 529
Note:
See TracChangeset
for help on using the changeset viewer.