Changes in / [c7bdfa7:26d46d2] in mainline


Ignore:
Location:
uspace/drv
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/batch.c

    rc7bdfa7 r26d46d2  
    5151static void batch_control(usb_transfer_batch_t *instance,
    5252    usb_direction_t data_dir, usb_direction_t status_dir);
     53static void batch_data(usb_transfer_batch_t *instance);
    5354static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);
    5455static void batch_call_out_and_dispose(usb_transfer_batch_t *instance);
     
    134135        assert(data);
    135136        size_t tds = data->td_count - 1;
    136         usb_log_debug2("Batch(%p) checking %d td(s) for completion.\n",
     137        usb_log_debug("Batch(%p) checking %d td(s) for completion.\n",
    137138            instance, tds);
     139        usb_log_debug("ED: %x:%x:%x:%x.\n",
     140            data->ed->status, data->ed->td_head, data->ed->td_tail,
     141            data->ed->next);
    138142        size_t i = 0;
    139143        for (; i < tds; ++i) {
     144                usb_log_debug("TD %d: %x:%x:%x:%x.\n", i,
     145                    data->tds[i].status, data->tds[i].cbp, data->tds[i].next,
     146                    data->tds[i].be);
    140147                if (!td_is_finished(&data->tds[i]))
    141148                        return false;
     
    177184        assert(instance->direction == USB_DIRECTION_IN);
    178185        instance->next_step = batch_call_in_and_dispose;
    179         /* TODO: implement */
     186        batch_data(instance);
    180187        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    181188}
     
    189196            instance->buffer_size);
    190197        instance->next_step = batch_call_out_and_dispose;
    191         /* TODO: implement */
     198        batch_data(instance);
    192199        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    193200}
     
    198205        instance->direction = USB_DIRECTION_IN;
    199206        instance->next_step = batch_call_in_and_dispose;
    200         /* TODO: implement */
     207        batch_data(instance);
    201208        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    202209}
     
    207214        instance->direction = USB_DIRECTION_IN;
    208215        instance->next_step = batch_call_in_and_dispose;
    209         /* TODO: implement */
     216        batch_data(instance);
    210217        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    211218}
     
    268275}
    269276/*----------------------------------------------------------------------------*/
     277void batch_data(usb_transfer_batch_t *instance)
     278{
     279        assert(instance);
     280        ohci_batch_t *data = instance->private_data;
     281        assert(data);
     282        ed_init(data->ed, instance->ep);
     283        ed_add_tds(data->ed, &data->tds[0], &data->tds[data->td_count - 1]);
     284        usb_log_debug("Created ED(%p): %x:%x:%x:%x.\n", data->ed,
     285            data->ed->status, data->ed->td_tail, data->ed->td_head,
     286            data->ed->next);
     287
     288        /* data stage */
     289        size_t td_current = 1;
     290        size_t remain_size = instance->buffer_size;
     291        char *transfer_buffer = instance->transport_buffer;
     292        while (remain_size > 0) {
     293                size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ?
     294                    OHCI_TD_MAX_TRANSFER : remain_size;
     295
     296                td_init(&data->tds[td_current], instance->ep->direction,
     297                    transfer_buffer, transfer_size, -1);
     298                td_set_next(&data->tds[td_current], &data->tds[td_current + 1]);
     299                usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n",
     300                    data->tds[td_current].status, data->tds[td_current].cbp,
     301                    data->tds[td_current].next, data->tds[td_current].be);
     302
     303                transfer_buffer += transfer_size;
     304                remain_size -= transfer_size;
     305                assert(td_current < data->td_count);
     306                ++td_current;
     307        }
     308}
     309/*----------------------------------------------------------------------------*/
    270310/** Helper function calls callback and correctly disposes of batch structure.
    271311 *
  • uspace/drv/ohci/hc.c

    rc7bdfa7 r26d46d2  
    135135        }
    136136
    137         transfer_list_add_batch(
    138             instance->transfers[batch->transfer_type], batch);
    139 
    140137        switch (batch->transfer_type) {
    141138        case USB_TRANSFER_CONTROL:
    142139                instance->registers->control &= ~C_CLE;
     140                transfer_list_add_batch(
     141                    instance->transfers[batch->transfer_type], batch);
    143142                instance->registers->command_status |= CS_CLF;
    144                 usb_log_debug2("Set control transfer filled: %x.\n",
     143                usb_log_debug2("Set CS control transfer filled: %x.\n",
    145144                        instance->registers->command_status);
     145                instance->registers->control_current = 0;
    146146                instance->registers->control |= C_CLE;
    147147                break;
    148148        case USB_TRANSFER_BULK:
     149                instance->registers->control &= ~C_BLE;
     150                transfer_list_add_batch(
     151                    instance->transfers[batch->transfer_type], batch);
    149152                instance->registers->command_status |= CS_BLF;
    150153                usb_log_debug2("Set bulk transfer filled: %x.\n",
    151154                        instance->registers->command_status);
     155                instance->registers->control |= C_BLE;
     156                break;
     157        case USB_TRANSFER_INTERRUPT:
     158        case USB_TRANSFER_ISOCHRONOUS:
     159                instance->registers->control &= ~C_PLE;
     160                transfer_list_add_batch(
     161                    instance->transfers[batch->transfer_type], batch);
     162                instance->registers->control |= C_PLE;
    152163                break;
    153164        default:
     
    165176                rh_interrupt(&instance->rh);
    166177
    167         usb_log_info("OHCI interrupt: %x.\n", status);
    168 
    169 
    170         LIST_INITIALIZE(done);
    171         transfer_list_remove_finished(&instance->transfers_interrupt, &done);
    172         transfer_list_remove_finished(&instance->transfers_isochronous, &done);
    173         transfer_list_remove_finished(&instance->transfers_control, &done);
    174         transfer_list_remove_finished(&instance->transfers_bulk, &done);
    175 
    176         while (!list_empty(&done)) {
    177                 link_t *item = done.next;
    178                 list_remove(item);
    179                 usb_transfer_batch_t *batch =
    180                     list_get_instance(item, usb_transfer_batch_t, link);
    181                 usb_transfer_batch_finish(batch);
     178        usb_log_debug("OHCI interrupt: %x.\n", status);
     179
     180
     181        if (status & IS_WDH) {
     182                LIST_INITIALIZE(done);
     183                transfer_list_remove_finished(
     184                    &instance->transfers_interrupt, &done);
     185                transfer_list_remove_finished(
     186                    &instance->transfers_isochronous, &done);
     187                transfer_list_remove_finished(
     188                    &instance->transfers_control, &done);
     189                transfer_list_remove_finished(
     190                    &instance->transfers_bulk, &done);
     191
     192                while (!list_empty(&done)) {
     193                        link_t *item = done.next;
     194                        list_remove(item);
     195                        usb_transfer_batch_t *batch =
     196                            list_get_instance(item, usb_transfer_batch_t, link);
     197                        usb_transfer_batch_finish(batch);
     198                }
    182199        }
    183200}
     
    191208                instance->registers->interrupt_status = status;
    192209                hc_interrupt(instance, status);
    193                 async_usleep(1000);
     210                async_usleep(10000);
    194211        }
    195212        return EOK;
     
    267284            instance->registers->control);
    268285
     286        /* Use HCCA */
     287        instance->registers->hcca = addr_to_phys(instance->hcca);
     288
     289        /* Use queues */
     290        instance->registers->bulk_head = instance->transfers_bulk.list_head_pa;
     291        usb_log_debug2("Bulk HEAD set to: %p(%p).\n",
     292            instance->transfers_bulk.list_head,
     293            instance->transfers_bulk.list_head_pa);
     294
     295        instance->registers->control_head =
     296            instance->transfers_control.list_head_pa;
     297        usb_log_debug2("Control HEAD set to: %p(%p).\n",
     298            instance->transfers_control.list_head,
     299            instance->transfers_control.list_head_pa);
     300
    269301        /* Enable queues */
    270302        instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
     
    342374                return ENOMEM;
    343375        bzero(instance->hcca, sizeof(hcca_t));
    344         instance->registers->hcca = addr_to_phys(instance->hcca);
    345         usb_log_debug2("OHCI HCCA initialized at %p(%p).\n",
    346             instance->hcca, instance->registers->hcca);
    347 
    348         /* Use queues */
    349         instance->registers->bulk_head = instance->transfers_bulk.list_head_pa;
    350         usb_log_debug2("Bulk HEAD set to: %p(%p).\n",
    351             instance->transfers_bulk.list_head,
    352             instance->transfers_bulk.list_head_pa);
    353 
    354         instance->registers->control_head =
    355             instance->transfers_control.list_head_pa;
    356         usb_log_debug2("Control HEAD set to: %p(%p).\n",
    357             instance->transfers_control.list_head,
    358             instance->transfers_control.list_head_pa);
     376        usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
    359377
    360378        unsigned i = 0;
  • uspace/drv/ohci/hw_struct/endpoint_descriptor.c

    rc7bdfa7 r26d46d2  
    5353                << ED_STATUS_MPS_SHIFT);
    5454
     55
    5556        if (ep->speed == USB_SPEED_LOW)
    5657                instance->status |= ED_STATUS_S_FLAG;
    5758        if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)
    5859                instance->status |= ED_STATUS_F_FLAG;
     60
     61        if (ep->toggle)
     62                instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
    5963}
    6064/**
  • uspace/drv/ohci/hw_struct/endpoint_descriptor.h

    rc7bdfa7 r26d46d2  
    5353#define ED_STATUS_D_MASK (0x3)     /* direction */
    5454#define ED_STATUS_D_SHIFT (11)
    55 #define ED_STATUS_D_IN (0x1)
    56 #define ED_STATUS_D_OUT (0x2)
     55#define ED_STATUS_D_OUT (0x1)
     56#define ED_STATUS_D_IN (0x2)
    5757#define ED_STATUS_D_TRANSFER (0x3)
    5858
     
    8484{
    8585        assert(instance);
    86         instance->td_head = addr_to_phys(head) & ED_TDHEAD_PTR_MASK;
     86        instance->td_head =
     87            ((addr_to_phys(head) & ED_TDHEAD_PTR_MASK)
     88            | (instance->td_head & ~ED_TDHEAD_PTR_MASK));
    8789        instance->td_tail = addr_to_phys(tail) & ED_TDTAIL_PTR_MASK;
    8890}
     
    9698        instance->next = pa;
    9799}
    98 
    99100#endif
    100101/**
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    rc7bdfa7 r26d46d2  
    5050#define TD_STATUS_DP_SHIFT (19)
    5151#define TD_STATUS_DP_SETUP (0x0)
    52 #define TD_STATUS_DP_IN (0x1)
    53 #define TD_STATUS_DP_OUT (0x2)
     52#define TD_STATUS_DP_OUT (0x1)
     53#define TD_STATUS_DP_IN (0x2)
    5454#define TD_STATUS_DI_MASK (0x7) /* delay interrupt, wait DI frames before int */
    5555#define TD_STATUS_DI_SHIFT (21)
  • uspace/drv/ohci/main.c

    rc7bdfa7 r26d46d2  
    9292int main(int argc, char *argv[])
    9393{
    94         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     94        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    9595        sleep(5);
    9696        return ddf_driver_main(&ohci_driver);
  • uspace/drv/ohci/transfer_list.c

    rc7bdfa7 r26d46d2  
    143143
    144144        fibril_mutex_lock(&instance->guard);
     145        usb_log_debug2("Checking list %s for completed batches(%d).\n",
     146            instance->name, list_count(&instance->batch_list));
    145147        link_t *current = instance->batch_list.next;
    146148        while (current != &instance->batch_list) {
Note: See TracChangeset for help on using the changeset viewer.