Ignore:
File:
1 edited

Legend:

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

    r30a4301 r48563a3  
    3333 */
    3434#include <errno.h>
     35#include <str_error.h>
    3536
    3637#include <usb/debug.h>
     
    5152
    5253
    53 batch_t * batch_get(device_t *dev, usb_target_t target,
     54batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    5455    usb_transfer_type_t transfer_type, size_t max_packet_size,
    55     dev_speed_t speed, char *buffer, size_t size,
     56    usb_speed_t speed, char *buffer, size_t size,
    5657    char* setup_buffer, size_t setup_size,
    5758    usbhc_iface_transfer_in_callback_t func_in,
     
    128129        instance->buffer_size = size;
    129130        instance->setup_size = setup_size;
    130         instance->dev = dev;
     131        instance->fun = fun;
    131132        instance->arg = arg;
    132133        instance->speed = speed;
     
    139140{
    140141        assert(instance);
    141         usb_log_debug("Checking(%p) %d packet for completion.\n",
     142        usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    142143            instance, instance->packets);
    143144        instance->transfered_size = 0;
     
    151152                        if (i > 0)
    152153                                instance->transfered_size -= instance->setup_size;
     154                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
     155                          instance, i, instance->tds[i].status);
    153156                        return true;
    154157                }
     
    156159                    transfer_descriptor_actual_size(&instance->tds[i]);
    157160        }
    158         /* This is just an ugly trick to support the old API */
    159161        instance->transfered_size -= instance->setup_size;
    160162        return true;
     
    168170        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    169171
     172        const bool low_speed = instance->speed == USB_SPEED_LOW;
    170173        int toggle = 0;
    171174        /* setup stage */
    172175        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    173             instance->setup_size, toggle, false, instance->target,
    174             USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
     176            instance->setup_size, toggle, false, low_speed,
     177            instance->target, USB_PID_SETUP, instance->setup_buffer,
     178            &instance->tds[1]);
    175179
    176180        /* data stage */
     
    182186
    183187                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    184                     instance->max_packet_size, toggle++, false, instance->target,
    185                     USB_PID_OUT, data, &instance->tds[i + 1]);
     188                    instance->max_packet_size, toggle++, false, low_speed,
     189                    instance->target, USB_PID_OUT, data, &instance->tds[i + 1]);
    186190        }
    187191
     
    189193        i = instance->packets - 1;
    190194        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    191             0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
     195            0, 1, false, low_speed, instance->target, USB_PID_IN, NULL, NULL);
    192196
    193197        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     198        usb_log_debug("Control write last TD status: %x.\n",
     199                instance->tds[i].status);
    194200
    195201        instance->next_step = batch_call_out_and_dispose;
     
    201207        assert(instance);
    202208
     209        const bool low_speed = instance->speed == USB_SPEED_LOW;
    203210        int toggle = 0;
    204211        /* setup stage */
    205212        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    206             instance->setup_size, toggle, false, instance->target,
     213            instance->setup_size, toggle, false, low_speed, instance->target,
    207214            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    208215
     
    215222
    216223                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    217                     instance->max_packet_size, toggle, false, instance->target,
    218                     USB_PID_IN, data, &instance->tds[i + 1]);
     224                    instance->max_packet_size, toggle, false, low_speed,
     225                                instance->target, USB_PID_IN, data, &instance->tds[i + 1]);
    219226        }
    220227
     
    222229        i = instance->packets - 1;
    223230        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    224             0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
     231            0, 1, false, low_speed, instance->target, USB_PID_OUT, NULL, NULL);
    225232
    226233        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     234        usb_log_debug("Control read last TD status: %x.\n",
     235                instance->tds[i].status);
    227236
    228237        instance->next_step = batch_call_in_and_dispose;
     
    234243        assert(instance);
    235244
     245        const bool low_speed = instance->speed == USB_SPEED_LOW;
    236246        int toggle = 1;
    237247        size_t i = 0;
     
    244254
    245255                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    246                     instance->max_packet_size, toggle, false, instance->target,
    247                     USB_PID_IN, data, next);
     256                    instance->max_packet_size, toggle, false, low_speed,
     257                    instance->target, USB_PID_IN, data, next);
    248258        }
    249259
     
    260270        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    261271
     272        const bool low_speed = instance->speed == USB_SPEED_LOW;
    262273        int toggle = 1;
    263274        size_t i = 0;
     
    270281
    271282                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    272                     instance->max_packet_size, toggle++, false, instance->target,
    273                     USB_PID_OUT, data, next);
     283                    instance->max_packet_size, toggle++, false, low_speed,
     284                    instance->target, USB_PID_OUT, data, next);
    274285        }
    275286
     
    288299
    289300        int err = instance->error;
    290         usb_log_info("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
    291             err, instance->transfered_size);
    292 
    293         instance->callback_in(instance->dev,
     301        usb_log_info("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n",
     302            instance, instance->transfer_type, str_error(err), err,
     303            instance->transfered_size);
     304
     305        instance->callback_in(instance->fun,
    294306            err, instance->transfered_size,
    295307            instance->arg);
     
    302314
    303315        int err = instance->error;
    304         usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
    305         instance->callback_out(instance->dev,
     316        usb_log_info("Batch(%p) callback OUT(type:%d): %s(%d).\n",
     317            instance, instance->transfer_type, str_error(err), err);
     318        instance->callback_out(instance->fun,
    306319            err, instance->arg);
    307320}
     
    311324        assert(instance);
    312325        batch_call_in(instance);
    313         usb_log_debug("Disposing batch: %p.\n", instance);
     326        usb_log_debug("Batch(%p) disposing.\n", instance);
    314327        free32(instance->tds);
    315328        free32(instance->qh);
     
    323336        assert(instance);
    324337        batch_call_out(instance);
    325         usb_log_debug("Disposing batch: %p.\n", instance);
     338        usb_log_debug("Batch(%p) disposing.\n", instance);
    326339        free32(instance->tds);
    327340        free32(instance->qh);
     
    334347{
    335348        assert(instance);
    336         uhci_t *hc = dev_to_uhci(instance->dev);
     349        uhci_t *hc = fun_to_uhci(instance->fun);
    337350        assert(hc);
    338351        return uhci_schedule(hc, instance);
    339 }
    340 /*----------------------------------------------------------------------------*/
    341 /* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
    342 void batch_control_setup_old(batch_t *instance)
    343 {
    344         assert(instance);
    345         instance->packets = 1;
    346 
    347         /* setup stage */
    348         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    349             instance->setup_size, 0, false, instance->target,
    350             USB_PID_SETUP, instance->setup_buffer, NULL);
    351 
    352         instance->next_step = batch_call_out_and_dispose;
    353         batch_schedule(instance);
    354 }
    355 /*----------------------------------------------------------------------------*/
    356 void batch_control_write_data_old(batch_t *instance)
    357 {
    358         assert(instance);
    359         instance->packets -= 2;
    360         batch_interrupt_out(instance);
    361 }
    362 /*----------------------------------------------------------------------------*/
    363 void batch_control_read_data_old(batch_t *instance)
    364 {
    365         assert(instance);
    366         instance->packets -= 2;
    367         batch_interrupt_in(instance);
    368 }
    369 /*----------------------------------------------------------------------------*/
    370 void batch_control_write_status_old(batch_t *instance)
    371 {
    372         assert(instance);
    373         instance->packets = 1;
    374         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    375             0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
    376         instance->next_step = batch_call_in_and_dispose;
    377         batch_schedule(instance);
    378 }
    379 /*----------------------------------------------------------------------------*/
    380 void batch_control_read_status_old(batch_t *instance)
    381 {
    382         assert(instance);
    383         instance->packets = 1;
    384         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    385             0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
    386         instance->next_step = batch_call_out_and_dispose;
    387         batch_schedule(instance);
    388352}
    389353/**
Note: See TracChangeset for help on using the changeset viewer.