Ignore:
File:
1 edited

Legend:

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

    r4abc304 r30a4301  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
    3635
    3736#include <usb/debug.h>
     
    5251
    5352
    54 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     53batch_t * batch_get(device_t *dev, usb_target_t target,
    5554    usb_transfer_type_t transfer_type, size_t max_packet_size,
    56     usb_speed_t speed, char *buffer, size_t size,
     55    dev_speed_t speed, char *buffer, size_t size,
    5756    char* setup_buffer, size_t setup_size,
    5857    usbhc_iface_transfer_in_callback_t func_in,
     
    129128        instance->buffer_size = size;
    130129        instance->setup_size = setup_size;
    131         instance->fun = fun;
     130        instance->dev = dev;
    132131        instance->arg = arg;
    133132        instance->speed = speed;
    134133
    135134        queue_head_element_td(instance->qh, addr_to_phys(instance->tds));
    136         usb_log_debug("Batch(%p) %d:%d memory structures ready.\n",
    137             instance, target.address, target.endpoint);
    138135        return instance;
    139136}
     
    142139{
    143140        assert(instance);
    144         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
     141        usb_log_debug("Checking(%p) %d packet for completion.\n",
    145142            instance, instance->packets);
    146143        instance->transfered_size = 0;
     
    154151                        if (i > 0)
    155152                                instance->transfered_size -= instance->setup_size;
    156                         usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    157                           instance, i, instance->tds[i].status);
    158153                        return true;
    159154                }
     
    161156                    transfer_descriptor_actual_size(&instance->tds[i]);
    162157        }
     158        /* This is just an ugly trick to support the old API */
    163159        instance->transfered_size -= instance->setup_size;
    164160        return true;
     
    172168        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    173169
    174         const bool low_speed = instance->speed == USB_SPEED_LOW;
    175170        int toggle = 0;
    176171        /* setup stage */
    177172        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    178             instance->setup_size, toggle, false, low_speed,
    179             instance->target, USB_PID_SETUP, instance->setup_buffer,
    180             &instance->tds[1]);
     173            instance->setup_size, toggle, false, instance->target,
     174            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    181175
    182176        /* data stage */
     
    188182
    189183                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    190                     instance->max_packet_size, toggle++, false, low_speed,
    191                     instance->target, USB_PID_OUT, data, &instance->tds[i + 1]);
     184                    instance->max_packet_size, toggle++, false, instance->target,
     185                    USB_PID_OUT, data, &instance->tds[i + 1]);
    192186        }
    193187
     
    195189        i = instance->packets - 1;
    196190        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    197             0, 1, false, low_speed, instance->target, USB_PID_IN, NULL, NULL);
     191            0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
    198192
    199193        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    200         usb_log_debug2("Control write last TD status: %x.\n",
    201                 instance->tds[i].status);
    202194
    203195        instance->next_step = batch_call_out_and_dispose;
    204         usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance);
    205196        batch_schedule(instance);
    206197}
     
    210201        assert(instance);
    211202
    212         const bool low_speed = instance->speed == USB_SPEED_LOW;
    213203        int toggle = 0;
    214204        /* setup stage */
    215205        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    216             instance->setup_size, toggle, false, low_speed, instance->target,
     206            instance->setup_size, toggle, false, instance->target,
    217207            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    218208
     
    225215
    226216                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    227                     instance->max_packet_size, toggle, false, low_speed,
    228                                 instance->target, USB_PID_IN, data, &instance->tds[i + 1]);
     217                    instance->max_packet_size, toggle, false, instance->target,
     218                    USB_PID_IN, data, &instance->tds[i + 1]);
    229219        }
    230220
     
    232222        i = instance->packets - 1;
    233223        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    234             0, 1, false, low_speed, instance->target, USB_PID_OUT, NULL, NULL);
     224            0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
    235225
    236226        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    237         usb_log_debug2("Control read last TD status: %x.\n",
    238                 instance->tds[i].status);
    239227
    240228        instance->next_step = batch_call_in_and_dispose;
    241         usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance);
    242229        batch_schedule(instance);
    243230}
     
    247234        assert(instance);
    248235
    249         const bool low_speed = instance->speed == USB_SPEED_LOW;
    250236        int toggle = 1;
    251237        size_t i = 0;
     
    258244
    259245                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    260                     instance->max_packet_size, toggle, false, low_speed,
    261                     instance->target, USB_PID_IN, data, next);
     246                    instance->max_packet_size, toggle, false, instance->target,
     247                    USB_PID_IN, data, next);
    262248        }
    263249
     
    265251
    266252        instance->next_step = batch_call_in_and_dispose;
    267         usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    268253        batch_schedule(instance);
    269254}
     
    275260        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    276261
    277         const bool low_speed = instance->speed == USB_SPEED_LOW;
    278262        int toggle = 1;
    279263        size_t i = 0;
     
    286270
    287271                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    288                     instance->max_packet_size, toggle++, false, low_speed,
    289                     instance->target, USB_PID_OUT, data, next);
     272                    instance->max_packet_size, toggle++, false, instance->target,
     273                    USB_PID_OUT, data, next);
    290274        }
    291275
     
    293277
    294278        instance->next_step = batch_call_out_and_dispose;
    295         usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    296279        batch_schedule(instance);
    297280}
     
    305288
    306289        int err = instance->error;
    307         usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n",
    308             instance, instance->transfer_type, str_error(err), err,
    309             instance->transfered_size);
    310 
    311         instance->callback_in(instance->fun,
     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,
    312294            err, instance->transfered_size,
    313295            instance->arg);
     
    320302
    321303        int err = instance->error;
    322         usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n",
    323             instance, instance->transfer_type, str_error(err), err);
    324         instance->callback_out(instance->fun,
     304        usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
     305        instance->callback_out(instance->dev,
    325306            err, instance->arg);
    326307}
     
    330311        assert(instance);
    331312        batch_call_in(instance);
    332         usb_log_debug("Batch(%p) disposing.\n", instance);
     313        usb_log_debug("Disposing batch: %p.\n", instance);
    333314        free32(instance->tds);
    334315        free32(instance->qh);
     
    342323        assert(instance);
    343324        batch_call_out(instance);
    344         usb_log_debug("Batch(%p) disposing.\n", instance);
     325        usb_log_debug("Disposing batch: %p.\n", instance);
    345326        free32(instance->tds);
    346327        free32(instance->qh);
     
    353334{
    354335        assert(instance);
    355         uhci_t *hc = fun_to_uhci(instance->fun);
     336        uhci_t *hc = dev_to_uhci(instance->dev);
    356337        assert(hc);
    357338        return uhci_schedule(hc, instance);
     339}
     340/*----------------------------------------------------------------------------*/
     341/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
     342void 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/*----------------------------------------------------------------------------*/
     356void batch_control_write_data_old(batch_t *instance)
     357{
     358        assert(instance);
     359        instance->packets -= 2;
     360        batch_interrupt_out(instance);
     361}
     362/*----------------------------------------------------------------------------*/
     363void batch_control_read_data_old(batch_t *instance)
     364{
     365        assert(instance);
     366        instance->packets -= 2;
     367        batch_interrupt_in(instance);
     368}
     369/*----------------------------------------------------------------------------*/
     370void 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/*----------------------------------------------------------------------------*/
     380void 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);
    358388}
    359389/**
Note: See TracChangeset for help on using the changeset viewer.