Changeset 432a269 in mainline for uspace/drv/bus/usb/vhc/connhost.c
- Timestamp:
- 2011-09-16T21:13:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a11f17
- Parents:
- c0e53ff (diff), fd07e526 (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
rc0e53ff r432a269 62 62 VHC_DATA(vhc, fun); 63 63 64 usb_address_t addr = device_keeper_get_free_address(&vhc->dev_keeper,65 USB_SPEED_HIGH);64 usb_address_t addr = usb_device_manager_get_free_address( 65 &vhc->dev_manager, USB_SPEED_HIGH); 66 66 if (addr < 0) { 67 67 return addr; … … 88 88 usb_log_debug("Binding handle %" PRIun " to address %d.\n", 89 89 handle, address); 90 usb_device_ keeper_bind(&vhc->dev_keeper, address, handle);90 usb_device_manager_bind(&vhc->dev_manager, address, handle); 91 91 92 92 return EOK; … … 105 105 VHC_DATA(vhc, fun); 106 106 bool found = 107 usb_device_ keeper_find_by_address(&vhc->dev_keeper, address, handle);107 usb_device_manager_find_by_address(&vhc->dev_manager, address, handle); 108 108 return found ? EOK : ENOENT; 109 109 } … … 119 119 VHC_DATA(vhc, fun); 120 120 usb_log_debug("Releasing address %d...\n", address); 121 usb_device_ keeper_release(&vhc->dev_keeper, address);121 usb_device_manager_release(&vhc->dev_manager, address); 122 122 123 123 return ENOTSUP; … … 172 172 VHC_DATA(vhc, fun); 173 173 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 174 int rc = usb_endpoint_manager_unregister_ep(&vhc->ep_manager, 181 175 address, endpoint, direction); … … 183 177 return rc; 184 178 } 185 179 #if 0 186 180 /** Schedule interrupt out transfer. 187 181 * … … 413 407 return EOK; 414 408 } 409 #endif 410 static int usb_read(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer, 411 uint8_t *data_buffer, size_t data_buffer_size, 412 usbhc_iface_transfer_in_callback_t callback, void *arg) 413 { 414 VHC_DATA(vhc, fun); 415 416 endpoint_t *ep = usb_endpoint_manager_get_ep(&vhc->ep_manager, 417 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 418 if (ep == NULL) { 419 return ENOENT; 420 } 421 const usb_transfer_type_t transfer_type = ep->transfer_type; 422 423 424 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 425 target.endpoint, USB_DIRECTION_IN, transfer_type, 426 fun, arg); 427 if (transfer == NULL) { 428 return ENOMEM; 429 } 430 if (transfer_type == USB_TRANSFER_CONTROL) { 431 transfer->setup_buffer = malloc(sizeof(uint64_t)); 432 assert(transfer->setup_buffer); 433 memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t)); 434 transfer->setup_buffer_size = sizeof(uint64_t); 435 } 436 transfer->data_buffer = data_buffer; 437 transfer->data_buffer_size = data_buffer_size; 438 transfer->callback_in = callback; 439 440 int rc = vhc_virtdev_add_transfer(vhc, transfer); 441 if (rc != EOK) { 442 free(transfer->setup_buffer); 443 free(transfer); 444 return rc; 445 } 446 447 return EOK; 448 } 449 450 static int usb_write(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer, 451 const uint8_t *data_buffer, size_t data_buffer_size, 452 usbhc_iface_transfer_out_callback_t callback, void *arg) 453 { 454 VHC_DATA(vhc, fun); 455 456 endpoint_t *ep = usb_endpoint_manager_get_ep(&vhc->ep_manager, 457 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 458 if (ep == NULL) { 459 return ENOENT; 460 } 461 const usb_transfer_type_t transfer_type = ep->transfer_type; 462 463 464 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 465 target.endpoint, USB_DIRECTION_OUT, transfer_type, 466 fun, arg); 467 if (transfer == NULL) { 468 return ENOMEM; 469 } 470 if (transfer_type == USB_TRANSFER_CONTROL) { 471 transfer->setup_buffer = malloc(sizeof(uint64_t)); 472 assert(transfer->setup_buffer); 473 memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t)); 474 transfer->setup_buffer_size = sizeof(uint64_t); 475 } 476 transfer->data_buffer = (void*)data_buffer; 477 transfer->data_buffer_size = data_buffer_size; 478 transfer->callback_out = callback; 479 480 int rc = vhc_virtdev_add_transfer(vhc, transfer); 481 if (rc != EOK) { 482 free(transfer->setup_buffer); 483 free(transfer); 484 return rc; 485 } 486 487 return EOK; 488 } 415 489 416 490 static int tell_address(ddf_fun_t *fun, devman_handle_t handle, … … 442 516 443 517 usb_log_debug("tell_address_rh(handle=%" PRIun ")\n", handle); 444 usb_address_t addr = usb_device_ keeper_find(&vhc->dev_keeper, handle);518 usb_address_t addr = usb_device_manager_find(&vhc->dev_manager, handle); 445 519 if (addr < 0) { 446 520 return addr; … … 460 534 .unregister_endpoint = unregister_endpoint, 461 535 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 536 .write = usb_write, 537 .read = usb_read, 470 538 }; 471 539
Note:
See TracChangeset
for help on using the changeset viewer.