Changeset f241b05b in mainline for uspace/drv/uhci-hcd/tracker.c


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.