Changeset f241b05b in mainline


Ignore:
Timestamp:
2011-02-07T22:09:17Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f82cc1a8
Parents:
a72620d
Message:

Adds new calbacks implementation

several debug texts

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

Legend:

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

    ra72620d rf241b05b  
    136136    usbhc_iface_transfer_out_callback_t callback, void *arg)
    137137{
    138         return ENOTSUP;
     138        size_t max_packet_size = size;
     139        dev_speed_t speed = FULL_SPEED;
     140
     141        tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
     142            max_packet_size, speed, data, size, NULL, callback, arg);
     143        if (!tracker)
     144                return ENOMEM;
     145        tracker_control_write(tracker, setup_data, setup_size);
     146        return EOK;
    139147}
    140148/*----------------------------------------------------------------------------*/
     
    143151    usbhc_iface_transfer_in_callback_t callback, void *arg)
    144152{
    145         return ENOTSUP;
     153        size_t max_packet_size = size;
     154        dev_speed_t speed = FULL_SPEED;
     155
     156        tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
     157            max_packet_size, speed, data, size, callback, NULL, arg);
     158        if (!tracker)
     159                return ENOMEM;
     160        tracker_control_read(tracker, setup_data, setup_size);
     161        return EOK;
    146162}
    147163/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-hcd/tracker.c

    ra72620d rf241b05b  
    109109}
    110110/*----------------------------------------------------------------------------*/
    111 void tracker_control_write(tracker_t *instance)
     111void tracker_control_write(
     112    tracker_t *instance, char* setup_buffer, size_t setup_size)
    112113{
    113114        assert(instance);
    114115        assert(instance->buffer_offset == 0);
    115 
    116         instance->packet_size = SETUP_PACKET_DATA_SIZE;
    117         memcpy(instance->packet, instance->buffer, SETUP_PACKET_DATA_SIZE);
    118 
    119         transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
    120             SETUP_PACKET_DATA_SIZE, instance->toggle++, false, instance->target,
     116        assert(setup_size == 8);
     117
     118        instance->packet_size = 0;
     119        memcpy(instance->packet, setup_buffer, setup_size);
     120
     121        transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
     122            setup_size, instance->toggle++, false, instance->target,
    121123            USB_PID_SETUP, instance->packet);
    122124
    123         instance->buffer_offset += SETUP_PACKET_DATA_SIZE;
    124125        instance->next_step = tracker_control_write_data;
    125126
     
    127128}
    128129/*----------------------------------------------------------------------------*/
    129 void tracker_control_read(tracker_t *instance)
     130void tracker_control_read(
     131    tracker_t *instance, char* setup_buffer, size_t setup_size)
    130132{
    131133        assert(instance);
    132134        assert(instance->buffer_offset == 0);
    133 
    134         instance->packet_size = SETUP_PACKET_DATA_SIZE;
    135         memcpy(instance->packet, instance->buffer, SETUP_PACKET_DATA_SIZE);
    136 
    137         transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
    138             SETUP_PACKET_DATA_SIZE, instance->toggle++, false, instance->target,
     135        assert(setup_size == 8);
     136
     137        memcpy(instance->packet, setup_buffer, setup_size);
     138
     139        transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
     140            setup_size, instance->toggle++, false, instance->target,
    139141            USB_PID_SETUP, instance->packet);
    140142
     
    157159
    158160        /* we are data in, we want data from our device */
    159         memcpy(instance->buffer + instance->buffer_offset, instance->packet,
    160             instance->packet_size);
     161        if (instance->packet_size) {
     162                memcpy(instance->buffer + instance->buffer_offset, instance->packet,
     163                    instance->packet_size);
     164        }
    161165        instance->buffer_offset += instance->packet_size;
    162166
     
    190194        }
    191195
    192         /* we are data out, we down't want data from our device */
     196        /* we are data out, we don't want data from our device */
    193197        instance->buffer_offset += instance->packet_size;
    194198
     
    233237        instance->packet_size = 0;
    234238        transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
    235             0, 1, false, instance->target, USB_PID_OUT, NULL);
     239            instance->packet_size, 1, false, instance->target, USB_PID_OUT, NULL);
    236240
    237241        tracker_schedule(instance);
     
    253257
    254258        /* we are data in, we want data from our device */
     259        assert(
     260            instance->buffer_offset + instance->packet_size <= instance->buffer_size);
    255261        memcpy(instance->buffer + instance->buffer_offset, instance->packet,
    256262            instance->packet_size);
     
    261267        instance->packet_size = 0;
    262268        transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
    263             0, 1, false, instance->target, USB_PID_OUT, NULL);
     269            instance->packet_size, 1, false, instance->target, USB_PID_IN, NULL);
    264270
    265271        tracker_schedule(instance);
     
    290296        instance->packet_size = MIN(instance->max_packet_size,
    291297                        instance->buffer_size - instance->buffer_offset);
     298        assert(instance->packet_size <= instance->max_packet_size);
    292299
    293300        transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
     
    351358        }
    352359        instance->buffer_offset += instance->packet_size;
    353         usb_log_debug("Callback IN: %d, %zu.\n", err, instance->buffer_offset);
     360        usb_log_debug("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
     361            err, instance->buffer_offset);
    354362        instance->callback_in(instance->dev,
    355363            err ? USB_OUTCOME_CRCERROR : USB_OUTCOME_OK, instance->buffer_offset,
     
    364372        /* check for errors */
    365373        int err = transfer_descriptor_status(instance->td);
    366         usb_log_debug("Callback OUT: %d, %zu.\n", err, instance->buffer_offset);
     374        usb_log_debug("Callback OUT(%d): %d, %zu.\n", instance->transfer_type,
     375            err, instance->buffer_offset);
    367376        instance->callback_out(instance->dev,
    368377            err ? USB_OUTCOME_CRCERROR : USB_OUTCOME_OK, instance->arg);
  • uspace/drv/uhci-hcd/tracker.h

    ra72620d rf241b05b  
    7777    usbhc_iface_transfer_out_callback_t func_out, void *arg);
    7878
    79 void tracker_control_write(tracker_t *instance);
     79void tracker_control_write(
     80    tracker_t *instance, char* setup_buffer, size_t setup_size);
    8081
    81 void tracker_control_read(tracker_t *instance);
     82void tracker_control_read(
     83    tracker_t *instance, char* setup_buffer, size_t setup_size);
    8284
    8385void tracker_interrupt_in(tracker_t *instance);
  • uspace/drv/uhci-hcd/transfer_list.c

    ra72620d rf241b05b  
    8383
    8484        /* check again, may be use atomic compare and swap */
    85         if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
    86                 instance->queue_head->element = pa;
    87         }
     85//      if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
     86//              instance->queue_head->element = pa;
     87//      }
    8888}
    8989/**
  • uspace/drv/uhci-hcd/uhci.c

    ra72620d rf241b05b  
    186186                        link_t *next = current->next;
    187187                        tracker_t *tracker = list_get_instance(current, tracker_t, link);
     188
    188189                        assert(current == &tracker->link);
     190                        assert(tracker);
     191                        assert(tracker->next_step);
     192                        assert(tracker->td);
     193
    189194                        if (!transfer_descriptor_is_active(tracker->td)) {
    190195                                usb_log_info("Found inactive tracker with status: %x.\n",
Note: See TracChangeset for help on using the changeset viewer.