Changeset d017cea in mainline


Ignore:
Timestamp:
2011-04-12T10:09:56Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
508a0ca
Parents:
f13381b
Message:

Remove EP information stored in usb_transfer_batch_t

rename usb_transfer_batch_t.transport_buffer ⇒ data_buffer

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/batch.c

    rf13381b rd017cea  
    7373        CHECK_NULL_DISPOSE_RETURN(instance,
    7474            "Failed to allocate batch instance.\n");
    75         usb_target_t target =
    76             { .address = ep->address, .endpoint = ep->endpoint };
    77         usb_transfer_batch_init(instance, target, ep->transfer_type, ep->speed,
    78             ep->max_packet_size, buffer, NULL, buffer_size, NULL, setup_size,
    79             func_in, func_out, arg, fun, ep, NULL);
     75        usb_transfer_batch_init(instance, ep, buffer, NULL, buffer_size,
     76            NULL, setup_size, func_in, func_out, arg, fun, NULL);
    8077
    8178        ohci_batch_t *data = malloc(sizeof(ohci_batch_t));
     
    10198
    10299        if (buffer_size > 0) {
    103                 instance->transport_buffer = malloc32(buffer_size);
    104                 CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer,
     100                instance->data_buffer = malloc32(buffer_size);
     101                CHECK_NULL_DISPOSE_RETURN(instance->data_buffer,
    105102                    "Failed to allocate device accessible buffer.\n");
    106103        }
     
    124121        free32(data->tds);
    125122        free32(instance->setup_buffer);
    126         free32(instance->transport_buffer);
     123        free32(instance->data_buffer);
    127124        free(data);
    128125        free(instance);
     
    165162        assert(instance);
    166163        /* We are data out, we are supposed to provide data */
    167         memcpy(instance->transport_buffer, instance->buffer,
    168             instance->buffer_size);
     164        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
    169165        instance->next_step = batch_call_out_and_dispose;
    170166        batch_control(instance, USB_DIRECTION_OUT, USB_DIRECTION_IN);
     
    183179{
    184180        assert(instance);
    185         assert(instance->direction == USB_DIRECTION_IN);
    186181        instance->next_step = batch_call_in_and_dispose;
    187182        batch_data(instance);
     
    192187{
    193188        assert(instance);
    194         assert(instance->direction == USB_DIRECTION_OUT);
    195189        /* We are data out, we are supposed to provide data */
    196         memcpy(instance->transport_buffer, instance->buffer,
    197             instance->buffer_size);
     190        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
    198191        instance->next_step = batch_call_out_and_dispose;
    199192        batch_data(instance);
     
    204197{
    205198        assert(instance);
    206         instance->direction = USB_DIRECTION_IN;
    207199        instance->next_step = batch_call_in_and_dispose;
    208200        batch_data(instance);
     
    213205{
    214206        assert(instance);
    215         instance->direction = USB_DIRECTION_IN;
    216207        instance->next_step = batch_call_in_and_dispose;
    217208        batch_data(instance);
     
    249240        size_t td_current = 1;
    250241        size_t remain_size = instance->buffer_size;
    251         char *transfer_buffer = instance->transport_buffer;
     242        char *buffer = instance->data_buffer;
    252243        while (remain_size > 0) {
    253244                size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ?
     
    255246                toggle = 1 - toggle;
    256247
    257                 td_init(&data->tds[td_current], data_dir, transfer_buffer,
     248                td_init(&data->tds[td_current], data_dir, buffer,
    258249                    transfer_size, toggle);
    259250                td_set_next(&data->tds[td_current], &data->tds[td_current + 1]);
     
    262253                    data->tds[td_current].next, data->tds[td_current].be);
    263254
    264                 transfer_buffer += transfer_size;
     255                buffer += transfer_size;
    265256                remain_size -= transfer_size;
    266257                assert(td_current < data->td_count - 2);
     
    290281        size_t td_current = 0;
    291282        size_t remain_size = instance->buffer_size;
    292         char *transfer_buffer = instance->transport_buffer;
     283        char *buffer = instance->data_buffer;
    293284        while (remain_size > 0) {
    294285                size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ?
     
    296287
    297288                td_init(&data->tds[td_current], instance->ep->direction,
    298                     transfer_buffer, transfer_size, -1);
     289                    buffer, transfer_size, -1);
    299290                td_set_next(&data->tds[td_current], &data->tds[td_current + 1]);
    300291                usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n",
     
    302293                    data->tds[td_current].next, data->tds[td_current].be);
    303294
    304                 transfer_buffer += transfer_size;
     295                buffer += transfer_size;
    305296                remain_size -= transfer_size;
    306297                assert(td_current < data->td_count);
  • uspace/drv/ohci/hc.c

    rf13381b rd017cea  
    130130        assert(instance);
    131131        assert(batch);
     132        assert(batch->ep);
    132133
    133134        /* check for root hub communication */
    134         if (batch->target.address == instance->rh.address) {
     135        if (batch->ep->address == instance->rh.address) {
    135136                return rh_request(&instance->rh, batch);
    136137        }
    137138
    138139        fibril_mutex_lock(&instance->guard);
    139         switch (batch->transfer_type) {
     140        switch (batch->ep->transfer_type) {
    140141        case USB_TRANSFER_CONTROL:
    141142                instance->registers->control &= ~C_CLE;
    142143                transfer_list_add_batch(
    143                     instance->transfers[batch->transfer_type], batch);
     144                    instance->transfers[batch->ep->transfer_type], batch);
    144145                instance->registers->command_status |= CS_CLF;
    145146                usb_log_debug2("Set CS control transfer filled: %x.\n",
     
    151152                instance->registers->control &= ~C_BLE;
    152153                transfer_list_add_batch(
    153                     instance->transfers[batch->transfer_type], batch);
     154                    instance->transfers[batch->ep->transfer_type], batch);
    154155                instance->registers->command_status |= CS_BLF;
    155156                usb_log_debug2("Set bulk transfer filled: %x.\n",
     
    161162                instance->registers->control &= (~C_PLE & ~C_IE);
    162163                transfer_list_add_batch(
    163                     instance->transfers[batch->transfer_type], batch);
     164                    instance->transfers[batch->ep->transfer_type], batch);
    164165                instance->registers->control |= C_PLE | C_IE;
    165166                usb_log_debug2("Added periodic transfer: %x.\n",
  • uspace/drv/ohci/root_hub.c

    rf13381b rd017cea  
    237237        assert(request);
    238238        int opResult;
    239         if (request->transfer_type == USB_TRANSFER_CONTROL) {
     239        if (request->ep->transfer_type == USB_TRANSFER_CONTROL) {
    240240                usb_log_info("Root hub got CONTROL packet\n");
    241241                opResult = process_ctrl_request(instance, request);
    242         } else if (request->transfer_type == USB_TRANSFER_INTERRUPT) {
     242        } else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) {
    243243                usb_log_info("Root hub got INTERRUPT packet\n");
    244244                void * buffer;
    245245                create_interrupt_mask(instance, &buffer,
    246246                        &(request->transfered_size));
    247                 memcpy(request->transport_buffer, buffer,
     247                memcpy(request->data_buffer, buffer,
    248248                        request->transfered_size);
    249249                opResult = EOK;
     
    374374        if (port < 1 || port > instance->port_count)
    375375                return EINVAL;
    376         uint32_t * uint32_buffer = (uint32_t*) request->transport_buffer;
     376        uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    377377        request->transfered_size = 4;
    378378        uint32_buffer[0] = instance->registers->rh_port_status[port - 1];
     
    400400static int process_get_hub_status_request(rh_t *instance,
    401401        usb_transfer_batch_t * request) {
    402         uint32_t * uint32_buffer = (uint32_t*) request->transport_buffer;
     402        uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    403403        request->transfered_size = 4;
    404404        //bits, 0,1,16,17
     
    550550        }
    551551        request->transfered_size = size;
    552         memcpy(request->transport_buffer, result_descriptor, size);
     552        memcpy(request->data_buffer, result_descriptor, size);
    553553        if (del)
    554554                free(result_descriptor);
     
    571571        if (request->buffer_size != 1)
    572572                return EINVAL;
    573         request->transport_buffer[0] = 1;
     573        request->data_buffer[0] = 1;
    574574        request->transfered_size = 1;
    575575        return EOK;
  • uspace/drv/uhci-hcd/batch.c

    rf13381b rd017cea  
    103103        usb_target_t target =
    104104            { .address = ep->address, .endpoint = ep->endpoint };
    105         usb_transfer_batch_init(instance, target, ep->transfer_type, ep->speed,
    106             ep->max_packet_size, buffer, NULL, buffer_size, NULL, setup_size,
    107             func_in, func_out, arg, fun, ep, NULL);
     105        usb_transfer_batch_init(instance, ep,
     106            buffer, NULL, buffer_size, NULL, setup_size,
     107            func_in, func_out, arg, fun, NULL);
    108108
    109109
     
    131131
    132132        if (buffer_size > 0) {
    133                 instance->transport_buffer = malloc32(buffer_size);
    134                 CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer,
     133                instance->data_buffer = malloc32(buffer_size);
     134                CHECK_NULL_DISPOSE_RETURN(instance->data_buffer,
    135135                    "Failed to allocate device accessible buffer.\n");
    136136        }
     
    205205        assert(instance);
    206206        /* We are data out, we are supposed to provide data */
    207         memcpy(instance->transport_buffer, instance->buffer,
    208             instance->buffer_size);
     207        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
    209208        batch_control(instance, USB_PID_OUT, USB_PID_IN);
    210209        instance->next_step = batch_call_out_and_dispose;
     
    235234{
    236235        assert(instance);
    237         instance->direction = USB_DIRECTION_IN;
     236//      instance->direction = USB_DIRECTION_IN;
    238237        batch_data(instance, USB_PID_IN);
    239238        instance->next_step = batch_call_in_and_dispose;
     
    250249{
    251250        assert(instance);
    252         instance->direction = USB_DIRECTION_OUT;
    253251        /* We are data out, we are supposed to provide data */
    254         memcpy(instance->transport_buffer, instance->buffer,
    255             instance->buffer_size);
     252        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
    256253        batch_data(instance, USB_PID_OUT);
    257254        instance->next_step = batch_call_out_and_dispose;
     
    269266        assert(instance);
    270267        batch_data(instance, USB_PID_IN);
    271         instance->direction = USB_DIRECTION_IN;
    272268        instance->next_step = batch_call_in_and_dispose;
    273269        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
     
    283279{
    284280        assert(instance);
    285         instance->direction = USB_DIRECTION_OUT;
    286281        /* We are data out, we are supposed to provide data */
    287         memcpy(instance->transport_buffer, instance->buffer,
     282        memcpy(instance->data_buffer, instance->buffer,
    288283            instance->buffer_size);
    289284        batch_data(instance, USB_PID_OUT);
     
    306301        assert(data);
    307302
    308         const bool low_speed = instance->speed == USB_SPEED_LOW;
     303        const bool low_speed = instance->ep->speed == USB_SPEED_LOW;
    309304        int toggle = endpoint_toggle_get(instance->ep);
    310305        assert(toggle == 0 || toggle == 1);
     
    314309        while (remain_size > 0) {
    315310                char *trans_data =
    316                     instance->transport_buffer + instance->buffer_size
     311                    instance->data_buffer + instance->buffer_size
    317312                    - remain_size;
    318313
    319314                const size_t packet_size =
    320                     (instance->max_packet_size > remain_size) ?
    321                     remain_size : instance->max_packet_size;
     315                    (instance->ep->max_packet_size > remain_size) ?
     316                    remain_size : instance->ep->max_packet_size;
    322317
    323318                td_t *next_transfer = (transfer + 1 < data->transfers)
     
    326321                assert(transfer < data->transfers);
    327322                assert(packet_size <= remain_size);
     323                usb_target_t target =
     324                    { instance->ep->address, instance->ep->endpoint };
    328325
    329326                td_init(
    330327                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    331                     toggle, false, low_speed, instance->target, pid, trans_data,
     328                    toggle, false, low_speed, target, pid, trans_data,
    332329                    next_transfer);
    333330
     
    360357        assert(data->transfers >= 2);
    361358
    362         const bool low_speed = instance->speed == USB_SPEED_LOW;
     359        const bool low_speed = instance->ep->speed == USB_SPEED_LOW;
    363360        int toggle = 0;
     361        const usb_target_t target =
     362            { instance->ep->address, instance->ep->endpoint };
     363
    364364        /* setup stage */
    365365        td_init(
    366366            data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, toggle, false,
    367             low_speed, instance->target, USB_PID_SETUP, instance->setup_buffer,
     367            low_speed, target, USB_PID_SETUP, instance->setup_buffer,
    368368            &data->tds[1]);
    369369
     
    373373        while (remain_size > 0) {
    374374                char *control_data =
    375                     instance->transport_buffer + instance->buffer_size
     375                    instance->data_buffer + instance->buffer_size
    376376                    - remain_size;
    377377
     
    379379
    380380                const size_t packet_size =
    381                     (instance->max_packet_size > remain_size) ?
    382                     remain_size : instance->max_packet_size;
     381                    (instance->ep->max_packet_size > remain_size) ?
     382                    remain_size : instance->ep->max_packet_size;
    383383
    384384                td_init(
    385385                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    386                     toggle, false, low_speed, instance->target, data_stage,
     386                    toggle, false, low_speed, target, data_stage,
    387387                    control_data, &data->tds[transfer + 1]);
    388388
     
    398398        td_init(
    399399            &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    400             instance->target, status_stage, NULL, NULL);
     400            target, status_stage, NULL, NULL);
    401401        td_set_ioc(&data->tds[transfer]);
    402402
     
    449449        free32(data->qh);
    450450        free32(instance->setup_buffer);
    451         free32(instance->transport_buffer);
     451        free32(instance->data_buffer);
    452452        free(data);
    453453        free(instance);
  • uspace/drv/uhci-hcd/hc.c

    rf13381b rd017cea  
    329329
    330330        transfer_list_t *list =
    331             instance->transfers[batch->speed][batch->transfer_type];
     331            instance->transfers[batch->ep->speed][batch->ep->transfer_type];
    332332        assert(list);
    333333        transfer_list_add_batch(list, batch);
  • uspace/lib/usb/include/usb/host/batch.h

    rf13381b rd017cea  
    4343typedef struct usb_transfer_batch usb_transfer_batch_t;
    4444struct usb_transfer_batch {
     45        endpoint_t *ep;
    4546        link_t link;
    46         usb_target_t target;
    47         usb_transfer_type_t transfer_type;
    48         usb_speed_t speed;
    49         usb_direction_t direction;
    5047        usbhc_iface_transfer_in_callback_t callback_in;
    5148        usbhc_iface_transfer_out_callback_t callback_out;
     49        void *arg;
    5250        char *buffer;
    53         char *transport_buffer;
     51        char *data_buffer;
    5452        size_t buffer_size;
    5553        char *setup_buffer;
    5654        size_t setup_size;
    57         size_t max_packet_size;
    5855        size_t transfered_size;
    5956        void (*next_step)(usb_transfer_batch_t *);
    6057        int error;
    6158        ddf_fun_t *fun;
    62         void *arg;
    63         endpoint_t *ep;
    6459        void *private_data;
    6560};
     
    6762void usb_transfer_batch_init(
    6863    usb_transfer_batch_t *instance,
    69     usb_target_t target,
    70     usb_transfer_type_t transfer_type,
    71     usb_speed_t speed,
    72     size_t max_packet_size,
     64                endpoint_t *ep,
    7365    char *buffer,
    74     char *transport_buffer,
     66    char *data_buffer,
    7567    size_t buffer_size,
    7668    char *setup_buffer,
     
    8072    void *arg,
    8173    ddf_fun_t *fun,
    82                 endpoint_t *ep,
    8374    void *private_data
    8475);
  • uspace/lib/usb/src/host/batch.c

    rf13381b rd017cea  
    4141void usb_transfer_batch_init(
    4242    usb_transfer_batch_t *instance,
    43     usb_target_t target,
    44     usb_transfer_type_t transfer_type,
    45     usb_speed_t speed,
    46     size_t max_packet_size,
     43                endpoint_t *ep,
    4744    char *buffer,
    48     char *transport_buffer,
     45    char *data_buffer,
    4946    size_t buffer_size,
    5047    char *setup_buffer,
     
    5451    void *arg,
    5552    ddf_fun_t *fun,
    56                 endpoint_t *ep,
    5753    void *private_data
    5854    )
     
    6056        assert(instance);
    6157        link_initialize(&instance->link);
    62         instance->target = target;
    63         instance->transfer_type = transfer_type;
    64         instance->speed = speed;
    65         instance->direction = ep->direction;
     58        instance->ep = ep;
    6659        instance->callback_in = func_in;
    6760        instance->callback_out = func_out;
    6861        instance->arg = arg;
    6962        instance->buffer = buffer;
    70         instance->transport_buffer = transport_buffer;
     63        instance->data_buffer = data_buffer;
    7164        instance->buffer_size = buffer_size;
    7265        instance->setup_buffer = setup_buffer;
    7366        instance->setup_size = setup_size;
    74         instance->max_packet_size = max_packet_size;
    7567        instance->fun = fun;
    7668        instance->private_data = private_data;
     
    7870        instance->next_step = NULL;
    7971        instance->error = EOK;
    80         instance->ep = ep;
    8172        endpoint_use(instance->ep);
    8273}
     
    10596        assert(instance);
    10697        assert(instance->callback_in);
     98        assert(instance->ep);
    10799
    108100        /* We are data in, we need data */
    109         memcpy(instance->buffer, instance->transport_buffer,
    110             instance->buffer_size);
     101        memcpy(instance->buffer, instance->data_buffer, instance->buffer_size);
    111102
    112103        usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n",
    113             instance,
    114             instance->target.address, instance->target.endpoint,
    115             usb_str_speed(instance->speed),
    116             usb_str_transfer_type_short(instance->transfer_type),
    117             instance->transfered_size,
    118             str_error(instance->error), instance->error);
     104            instance, instance->ep->address, instance->ep->endpoint,
     105            usb_str_speed(instance->ep->speed),
     106            usb_str_transfer_type_short(instance->ep->transfer_type),
     107            instance->transfered_size, str_error(instance->error), instance->error);
    119108
    120109        instance->callback_in(instance->fun, instance->error,
     
    132121
    133122        usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n",
    134             instance,
    135             instance->target.address, instance->target.endpoint,
    136             usb_str_speed(instance->speed),
    137             usb_str_transfer_type_short(instance->transfer_type),
     123            instance, instance->ep->address, instance->ep->endpoint,
     124            usb_str_speed(instance->ep->speed),
     125            usb_str_transfer_type_short(instance->ep->transfer_type),
    138126            str_error(instance->error), instance->error);
    139127
Note: See TracChangeset for help on using the changeset viewer.