Changeset c6fe469 in mainline


Ignore:
Timestamp:
2011-04-10T22:30:59Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
26d46d2
Parents:
7628050
Message:

Add support for INT and BULK transfers

Location:
uspace/drv/ohci
Files:
2 edited

Legend:

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

    r7628050 rc6fe469  
    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);
     
    183184        assert(instance->direction == USB_DIRECTION_IN);
    184185        instance->next_step = batch_call_in_and_dispose;
    185         /* TODO: implement */
     186        batch_data(instance);
    186187        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    187188}
     
    195196            instance->buffer_size);
    196197        instance->next_step = batch_call_out_and_dispose;
    197         /* TODO: implement */
     198        batch_data(instance);
    198199        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    199200}
     
    204205        instance->direction = USB_DIRECTION_IN;
    205206        instance->next_step = batch_call_in_and_dispose;
    206         /* TODO: implement */
     207        batch_data(instance);
    207208        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    208209}
     
    213214        instance->direction = USB_DIRECTION_IN;
    214215        instance->next_step = batch_call_in_and_dispose;
    215         /* TODO: implement */
     216        batch_data(instance);
    216217        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    217218}
     
    274275}
    275276/*----------------------------------------------------------------------------*/
     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/*----------------------------------------------------------------------------*/
    276310/** Helper function calls callback and correctly disposes of batch structure.
    277311 *
  • uspace/drv/ohci/hc.c

    r7628050 rc6fe469  
    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:
Note: See TracChangeset for help on using the changeset viewer.