Changeset 432a269 in mainline for uspace/drv/bus/usb/vhc/connhost.c


Ignore:
Timestamp:
2011-09-16T21:13:57Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/vhc/connhost.c

    rc0e53ff r432a269  
    6262        VHC_DATA(vhc, fun);
    6363
    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);
    6666        if (addr < 0) {
    6767                return addr;
     
    8888        usb_log_debug("Binding handle %" PRIun " to address %d.\n",
    8989            handle, address);
    90         usb_device_keeper_bind(&vhc->dev_keeper, address, handle);
     90        usb_device_manager_bind(&vhc->dev_manager, address, handle);
    9191
    9292        return EOK;
     
    105105        VHC_DATA(vhc, fun);
    106106        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);
    108108        return found ? EOK : ENOENT;
    109109}
     
    119119        VHC_DATA(vhc, fun);
    120120        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);
    122122
    123123        return ENOTSUP;
     
    172172        VHC_DATA(vhc, fun);
    173173
    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 
    180174        int rc = usb_endpoint_manager_unregister_ep(&vhc->ep_manager,
    181175            address, endpoint, direction);
     
    183177        return rc;
    184178}
    185 
     179#if 0
    186180/** Schedule interrupt out transfer.
    187181 *
     
    413407        return EOK;
    414408}
     409#endif
     410static 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
     450static 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}
    415489
    416490static int tell_address(ddf_fun_t *fun, devman_handle_t handle,
     
    442516
    443517        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);
    445519        if (addr < 0) {
    446520                return addr;
     
    460534        .unregister_endpoint = unregister_endpoint,
    461535
    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,
    470538};
    471539
Note: See TracChangeset for help on using the changeset viewer.