Ignore:
File:
1 edited

Legend:

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

    r87644b4 r20a1e76  
    4848        qh_t *qh;
    4949        td_t *tds;
    50         size_t packets;
     50        size_t transfers;
    5151        usb_device_keeper_t *manager;
    5252} uhci_batch_t;
     
    6464 * @param[in] target Device and endpoint target of the transaction.
    6565 * @param[in] transfer_type Interrupt, Control or Bulk.
    66  * @param[in] max_packet_size maximum allowed size of data packets.
     66 * @param[in] max_packet_size maximum allowed size of data transfers.
    6767 * @param[in] speed Speed of the transaction.
    6868 * @param[in] buffer Data source/destination.
     
    7777 * NULL otherwise.
    7878 *
    79  * Determines the number of needed packets (TDs). Prepares a transport buffer
     79 * Determines the number of needed transfers (TDs). Prepares a transport buffer
    8080 * (that is accessible by the hardware). Initializes parameters needed for the
    8181 * transaction and callback.
     
    117117        instance->private_data = data;
    118118
    119         data->packets = (buffer_size + max_packet_size - 1) / max_packet_size;
     119        data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
    120120        if (transfer_type == USB_TRANSFER_CONTROL) {
    121                 data->packets += 2;
    122         }
    123 
    124         data->tds = malloc32(sizeof(td_t) * data->packets);
     121                data->transfers += 2;
     122        }
     123
     124        data->tds = malloc32(sizeof(td_t) * data->transfers);
    125125        CHECK_NULL_DISPOSE_RETURN(
    126126            data->tds, "Failed to allocate transfer descriptors.\n");
    127         bzero(data->tds, sizeof(td_t) * data->packets);
     127        bzero(data->tds, sizeof(td_t) * data->transfers);
    128128
    129129        data->qh = malloc32(sizeof(qh_t));
     
    166166        assert(data);
    167167
    168         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    169             instance, data->packets);
     168        usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
     169            instance, data->transfers);
    170170        instance->transfered_size = 0;
    171171        size_t i = 0;
    172         for (;i < data->packets; ++i) {
     172        for (;i < data->transfers; ++i) {
    173173                if (td_is_active(&data->tds[i])) {
    174174                        return false;
     
    298298 *
    299299 * @param[in] instance Batch structure to use.
    300  * @param[in] pid to use for data packets.
     300 * @param[in] pid Pid to use for data transfers.
    301301 *
    302302 * Packets with alternating toggle bit and supplied pid value.
    303  * The last packet is marked with IOC flag.
     303 * The last transfer is marked with IOC flag.
    304304 */
    305305void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid)
     
    314314        assert(toggle == 0 || toggle == 1);
    315315
    316         size_t packet = 0;
     316        size_t transfer = 0;
    317317        size_t remain_size = instance->buffer_size;
    318318        while (remain_size > 0) {
     
    325325                    remain_size : instance->max_packet_size;
    326326
    327                 td_t *next_packet = (packet + 1 < data->packets)
    328                     ? &data->tds[packet + 1] : NULL;
    329 
    330                 assert(packet < data->packets);
     327                td_t *next_transfer = (transfer + 1 < data->transfers)
     328                    ? &data->tds[transfer + 1] : NULL;
     329
     330                assert(transfer < data->transfers);
    331331                assert(packet_size <= remain_size);
    332332
    333333                td_init(
    334                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     334                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    335335                    toggle, false, low_speed, instance->target, pid, trans_data,
    336                     next_packet);
     336                    next_transfer);
    337337
    338338
    339339                toggle = 1 - toggle;
    340340                remain_size -= packet_size;
    341                 ++packet;
    342         }
    343         td_set_ioc(&data->tds[packet - 1]);
     341                ++transfer;
     342        }
     343        td_set_ioc(&data->tds[transfer - 1]);
    344344        usb_device_keeper_set_toggle(data->manager, instance->target,
    345345            instance->direction, toggle);
     
    349349 *
    350350 * @param[in] instance Batch structure to use.
    351  * @param[in] data_stage to use for data packets.
    352  * @param[in] status_stage to use for data packets.
     351 * @param[in] data_stage Pid to use for data transfers.
     352 * @param[in] status_stage Pid to use for data transfers.
    353353 *
    354354 * Setup stage with toggle 0 and USB_PID_SETUP.
    355355 * Data stage with alternating toggle and pid supplied by parameter.
    356356 * Status stage with toggle 1 and pid supplied by parameter.
    357  * The last packet is marked with IOC.
     357 * The last transfer is marked with IOC.
    358358 */
    359359void batch_control(usb_transfer_batch_t *instance,
     
    363363        uhci_batch_t *data = instance->private_data;
    364364        assert(data);
    365         assert(data->packets >= 2);
     365        assert(data->transfers >= 2);
    366366
    367367        const bool low_speed = instance->speed == USB_SPEED_LOW;
     
    374374
    375375        /* data stage */
    376         size_t packet = 1;
     376        size_t transfer = 1;
    377377        size_t remain_size = instance->buffer_size;
    378378        while (remain_size > 0) {
     
    388388
    389389                td_init(
    390                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     390                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    391391                    toggle, false, low_speed, instance->target, data_stage,
    392                     control_data, &data->tds[packet + 1]);
    393 
    394                 ++packet;
    395                 assert(packet < data->packets);
     392                    control_data, &data->tds[transfer + 1]);
     393
     394                ++transfer;
     395                assert(transfer < data->transfers);
    396396                assert(packet_size <= remain_size);
    397397                remain_size -= packet_size;
     
    399399
    400400        /* status stage */
    401         assert(packet == data->packets - 1);
     401        assert(transfer == data->transfers - 1);
    402402
    403403        td_init(
    404             &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     404            &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    405405            instance->target, status_stage, NULL, NULL);
    406         td_set_ioc(&data->tds[packet]);
     406        td_set_ioc(&data->tds[transfer]);
    407407
    408408        usb_log_debug2("Control last TD status: %x.\n",
    409             data->tds[packet].status);
     409            data->tds[transfer].status);
    410410}
    411411/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.