Changeset d4beec3 in mainline for uspace/drv/uhci-hcd/batch.c


Ignore:
Timestamp:
2011-03-06T19:01:09Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
960bee9, c867a216
Parents:
24d5432 (diff), 8a20380 (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:

Fix toggle protocol implementation

File:
1 edited

Legend:

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

    r24d5432 rd4beec3  
    5454static void batch_call_in_and_dispose(batch_t *instance);
    5555static void batch_call_out_and_dispose(batch_t *instance);
     56static void batch_dispose(batch_t *instance);
    5657
    5758
     
    6162    char* setup_buffer, size_t setup_size,
    6263    usbhc_iface_transfer_in_callback_t func_in,
    63     usbhc_iface_transfer_out_callback_t func_out, void *arg)
     64    usbhc_iface_transfer_out_callback_t func_out, void *arg,
     65    device_keeper_t *manager
     66    )
    6467{
    6568        assert(func_in == NULL || func_out == NULL);
     
    137140        instance->arg = arg;
    138141        instance->speed = speed;
     142        instance->manager = manager;
    139143
    140144        queue_head_element_td(instance->qh, addr_to_phys(instance->tds));
     
    160164                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    161165                            instance, i, instance->tds[i].status);
     166
     167                        device_keeper_set_toggle(instance->manager, instance->target,
     168                            td_toggle(&instance->tds[i]));
    162169                        if (i > 0)
    163170                                goto substract_ret;
     
    232239}
    233240/*----------------------------------------------------------------------------*/
    234 static void batch_data(batch_t *instance, usb_packet_id pid)
     241void batch_data(batch_t *instance, usb_packet_id pid)
    235242{
    236243        assert(instance);
    237244        const bool low_speed = instance->speed == USB_SPEED_LOW;
    238         int toggle = 1;
     245        int toggle = device_keeper_get_toggle(instance->manager, instance->target);
     246        assert(toggle == 0 || toggle == 1);
    239247
    240248        size_t packet = 0;
     
    245253                    - remain_size;
    246254
    247                 toggle = 1 - toggle;
    248255
    249256                const size_t packet_size =
     
    256263                    &instance->tds[packet + 1]);
    257264
     265                toggle = 1 - toggle;
    258266                ++packet;
    259267                assert(packet <= instance->packets);
     
    261269                remain_size -= packet_size;
    262270        }
     271        device_keeper_set_toggle(instance->manager, instance->target, toggle);
    263272
    264273        instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     
    266275}
    267276/*----------------------------------------------------------------------------*/
    268 static void batch_control(batch_t *instance,
     277void batch_control(batch_t *instance,
    269278   usb_packet_id data_stage, usb_packet_id status_stage)
    270279{
     
    347356        assert(instance);
    348357        batch_call_in(instance);
     358        batch_dispose(instance);
     359}
     360/*----------------------------------------------------------------------------*/
     361void batch_call_out_and_dispose(batch_t *instance)
     362{
     363        assert(instance);
     364        batch_call_out(instance);
     365        batch_dispose(instance);
     366}
     367/*----------------------------------------------------------------------------*/
     368void batch_dispose(batch_t *instance)
     369{
     370        assert(instance);
    349371        usb_log_debug("Batch(%p) disposing.\n", instance);
    350372        free32(instance->tds);
     
    355377}
    356378/*----------------------------------------------------------------------------*/
    357 void batch_call_out_and_dispose(batch_t *instance)
    358 {
    359         assert(instance);
    360         batch_call_out(instance);
    361         usb_log_debug("Batch(%p) disposing.\n", instance);
    362         free32(instance->tds);
    363         free32(instance->qh);
    364         free32(instance->setup_buffer);
    365         free32(instance->transport_buffer);
    366         free(instance);
    367 }
    368 /*----------------------------------------------------------------------------*/
    369379int batch_schedule(batch_t *instance)
    370380{
Note: See TracChangeset for help on using the changeset viewer.