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


Ignore:
Timestamp:
2011-03-25T16:22:14Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da3dafc, e6223239
Parents:
d8421c4 (diff), f08c560 (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:

merge from development

File:
1 edited

Legend:

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

    rd8421c4 rf97717d9  
    4040#include "batch.h"
    4141#include "transfer_list.h"
    42 #include "uhci_hc.h"
     42#include "hw_struct/transfer_descriptor.h"
    4343#include "utils/malloc32.h"
    44 #include "uhci_struct/transfer_descriptor.h"
    4544
    4645#define DEFAULT_ERROR_COUNT 3
     
    4948        qh_t *qh;
    5049        td_t *tds;
    51         size_t packets;
     50        size_t transfers;
    5251        usb_device_keeper_t *manager;
    5352} uhci_batch_t;
     
    6564 * @param[in] target Device and endpoint target of the transaction.
    6665 * @param[in] transfer_type Interrupt, Control or Bulk.
    67  * @param[in] max_packet_size maximum allowed size of data packets.
     66 * @param[in] max_packet_size maximum allowed size of data transfers.
    6867 * @param[in] speed Speed of the transaction.
    6968 * @param[in] buffer Data source/destination.
     
    7877 * NULL otherwise.
    7978 *
    80  * Determines the number of needed packets (TDs). Prepares a transport buffer
     79 * Determines the number of needed transfers (TDs). Prepares a transport buffer
    8180 * (that is accessible by the hardware). Initializes parameters needed for the
    8281 * transaction and callback.
     
    118117        instance->private_data = data;
    119118
    120         data->packets = (buffer_size + max_packet_size - 1) / max_packet_size;
     119        data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
    121120        if (transfer_type == USB_TRANSFER_CONTROL) {
    122                 data->packets += 2;
    123         }
    124 
    125         data->tds = malloc32(sizeof(td_t) * data->packets);
     121                data->transfers += 2;
     122        }
     123
     124        data->tds = malloc32(sizeof(td_t) * data->transfers);
    126125        CHECK_NULL_DISPOSE_RETURN(
    127126            data->tds, "Failed to allocate transfer descriptors.\n");
    128         bzero(data->tds, sizeof(td_t) * data->packets);
     127        bzero(data->tds, sizeof(td_t) * data->transfers);
    129128
    130129        data->qh = malloc32(sizeof(qh_t));
     
    167166        assert(data);
    168167
    169         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    170             instance, data->packets);
     168        usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
     169            instance, data->transfers);
    171170        instance->transfered_size = 0;
    172171        size_t i = 0;
    173         for (;i < data->packets; ++i) {
     172        for (;i < data->transfers; ++i) {
    174173                if (td_is_active(&data->tds[i])) {
    175174                        return false;
     
    299298 *
    300299 * @param[in] instance Batch structure to use.
    301  * @param[in] pid to use for data packets.
     300 * @param[in] pid Pid to use for data transfers.
    302301 *
    303302 * Packets with alternating toggle bit and supplied pid value.
    304  * The last packet is marked with IOC flag.
     303 * The last transfer is marked with IOC flag.
    305304 */
    306305void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid)
     
    315314        assert(toggle == 0 || toggle == 1);
    316315
    317         size_t packet = 0;
     316        size_t transfer = 0;
    318317        size_t remain_size = instance->buffer_size;
    319318        while (remain_size > 0) {
     
    326325                    remain_size : instance->max_packet_size;
    327326
    328                 td_t *next_packet = (packet + 1 < data->packets)
    329                     ? &data->tds[packet + 1] : NULL;
    330 
    331                 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);
    332331                assert(packet_size <= remain_size);
    333332
    334333                td_init(
    335                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     334                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    336335                    toggle, false, low_speed, instance->target, pid, trans_data,
    337                     next_packet);
     336                    next_transfer);
    338337
    339338
    340339                toggle = 1 - toggle;
    341340                remain_size -= packet_size;
    342                 ++packet;
    343         }
    344         td_set_ioc(&data->tds[packet - 1]);
     341                ++transfer;
     342        }
     343        td_set_ioc(&data->tds[transfer - 1]);
    345344        usb_device_keeper_set_toggle(data->manager, instance->target,
    346345            instance->direction, toggle);
     
    350349 *
    351350 * @param[in] instance Batch structure to use.
    352  * @param[in] data_stage to use for data packets.
    353  * @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.
    354353 *
    355354 * Setup stage with toggle 0 and USB_PID_SETUP.
    356355 * Data stage with alternating toggle and pid supplied by parameter.
    357356 * Status stage with toggle 1 and pid supplied by parameter.
    358  * The last packet is marked with IOC.
     357 * The last transfer is marked with IOC.
    359358 */
    360359void batch_control(usb_transfer_batch_t *instance,
     
    364363        uhci_batch_t *data = instance->private_data;
    365364        assert(data);
    366         assert(data->packets >= 2);
     365        assert(data->transfers >= 2);
    367366
    368367        const bool low_speed = instance->speed == USB_SPEED_LOW;
     
    375374
    376375        /* data stage */
    377         size_t packet = 1;
     376        size_t transfer = 1;
    378377        size_t remain_size = instance->buffer_size;
    379378        while (remain_size > 0) {
     
    389388
    390389                td_init(
    391                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     390                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    392391                    toggle, false, low_speed, instance->target, data_stage,
    393                     control_data, &data->tds[packet + 1]);
    394 
    395                 ++packet;
    396                 assert(packet < data->packets);
     392                    control_data, &data->tds[transfer + 1]);
     393
     394                ++transfer;
     395                assert(transfer < data->transfers);
    397396                assert(packet_size <= remain_size);
    398397                remain_size -= packet_size;
     
    400399
    401400        /* status stage */
    402         assert(packet == data->packets - 1);
     401        assert(transfer == data->transfers - 1);
    403402
    404403        td_init(
    405             &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     404            &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    406405            instance->target, status_stage, NULL, NULL);
    407         td_set_ioc(&data->tds[packet]);
     406        td_set_ioc(&data->tds[transfer]);
    408407
    409408        usb_log_debug2("Control last TD status: %x.\n",
    410             data->tds[packet].status);
     409            data->tds[transfer].status);
    411410}
    412411/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.