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


Ignore:
Timestamp:
2011-03-05T00:44:27Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
00db345a, d20f211
Parents:
80fdffe (diff), eae83aa (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:

Refactoring and SPD support

File:
1 edited

Legend:

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

    r80fdffe r474d08e  
    4747static int batch_schedule(batch_t *instance);
    4848
    49 static void batch_control(
    50     batch_t *instance, int data_stage, int status_stage);
    51 static void batch_data(batch_t *instance, int pid);
     49static void batch_control(batch_t *instance,
     50    usb_packet_id data_stage, usb_packet_id status_stage);
     51static void batch_data(batch_t *instance, usb_packet_id pid);
    5252static void batch_call_in(batch_t *instance);
    5353static void batch_call_out(batch_t *instance);
     
    8484        }
    8585
    86         instance->tds = malloc32(sizeof(transfer_descriptor_t) * instance->packets);
     86        instance->tds = malloc32(sizeof(td_t) * instance->packets);
    8787        if (instance->tds == NULL) {
    8888                usb_log_error("Failed to allocate transfer descriptors.\n");
     
    9191                return NULL;
    9292        }
    93         bzero(instance->tds, sizeof(transfer_descriptor_t) * instance->packets);
     93        bzero(instance->tds, sizeof(td_t) * instance->packets);
    9494
    9595        const size_t transport_size = max_packet_size * instance->packets;
     
    152152        size_t i = 0;
    153153        for (;i < instance->packets; ++i) {
    154                 if (transfer_descriptor_is_active(&instance->tds[i])) {
     154                if (td_is_active(&instance->tds[i])) {
    155155                        return false;
    156156                }
    157                 instance->error = transfer_descriptor_status(&instance->tds[i]);
     157
     158                instance->error = td_status(&instance->tds[i]);
    158159                if (instance->error != EOK) {
     160                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
     161                            instance, i, instance->tds[i].status);
    159162                        if (i > 0)
    160                                 instance->transfered_size -= instance->setup_size;
    161                         usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    162                           instance, i, instance->tds[i].status);
     163                                goto substract_ret;
    163164                        return true;
    164165                }
    165                 instance->transfered_size +=
    166                     transfer_descriptor_actual_size(&instance->tds[i]);
    167         }
     166
     167                instance->transfered_size += td_act_size(&instance->tds[i]);
     168                if (td_is_short(&instance->tds[i]))
     169                        goto substract_ret;
     170        }
     171substract_ret:
    168172        instance->transfered_size -= instance->setup_size;
    169173        return true;
     
    228232}
    229233/*----------------------------------------------------------------------------*/
    230 static void batch_data(batch_t *instance, int pid)
     234static void batch_data(batch_t *instance, usb_packet_id pid)
    231235{
    232236        assert(instance);
     
    247251                    remain_size : instance->max_packet_size;
    248252
    249                 transfer_descriptor_init(&instance->tds[packet],
     253                td_init(&instance->tds[packet],
    250254                    DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed,
    251255                    instance->target, pid, data,
     
    262266}
    263267/*----------------------------------------------------------------------------*/
    264 static void batch_control(
    265     batch_t *instance, int data_stage, int status_stage)
     268static void batch_control(batch_t *instance,
     269   usb_packet_id data_stage, usb_packet_id status_stage)
    266270{
    267271        assert(instance);
     
    270274        int toggle = 0;
    271275        /* setup stage */
    272         transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
     276        td_init(instance->tds, DEFAULT_ERROR_COUNT,
    273277            instance->setup_size, toggle, false, low_speed, instance->target,
    274278            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
     
    288292                    remain_size : instance->max_packet_size;
    289293
    290                 transfer_descriptor_init(&instance->tds[packet],
     294                td_init(&instance->tds[packet],
    291295                    DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed,
    292296                    instance->target, data_stage, data,
     
    301305        /* status stage */
    302306        assert(packet == instance->packets - 1);
    303         transfer_descriptor_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,
     307        td_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,
    304308            0, 1, false, low_speed, instance->target, status_stage, NULL, NULL);
    305309
Note: See TracChangeset for help on using the changeset viewer.