Changeset 5620bd4 in mainline


Ignore:
Timestamp:
2011-03-06T18:38:55Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
57c0a7e
Parents:
98807e16
Message:

Integrate device_keeper into bathc structure

Check every control write for toggle reset

Location:
uspace/drv/uhci-hcd
Files:
3 edited

Legend:

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

    r98807e16 r5620bd4  
    4949static void batch_control(batch_t *instance,
    5050    usb_packet_id data_stage, usb_packet_id status_stage);
    51 static void batch_data(batch_t *instance, usb_packet_id pid, device_keeper_t *keeper);
     51static void batch_data(batch_t *instance, usb_packet_id pid);
    5252static void batch_call_in(batch_t *instance);
    5353static void batch_call_out(batch_t *instance);
     
    6161    char* setup_buffer, size_t setup_size,
    6262    usbhc_iface_transfer_in_callback_t func_in,
    63     usbhc_iface_transfer_out_callback_t func_out, void *arg)
     63    usbhc_iface_transfer_out_callback_t func_out, void *arg,
     64    device_keeper_t *manager
     65    )
    6466{
    6567        assert(func_in == NULL || func_out == NULL);
     
    137139        instance->arg = arg;
    138140        instance->speed = speed;
     141        instance->manager = manager;
    139142
    140143        queue_head_element_td(instance->qh, addr_to_phys(instance->tds));
     
    194197}
    195198/*----------------------------------------------------------------------------*/
    196 void batch_interrupt_in(batch_t *instance, device_keeper_t *keeper)
    197 {
    198         assert(instance);
    199         batch_data(instance, USB_PID_IN, keeper);
     199void batch_interrupt_in(batch_t *instance)
     200{
     201        assert(instance);
     202        batch_data(instance, USB_PID_IN);
    200203        instance->next_step = batch_call_in_and_dispose;
    201204        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
     
    203206}
    204207/*----------------------------------------------------------------------------*/
    205 void batch_interrupt_out(batch_t *instance, device_keeper_t *keeper)
     208void batch_interrupt_out(batch_t *instance)
    206209{
    207210        assert(instance);
    208211        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    209         batch_data(instance, USB_PID_OUT, keeper);
     212        batch_data(instance, USB_PID_OUT);
    210213        instance->next_step = batch_call_out_and_dispose;
    211214        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
     
    213216}
    214217/*----------------------------------------------------------------------------*/
    215 void batch_bulk_in(batch_t *instance, device_keeper_t *keeper)
    216 {
    217         assert(instance);
    218         batch_data(instance, USB_PID_IN, keeper);
     218void batch_bulk_in(batch_t *instance)
     219{
     220        assert(instance);
     221        batch_data(instance, USB_PID_IN);
    219222        instance->next_step = batch_call_in_and_dispose;
    220223        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
     
    222225}
    223226/*----------------------------------------------------------------------------*/
    224 void batch_bulk_out(batch_t *instance, device_keeper_t *keeper)
     227void batch_bulk_out(batch_t *instance)
    225228{
    226229        assert(instance);
    227230        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    228         batch_data(instance, USB_PID_OUT, keeper);
     231        batch_data(instance, USB_PID_OUT);
    229232        instance->next_step = batch_call_out_and_dispose;
    230233        usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
     
    232235}
    233236/*----------------------------------------------------------------------------*/
    234 void batch_data(batch_t *instance, usb_packet_id pid, device_keeper_t *keeper)
     237void batch_data(batch_t *instance, usb_packet_id pid)
    235238{
    236239        assert(instance);
    237240        const bool low_speed = instance->speed == USB_SPEED_LOW;
    238         int toggle = device_keeper_get_toggle(keeper, instance->target);
     241        int toggle = device_keeper_get_toggle(instance->manager, instance->target);
    239242        assert(toggle == 0 || toggle == 1);
    240243
     
    262265                remain_size -= packet_size;
    263266        }
    264         device_keeper_set_toggle(keeper, instance->target, toggle);
     267        device_keeper_set_toggle(instance->manager, instance->target, toggle);
    265268
    266269        instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
  • uspace/drv/uhci-hcd/batch.h

    r98807e16 r5620bd4  
    6868        td_t *tds;
    6969        void (*next_step)(struct batch*);
     70        device_keeper_t *manager;
    7071} batch_t;
    7172
     
    7576                char *setup_buffer, size_t setup_size,
    7677    usbhc_iface_transfer_in_callback_t func_in,
    77     usbhc_iface_transfer_out_callback_t func_out, void *arg);
     78    usbhc_iface_transfer_out_callback_t func_out, void *arg,
     79                device_keeper_t *manager
     80                );
    7881
    7982bool batch_is_complete(batch_t *instance);
     
    8386void batch_control_read(batch_t *instance);
    8487
    85 void batch_interrupt_in(batch_t *instance, device_keeper_t *keeper);
     88void batch_interrupt_in(batch_t *instance);
    8689
    87 void batch_interrupt_out(batch_t *instance, device_keeper_t *keeper);
     90void batch_interrupt_out(batch_t *instance);
    8891
    89 void batch_bulk_in(batch_t *instance, device_keeper_t *keeper);
     92void batch_bulk_in(batch_t *instance);
    9093
    91 void batch_bulk_out(batch_t *instance, device_keeper_t *keeper);
     94void batch_bulk_out(batch_t *instance);
    9295#endif
    9396/**
  • uspace/drv/uhci-hcd/iface.c

    r98807e16 r5620bd4  
    114114
    115115        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    116             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    117         if (!batch)
    118                 return ENOMEM;
    119         batch_interrupt_out(batch, &hc->device_manager);
     116            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
     117            &hc->device_manager);
     118        if (!batch)
     119                return ENOMEM;
     120        batch_interrupt_out(batch);
    120121        return EOK;
    121122}
     
    133134
    134135        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    135             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    136         if (!batch)
    137                 return ENOMEM;
    138         batch_interrupt_in(batch, &hc->device_manager);
     136            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
     137                        &hc->device_manager);
     138        if (!batch)
     139                return ENOMEM;
     140        batch_interrupt_in(batch);
    139141        return EOK;
    140142}
     
    153155
    154156        batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    155             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    156         if (!batch)
    157                 return ENOMEM;
    158         batch_bulk_out(batch, &hc->device_manager);
     157            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
     158            &hc->device_manager);
     159        if (!batch)
     160                return ENOMEM;
     161        batch_bulk_out(batch);
    159162        return EOK;
    160163}
     
    172175
    173176        batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    174             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    175         if (!batch)
    176                 return ENOMEM;
    177         batch_bulk_in(batch, &hc->device_manager);
     177            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
     178            &hc->device_manager);
     179        if (!batch)
     180                return ENOMEM;
     181        batch_bulk_in(batch);
    178182        return EOK;
    179183}
     
    191195            target.address, target.endpoint, size, max_packet_size);
    192196
     197        if (setup_size != 8)
     198                return EINVAL;
     199
    193200        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    194201            max_packet_size, speed, data, size, setup_data, setup_size,
    195             NULL, callback, arg);
    196         if (!batch)
    197                 return ENOMEM;
     202            NULL, callback, arg, &hc->device_manager);
     203        if (!batch)
     204                return ENOMEM;
     205        device_keeper_reset_if_need(&hc->device_manager, target, setup_data);
    198206        batch_control_write(batch);
    199207        return EOK;
     
    214222        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    215223            max_packet_size, speed, data, size, setup_data, setup_size, callback,
    216             NULL, arg);
     224            NULL, arg, &hc->device_manager);
    217225        if (!batch)
    218226                return ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.