Changeset cc44f7e in mainline for uspace/drv/uhci-hcd/batch.c


Ignore:
Timestamp:
2011-02-28T13:04:21Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b5644c, 494eaf7, 51b46f2
Parents:
81c508c (diff), dced52a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

hc and rh work

Support for low speed devices
RH iospace obtained from parent hc driver
proper hc initialization
Debug messages reworked
intelpci adressspace size fix (read the warning)

File:
1 edited

Legend:

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

    r81c508c rcc44f7e  
    3333 */
    3434#include <errno.h>
     35#include <str_error.h>
    3536
    3637#include <usb/debug.h>
     
    5354batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    5455    usb_transfer_type_t transfer_type, size_t max_packet_size,
    55     dev_speed_t speed, char *buffer, size_t size,
     56    usb_speed_t speed, char *buffer, size_t size,
    5657    char* setup_buffer, size_t setup_size,
    5758    usbhc_iface_transfer_in_callback_t func_in,
     
    133134
    134135        queue_head_element_td(instance->qh, addr_to_phys(instance->tds));
     136        usb_log_debug("Batch(%p) %d:%d memory structures ready.\n",
     137            instance, target.address, target.endpoint);
    135138        return instance;
    136139}
     
    139142{
    140143        assert(instance);
    141         usb_log_debug("Checking(%p) %d packet for completion.\n",
     144        usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    142145            instance, instance->packets);
    143146        instance->transfered_size = 0;
     
    151154                        if (i > 0)
    152155                                instance->transfered_size -= instance->setup_size;
     156                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
     157                          instance, i, instance->tds[i].status);
    153158                        return true;
    154159                }
     
    156161                    transfer_descriptor_actual_size(&instance->tds[i]);
    157162        }
    158         /* This is just an ugly trick to support the old API */
    159163        instance->transfered_size -= instance->setup_size;
    160164        return true;
     
    168172        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    169173
     174        const bool low_speed = instance->speed == USB_SPEED_LOW;
    170175        int toggle = 0;
    171176        /* setup stage */
    172177        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    173             instance->setup_size, toggle, false, instance->target,
    174             USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
     178            instance->setup_size, toggle, false, low_speed,
     179            instance->target, USB_PID_SETUP, instance->setup_buffer,
     180            &instance->tds[1]);
    175181
    176182        /* data stage */
     
    182188
    183189                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    184                     instance->max_packet_size, toggle++, false, instance->target,
    185                     USB_PID_OUT, data, &instance->tds[i + 1]);
     190                    instance->max_packet_size, toggle++, false, low_speed,
     191                    instance->target, USB_PID_OUT, data, &instance->tds[i + 1]);
    186192        }
    187193
     
    189195        i = instance->packets - 1;
    190196        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    191             0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
     197            0, 1, false, low_speed, instance->target, USB_PID_IN, NULL, NULL);
    192198
    193199        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     200        usb_log_debug2("Control write last TD status: %x.\n",
     201                instance->tds[i].status);
    194202
    195203        instance->next_step = batch_call_out_and_dispose;
     204        usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance);
    196205        batch_schedule(instance);
    197206}
     
    201210        assert(instance);
    202211
     212        const bool low_speed = instance->speed == USB_SPEED_LOW;
    203213        int toggle = 0;
    204214        /* setup stage */
    205215        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    206             instance->setup_size, toggle, false, instance->target,
     216            instance->setup_size, toggle, false, low_speed, instance->target,
    207217            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    208218
     
    215225
    216226                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    217                     instance->max_packet_size, toggle, false, instance->target,
    218                     USB_PID_IN, data, &instance->tds[i + 1]);
     227                    instance->max_packet_size, toggle, false, low_speed,
     228                                instance->target, USB_PID_IN, data, &instance->tds[i + 1]);
    219229        }
    220230
     
    222232        i = instance->packets - 1;
    223233        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    224             0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
     234            0, 1, false, low_speed, instance->target, USB_PID_OUT, NULL, NULL);
    225235
    226236        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     237        usb_log_debug2("Control read last TD status: %x.\n",
     238                instance->tds[i].status);
    227239
    228240        instance->next_step = batch_call_in_and_dispose;
     241        usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance);
    229242        batch_schedule(instance);
    230243}
     
    234247        assert(instance);
    235248
     249        const bool low_speed = instance->speed == USB_SPEED_LOW;
    236250        int toggle = 1;
    237251        size_t i = 0;
     
    244258
    245259                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    246                     instance->max_packet_size, toggle, false, instance->target,
    247                     USB_PID_IN, data, next);
     260                    instance->max_packet_size, toggle, false, low_speed,
     261                    instance->target, USB_PID_IN, data, next);
    248262        }
    249263
     
    251265
    252266        instance->next_step = batch_call_in_and_dispose;
     267        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    253268        batch_schedule(instance);
    254269}
     
    260275        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    261276
     277        const bool low_speed = instance->speed == USB_SPEED_LOW;
    262278        int toggle = 1;
    263279        size_t i = 0;
     
    270286
    271287                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    272                     instance->max_packet_size, toggle++, false, instance->target,
    273                     USB_PID_OUT, data, next);
     288                    instance->max_packet_size, toggle++, false, low_speed,
     289                    instance->target, USB_PID_OUT, data, next);
    274290        }
    275291
     
    277293
    278294        instance->next_step = batch_call_out_and_dispose;
     295        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    279296        batch_schedule(instance);
    280297}
     
    288305
    289306        int err = instance->error;
    290         usb_log_info("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
    291             err, instance->transfered_size);
     307        usb_log_debug("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n",
     308            instance, instance->transfer_type, str_error(err), err,
     309            instance->transfered_size);
    292310
    293311        instance->callback_in(instance->fun,
     
    302320
    303321        int err = instance->error;
    304         usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
     322        usb_log_debug("Batch(%p) callback OUT(type:%d): %s(%d).\n",
     323            instance, instance->transfer_type, str_error(err), err);
    305324        instance->callback_out(instance->fun,
    306325            err, instance->arg);
     
    311330        assert(instance);
    312331        batch_call_in(instance);
    313         usb_log_debug("Disposing batch: %p.\n", instance);
     332        usb_log_debug("Batch(%p) disposing.\n", instance);
    314333        free32(instance->tds);
    315334        free32(instance->qh);
     
    323342        assert(instance);
    324343        batch_call_out(instance);
    325         usb_log_debug("Disposing batch: %p.\n", instance);
     344        usb_log_debug("Batch(%p) disposing.\n", instance);
    326345        free32(instance->tds);
    327346        free32(instance->qh);
     
    338357        return uhci_schedule(hc, instance);
    339358}
    340 /*----------------------------------------------------------------------------*/
    341 /* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
    342 void batch_control_setup_old(batch_t *instance)
    343 {
    344         assert(instance);
    345         instance->packets = 1;
    346 
    347         /* setup stage */
    348         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    349             instance->setup_size, 0, false, instance->target,
    350             USB_PID_SETUP, instance->setup_buffer, NULL);
    351 
    352         instance->next_step = batch_call_out_and_dispose;
    353         batch_schedule(instance);
    354 }
    355 /*----------------------------------------------------------------------------*/
    356 void batch_control_write_data_old(batch_t *instance)
    357 {
    358         assert(instance);
    359         instance->packets -= 2;
    360         batch_interrupt_out(instance);
    361 }
    362 /*----------------------------------------------------------------------------*/
    363 void batch_control_read_data_old(batch_t *instance)
    364 {
    365         assert(instance);
    366         instance->packets -= 2;
    367         batch_interrupt_in(instance);
    368 }
    369 /*----------------------------------------------------------------------------*/
    370 void batch_control_write_status_old(batch_t *instance)
    371 {
    372         assert(instance);
    373         instance->packets = 1;
    374         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    375             0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
    376         instance->next_step = batch_call_in_and_dispose;
    377         batch_schedule(instance);
    378 }
    379 /*----------------------------------------------------------------------------*/
    380 void batch_control_read_status_old(batch_t *instance)
    381 {
    382         assert(instance);
    383         instance->packets = 1;
    384         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    385             0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
    386         instance->next_step = batch_call_out_and_dispose;
    387         batch_schedule(instance);
    388 }
    389359/**
    390360 * @}
Note: See TracChangeset for help on using the changeset viewer.