Changeset 3e37964 in mainline


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

Use toggle tracking

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

Legend:

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

    redb5f837 r3e37964  
    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);
     51static void batch_data(batch_t *instance, usb_packet_id pid, device_keeper_t *keeper);
    5252static void batch_call_in(batch_t *instance);
    5353static void batch_call_out(batch_t *instance);
     
    194194}
    195195/*----------------------------------------------------------------------------*/
    196 void batch_interrupt_in(batch_t *instance)
    197 {
    198         assert(instance);
    199         batch_data(instance, USB_PID_IN);
     196void batch_interrupt_in(batch_t *instance, device_keeper_t *keeper)
     197{
     198        assert(instance);
     199        batch_data(instance, USB_PID_IN, keeper);
    200200        instance->next_step = batch_call_in_and_dispose;
    201201        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
     
    203203}
    204204/*----------------------------------------------------------------------------*/
    205 void batch_interrupt_out(batch_t *instance)
     205void batch_interrupt_out(batch_t *instance, device_keeper_t *keeper)
    206206{
    207207        assert(instance);
    208208        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    209         batch_data(instance, USB_PID_OUT);
     209        batch_data(instance, USB_PID_OUT, keeper);
    210210        instance->next_step = batch_call_out_and_dispose;
    211211        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
     
    213213}
    214214/*----------------------------------------------------------------------------*/
    215 void batch_bulk_in(batch_t *instance)
    216 {
    217         assert(instance);
    218         batch_data(instance, USB_PID_IN);
     215void batch_bulk_in(batch_t *instance, device_keeper_t *keeper)
     216{
     217        assert(instance);
     218        batch_data(instance, USB_PID_IN, keeper);
    219219        instance->next_step = batch_call_in_and_dispose;
    220220        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
     
    222222}
    223223/*----------------------------------------------------------------------------*/
    224 void batch_bulk_out(batch_t *instance)
     224void batch_bulk_out(batch_t *instance, device_keeper_t *keeper)
    225225{
    226226        assert(instance);
    227227        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    228         batch_data(instance, USB_PID_OUT);
     228        batch_data(instance, USB_PID_OUT, keeper);
    229229        instance->next_step = batch_call_out_and_dispose;
    230230        usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
     
    232232}
    233233/*----------------------------------------------------------------------------*/
    234 static void batch_data(batch_t *instance, usb_packet_id pid)
     234void batch_data(batch_t *instance, usb_packet_id pid, device_keeper_t *keeper)
    235235{
    236236        assert(instance);
    237237        const bool low_speed = instance->speed == USB_SPEED_LOW;
    238         int toggle = 1;
     238        int toggle = device_keeper_get_toggle(keeper, instance->target);
     239        assert(toggle == 0 || toggle == 1);
    239240
    240241        size_t packet = 0;
     
    245246                    - remain_size;
    246247
    247                 toggle = 1 - toggle;
    248248
    249249                const size_t packet_size =
     
    256256                    &instance->tds[packet + 1]);
    257257
     258                toggle = 1 - toggle;
    258259                ++packet;
    259260                assert(packet <= instance->packets);
     
    261262                remain_size -= packet_size;
    262263        }
     264        device_keeper_set_toggle(keeper, instance->target, toggle);
    263265
    264266        instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     
    266268}
    267269/*----------------------------------------------------------------------------*/
    268 static void batch_control(batch_t *instance,
     270void batch_control(batch_t *instance,
    269271   usb_packet_id data_stage, usb_packet_id status_stage)
    270272{
  • uspace/drv/uhci-hcd/batch.h

    redb5f837 r3e37964  
    4242#include "uhci_struct/transfer_descriptor.h"
    4343#include "uhci_struct/queue_head.h"
     44#include "utils/device_keeper.h"
    4445
    4546typedef struct batch
     
    8283void batch_control_read(batch_t *instance);
    8384
    84 void batch_interrupt_in(batch_t *instance);
     85void batch_interrupt_in(batch_t *instance, device_keeper_t *keeper);
    8586
    86 void batch_interrupt_out(batch_t *instance);
     87void batch_interrupt_out(batch_t *instance, device_keeper_t *keeper);
    8788
    88 void batch_bulk_in(batch_t *instance);
     89void batch_bulk_in(batch_t *instance, device_keeper_t *keeper);
    8990
    90 void batch_bulk_out(batch_t *instance);
     91void batch_bulk_out(batch_t *instance, device_keeper_t *keeper);
    9192#endif
    9293/**
  • uspace/drv/uhci-hcd/iface.c

    redb5f837 r3e37964  
    117117        if (!batch)
    118118                return ENOMEM;
    119         batch_interrupt_out(batch);
     119        batch_interrupt_out(batch, &hc->device_manager);
    120120        return EOK;
    121121}
     
    136136        if (!batch)
    137137                return ENOMEM;
    138         batch_interrupt_in(batch);
     138        batch_interrupt_in(batch, &hc->device_manager);
    139139        return EOK;
    140140}
     
    156156        if (!batch)
    157157                return ENOMEM;
    158         batch_bulk_out(batch);
     158        batch_bulk_out(batch, &hc->device_manager);
    159159        return EOK;
    160160}
     
    175175        if (!batch)
    176176                return ENOMEM;
    177         batch_bulk_in(batch);
     177        batch_bulk_in(batch, &hc->device_manager);
    178178        return EOK;
    179179}
Note: See TracChangeset for help on using the changeset viewer.