Changes in / [fec47d4:1c6f4ff] in mainline


Ignore:
Location:
uspace/drv
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/batch.c

    rfec47d4 r1c6f4ff  
    8080 * transaction and callback.
    8181 */
    82 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    83     usb_transfer_type_t transfer_type, size_t max_packet_size,
    84     usb_speed_t speed, char *buffer, size_t buffer_size,
    85     char* setup_buffer, size_t setup_size,
     82usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
     83    char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size,
    8684    usbhc_iface_transfer_in_callback_t func_in,
    87     usbhc_iface_transfer_out_callback_t func_out, void *arg, endpoint_t *ep
    88     )
    89 {
     85    usbhc_iface_transfer_out_callback_t func_out, void *arg)
     86{
     87        assert(ep);
    9088        assert(func_in == NULL || func_out == NULL);
    9189        assert(func_in != NULL || func_out != NULL);
     
    103101        CHECK_NULL_DISPOSE_RETURN(instance,
    104102            "Failed to allocate batch instance.\n");
     103        usb_target_t target =
     104            { .address = ep->address, .endpoint = ep->endpoint };
    105105        usb_transfer_batch_init(instance, target,
    106             transfer_type, speed, max_packet_size,
     106            ep->transfer_type, ep->speed, ep->max_packet_size,
    107107            buffer, NULL, buffer_size, NULL, setup_size, func_in,
    108108            func_out, arg, fun, ep, NULL);
     
    115115        instance->private_data = data;
    116116
    117         data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
    118         if (transfer_type == USB_TRANSFER_CONTROL) {
     117        data->transfers =
     118            (buffer_size + ep->max_packet_size - 1) / ep->max_packet_size;
     119        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    119120                data->transfers += 2;
    120121        }
     
    178179                            instance, i, data->tds[i].status);
    179180                        td_print_status(&data->tds[i]);
    180                         if (instance->ep != NULL)
    181                                 endpoint_toggle_set(instance->ep,
    182                                     td_toggle(&data->tds[i]));
     181                        assert(instance->ep != NULL);
     182
     183                        endpoint_toggle_set(instance->ep,
     184                            td_toggle(&data->tds[i]));
    183185                        if (i > 0)
    184186                                goto substract_ret;
  • uspace/drv/uhci-hcd/batch.h

    rfec47d4 r1c6f4ff  
    4444
    4545usb_transfer_batch_t * batch_get(
    46     ddf_fun_t *fun,
    47                 usb_target_t target,
    48     usb_transfer_type_t transfer_type,
    49                 size_t max_packet_size,
    50     usb_speed_t speed,
    51                 char *buffer,
    52                 size_t size,
    53                 char *setup_buffer,
    54                 size_t setup_size,
     46    ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size,
     47    char *setup_buffer, size_t setup_size,
    5548    usbhc_iface_transfer_in_callback_t func_in,
    5649    usbhc_iface_transfer_out_callback_t func_out,
    57                 void *arg,
    58                 endpoint_t *ep
    59                 );
     50    void *arg);
    6051
    6152void batch_dispose(usb_transfer_batch_t *instance);
  • uspace/drv/uhci-hcd/iface.c

    rfec47d4 r1c6f4ff  
    4040#include "iface.h"
    4141#include "hc.h"
     42
     43static inline int setup_batch(
     44    ddf_fun_t *fun, usb_target_t target, usb_direction_t direction,
     45    void *data, size_t size, void * setup_data, size_t setup_size,
     46    usbhc_iface_transfer_in_callback_t in,
     47    usbhc_iface_transfer_out_callback_t out, void *arg, const char* name,
     48    hc_t **hc, usb_transfer_batch_t **batch)
     49{
     50        assert(hc);
     51        assert(batch);
     52        assert(fun);
     53        *hc = fun_to_hc(fun);
     54        assert(*hc);
     55
     56        size_t res_bw;
     57        endpoint_t *ep = usb_endpoint_manager_get_ep(&(*hc)->ep_manager,
     58            target.address, target.endpoint, direction, &res_bw);
     59        if (ep == NULL) {
     60                usb_log_error("Endpoint(%d:%d) not registered for %s.\n",
     61                    target.address, target.endpoint, name);
     62                return ENOENT;
     63        }
     64
     65        const size_t bw = bandwidth_count_usb11(
     66            ep->speed, ep->transfer_type, size, ep->max_packet_size);
     67        if (res_bw < bw) {
     68                usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
     69                    "but only %zu is reserved.\n",
     70                    name, target.address, target.endpoint, bw, res_bw);
     71                return ENOSPC;
     72        }
     73        usb_log_debug("%s %d:%d %zu(%zu).\n",
     74            name, target.address, target.endpoint, size, ep->max_packet_size);
     75
     76        assert(ep->speed ==
     77            usb_device_keeper_get_speed(&(*hc)->manager, target.address));
     78//      assert(ep->max_packet_size == max_packet_size);
     79//      assert(ep->transfer_type == USB_TRANSFER_CONTROL);
     80
     81        *batch =
     82            batch_get(fun, ep, data, size, setup_data, setup_size,
     83                in, out, arg);
     84        if (!batch)
     85                return ENOMEM;
     86        return EOK;
     87}
     88
    4289
    4390/** Reserve default address interface function
     
    215262    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    216263{
    217         assert(fun);
    218         hc_t *hc = fun_to_hc(fun);
    219         assert(hc);
    220 
    221         usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    222             target.address, target.endpoint, size, max_packet_size);
    223 
    224         size_t res_bw;
    225         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    226             target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw);
    227         if (ep == NULL) {
    228                 usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n",
    229                         target.address, target.endpoint);
    230                 return ENOENT;
    231         }
    232         const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
    233             size, ep->max_packet_size);
    234         if (res_bw < bw)
    235         {
    236                 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
    237                     "but only %zu is reserved.\n",
    238                     target.address, target.endpoint, bw, res_bw);
    239                 return ENOENT;
    240         }
    241         assert(ep->speed ==
    242             usb_device_keeper_get_speed(&hc->manager, target.address));
    243         assert(ep->max_packet_size == max_packet_size);
    244         assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
    245 
    246         usb_transfer_batch_t *batch =
    247             batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
    248                 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
    249         if (!batch)
    250                 return ENOMEM;
     264        usb_transfer_batch_t *batch = NULL;
     265        hc_t *hc = NULL;
     266        int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size,
     267            NULL, 0, NULL, callback, arg, "Interrupt OUT", &hc, &batch);
     268        if (ret != EOK)
     269                return ret;
    251270        batch_interrupt_out(batch);
    252         const int ret = hc_schedule(hc, batch);
     271        ret = hc_schedule(hc, batch);
    253272        if (ret != EOK) {
    254273                batch_dispose(batch);
     
    272291    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    273292{
    274         assert(fun);
    275         hc_t *hc = fun_to_hc(fun);
    276         assert(hc);
    277 
    278         usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    279             target.address, target.endpoint, size, max_packet_size);
    280 
    281         size_t res_bw;
    282         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    283             target.address, target.endpoint, USB_DIRECTION_IN, &res_bw);
    284         if (ep == NULL) {
    285                 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n",
    286                     target.address, target.endpoint);
    287                 return ENOENT;
    288         }
    289         const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
    290             size, ep->max_packet_size);
    291         if (res_bw < bw)
    292         {
    293                 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
    294                     "but only %zu bw is reserved.\n",
    295                     target.address, target.endpoint, bw, res_bw);
    296                 return ENOENT;
    297         }
    298 
    299         assert(ep->speed ==
    300             usb_device_keeper_get_speed(&hc->manager, target.address));
    301         assert(ep->max_packet_size == max_packet_size);
    302         assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
    303 
    304         usb_transfer_batch_t *batch =
    305             batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
    306                 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
    307         if (!batch)
    308                 return ENOMEM;
     293        usb_transfer_batch_t *batch = NULL;
     294        hc_t *hc = NULL;
     295        int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size,
     296            NULL, 0, callback, NULL, arg, "Interrupt IN", &hc, &batch);
     297        if (ret != EOK)
     298                return ret;
    309299        batch_interrupt_in(batch);
    310         const int ret = hc_schedule(hc, batch);
     300        ret = hc_schedule(hc, batch);
    311301        if (ret != EOK) {
    312302                batch_dispose(batch);
     
    330320    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    331321{
    332         assert(fun);
    333         hc_t *hc = fun_to_hc(fun);
    334         assert(hc);
    335 
    336         usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    337             target.address, target.endpoint, size, max_packet_size);
    338 
    339         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    340             target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
    341         if (ep == NULL) {
    342                 usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n",
    343                         target.address, target.endpoint);
    344                 return ENOENT;
    345         }
    346         assert(ep->speed ==
    347             usb_device_keeper_get_speed(&hc->manager, target.address));
    348         assert(ep->max_packet_size == max_packet_size);
    349         assert(ep->transfer_type == USB_TRANSFER_BULK);
    350 
    351         usb_transfer_batch_t *batch =
    352             batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
    353                 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
    354         if (!batch)
    355                 return ENOMEM;
     322        usb_transfer_batch_t *batch = NULL;
     323        hc_t *hc = NULL;
     324        int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size,
     325            NULL, 0, NULL, callback, arg, "Bulk OUT", &hc, &batch);
     326        if (ret != EOK)
     327                return ret;
    356328        batch_bulk_out(batch);
    357         const int ret = hc_schedule(hc, batch);
     329        ret = hc_schedule(hc, batch);
    358330        if (ret != EOK) {
    359331                batch_dispose(batch);
     
    377349    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    378350{
    379         assert(fun);
    380         hc_t *hc = fun_to_hc(fun);
    381         assert(hc);
    382         usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    383             target.address, target.endpoint, size, max_packet_size);
    384 
    385         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    386             target.address, target.endpoint, USB_DIRECTION_IN, NULL);
    387         if (ep == NULL) {
    388                 usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n",
    389                         target.address, target.endpoint);
    390                 return ENOENT;
    391         }
    392         assert(ep->speed ==
    393             usb_device_keeper_get_speed(&hc->manager, target.address));
    394         assert(ep->max_packet_size == max_packet_size);
    395         assert(ep->transfer_type == USB_TRANSFER_BULK);
    396 
    397         usb_transfer_batch_t *batch =
    398             batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
    399                 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
    400         if (!batch)
    401                 return ENOMEM;
     351        usb_transfer_batch_t *batch = NULL;
     352        hc_t *hc = NULL;
     353        int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size,
     354            NULL, 0, callback, NULL, arg, "Bulk IN", &hc, &batch);
     355        if (ret != EOK)
     356                return ret;
    402357        batch_bulk_in(batch);
    403         const int ret = hc_schedule(hc, batch);
     358        ret = hc_schedule(hc, batch);
    404359        if (ret != EOK) {
    405360                batch_dispose(batch);
     
    426381    usbhc_iface_transfer_out_callback_t callback, void *arg)
    427382{
    428         assert(fun);
    429         hc_t *hc = fun_to_hc(fun);
    430         assert(hc);
    431         usb_speed_t speed =
    432             usb_device_keeper_get_speed(&hc->manager, target.address);
    433         usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    434             speed, target.address, target.endpoint, size, max_packet_size);
    435         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    436             target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
    437         if (ep == NULL) {
    438                 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
    439                         target.address, target.endpoint);
    440         }
    441 
    442         if (setup_size != 8)
    443                 return EINVAL;
    444 
    445         usb_transfer_batch_t *batch =
    446             batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
    447                 data, size, setup_data, setup_size, NULL, callback, arg, ep);
    448         if (!batch)
    449                 return ENOMEM;
     383        usb_transfer_batch_t *batch = NULL;
     384        hc_t *hc = NULL;
     385        int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size,
     386            setup_data, setup_size, NULL, callback, arg, "Control WRITE",
     387            &hc, &batch);
     388        if (ret != EOK)
     389                return ret;
    450390        usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
    451391        batch_control_write(batch);
    452         const int ret = hc_schedule(hc, batch);
     392        ret = hc_schedule(hc, batch);
    453393        if (ret != EOK) {
    454394                batch_dispose(batch);
     
    475415    usbhc_iface_transfer_in_callback_t callback, void *arg)
    476416{
    477         assert(fun);
    478         hc_t *hc = fun_to_hc(fun);
    479         assert(hc);
    480         usb_speed_t speed =
    481             usb_device_keeper_get_speed(&hc->manager, target.address);
    482 
    483         usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    484             speed, target.address, target.endpoint, size, max_packet_size);
    485         endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
    486             target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
    487         if (ep == NULL) {
    488                 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
    489                         target.address, target.endpoint);
    490         }
    491         usb_transfer_batch_t *batch =
    492             batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
    493                 data, size, setup_data, setup_size, callback, NULL, arg, ep);
    494         if (!batch)
    495                 return ENOMEM;
     417        usb_transfer_batch_t *batch = NULL;
     418        hc_t *hc = NULL;
     419        int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size,
     420            setup_data, setup_size, callback, NULL, arg, "Control READ",
     421            &hc, &batch);
     422        if (ret != EOK)
     423                return ret;
    496424        batch_control_read(batch);
    497         const int ret = hc_schedule(hc, batch);
     425        ret = hc_schedule(hc, batch);
    498426        if (ret != EOK) {
    499427                batch_dispose(batch);
  • uspace/drv/uhci-rhd/root_hub.h

    rfec47d4 r1c6f4ff  
    4040
    4141#define UHCI_ROOT_HUB_PORT_COUNT 2
    42 #define ROOT_HUB_WAIT_USEC 5000000 /* 5 seconds */
     42#define ROOT_HUB_WAIT_USEC 250000 /* 250 miliseconds */
    4343
    4444typedef struct root_hub {
Note: See TracChangeset for help on using the changeset viewer.