Changeset 910ca3f in mainline


Ignore:
Timestamp:
2011-04-12T11:43:23Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2cc6e97, 4deca9b
Parents:
c4e3b1f7
Message:

Refactoring, doxygen fixes

File:
1 edited

Legend:

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

    rc4e3b1f7 r910ca3f  
    3030 */
    3131/** @file
    32  * @brief UHCI driver USB transaction structure
     32 * @brief UHCI driver USB transfer structure
    3333 */
    3434#include <errno.h>
     
    6161 *
    6262 * @param[in] fun DDF function to pass to callback.
    63  * @param[in] target Device and endpoint target of the transaction.
    64  * @param[in] transfer_type Interrupt, Control or Bulk.
    65  * @param[in] max_packet_size maximum allowed size of data transactions.
    66  * @param[in] speed Speed of the transaction.
     63 * @param[in] ep Communication target
    6764 * @param[in] buffer Data source/destination.
    6865 * @param[in] size Size of the buffer.
    6966 * @param[in] setup_buffer Setup data source (if not NULL)
    7067 * @param[in] setup_size Size of setup_buffer (should be always 8)
    71  * @param[in] func_in function to call on inbound transaction completion
    72  * @param[in] func_out function to call on outbound transaction completion
     68 * @param[in] func_in function to call on inbound transfer completion
     69 * @param[in] func_out function to call on outbound transfer completion
    7370 * @param[in] arg additional parameter to func_in or func_out
    74  * @param[in] ep Pointer to endpoint toggle management structure.
    7571 * @return Valid pointer if all substructures were successfully created,
    7672 * NULL otherwise.
     
    7874 * Determines the number of needed transfer descriptors (TDs).
    7975 * Prepares a transport buffer (that is accessible by the hardware).
    80  * Initializes parameters needed for the transaction and callback.
     76 * Initializes parameters needed for the transfer and callback.
    8177 */
    8278usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
     
    154150 *
    155151 * Walk all TDs. Stop with false if there is an active one (it is to be
    156  * processed). Stop with true if an error is found. Return true if the last TS
     152 * processed). Stop with true if an error is found. Return true if the last TD
    157153 * is reached.
    158154 */
     
    177173                            instance, i, data->tds[i].status);
    178174                        td_print_status(&data->tds[i]);
     175
    179176                        assert(instance->ep != NULL);
    180 
    181177                        endpoint_toggle_set(instance->ep,
    182178                            td_toggle(&data->tds[i]));
     
    195191}
    196192/*----------------------------------------------------------------------------*/
    197 /** Prepares control write transaction.
    198  *
    199  * @param[in] instance Batch structure to use.
    200  *
    201  * Uses genercir control function with pids OUT and IN.
     193/** Prepares control write transfer.
     194 *
     195 * @param[in] instance Batch structure to use.
     196 *
     197 * Uses generic control function with pids OUT and IN.
    202198 */
    203199void batch_control_write(usb_transfer_batch_t *instance)
     
    211207}
    212208/*----------------------------------------------------------------------------*/
    213 /** Prepares control read transaction.
     209/** Prepares control read transfer.
    214210 *
    215211 * @param[in] instance Batch structure to use.
     
    225221}
    226222/*----------------------------------------------------------------------------*/
    227 /** Prepare interrupt in transaction.
    228  *
    229  * @param[in] instance Batch structure to use.
    230  *
    231  * Data transaction with PID_IN.
     223/** Prepare interrupt in transfer.
     224 *
     225 * @param[in] instance Batch structure to use.
     226 *
     227 * Data transfer with PID_IN.
    232228 */
    233229void batch_interrupt_in(usb_transfer_batch_t *instance)
    234230{
    235231        assert(instance);
    236 //      instance->direction = USB_DIRECTION_IN;
    237232        batch_data(instance, USB_PID_IN);
    238233        instance->next_step = batch_call_in_and_dispose;
     
    240235}
    241236/*----------------------------------------------------------------------------*/
    242 /** Prepare interrupt out transaction.
    243  *
    244  * @param[in] instance Batch structure to use.
    245  *
    246  * Data transaction with PID_OUT.
     237/** Prepare interrupt out transfer.
     238 *
     239 * @param[in] instance Batch structure to use.
     240 *
     241 * Data transfer with PID_OUT.
    247242 */
    248243void batch_interrupt_out(usb_transfer_batch_t *instance)
     
    256251}
    257252/*----------------------------------------------------------------------------*/
    258 /** Prepare bulk in transaction.
    259  *
    260  * @param[in] instance Batch structure to use.
    261  *
    262  * Data transaction with PID_IN.
     253/** Prepare bulk in transfer.
     254 *
     255 * @param[in] instance Batch structure to use.
     256 *
     257 * Data transfer with PID_IN.
    263258 */
    264259void batch_bulk_in(usb_transfer_batch_t *instance)
     
    270265}
    271266/*----------------------------------------------------------------------------*/
    272 /** Prepare bulk out transaction.
    273  *
    274  * @param[in] instance Batch structure to use.
    275  *
    276  * Data transaction with PID_OUT.
     267/** Prepare bulk out transfer.
     268 *
     269 * @param[in] instance Batch structure to use.
     270 *
     271 * Data transfer with PID_OUT.
    277272 */
    278273void batch_bulk_out(usb_transfer_batch_t *instance)
     
    280275        assert(instance);
    281276        /* We are data out, we are supposed to provide data */
    282         memcpy(instance->data_buffer, instance->buffer,
    283             instance->buffer_size);
     277        memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
    284278        batch_data(instance, USB_PID_OUT);
    285279        instance->next_step = batch_call_out_and_dispose;
     
    287281}
    288282/*----------------------------------------------------------------------------*/
    289 /** Prepare generic data transaction
     283/** Prepare generic data transfer
    290284 *
    291285 * @param[in] instance Batch structure to use.
    292286 * @param[in] pid Pid to use for data transactions.
    293287 *
    294  * Packets with alternating toggle bit and supplied pid value.
     288 * Transactions with alternating toggle bit and supplied pid value.
    295289 * The last transfer is marked with IOC flag.
    296290 */
     
    307301        size_t td = 0;
    308302        size_t remain_size = instance->buffer_size;
     303        char *buffer = instance->data_buffer;
    309304        while (remain_size > 0) {
    310                 char *trans_data =
    311                     instance->data_buffer + instance->buffer_size
    312                     - remain_size;
    313 
    314305                const size_t packet_size =
    315306                    (instance->ep->max_packet_size > remain_size) ?
     
    319310                    ? &data->tds[td + 1] : NULL;
    320311
    321                 assert(td < data->td_count);
    322                 assert(packet_size <= remain_size);
     312
    323313                usb_target_t target =
    324314                    { instance->ep->address, instance->ep->endpoint };
    325315
     316                assert(td < data->td_count);
    326317                td_init(
    327318                    &data->tds[td], DEFAULT_ERROR_COUNT, packet_size,
    328                     toggle, false, low_speed, target, pid, trans_data, next_td);
    329 
    330 
     319                    toggle, false, low_speed, target, pid, buffer, next_td);
     320
     321                ++td;
    331322                toggle = 1 - toggle;
     323                buffer += packet_size;
     324                assert(packet_size <= remain_size);
    332325                remain_size -= packet_size;
    333                 ++td;
    334326        }
    335327        td_set_ioc(&data->tds[td - 1]);
     
    337329}
    338330/*----------------------------------------------------------------------------*/
    339 /** Prepare generic control transaction
     331/** Prepare generic control transfer
    340332 *
    341333 * @param[in] instance Batch structure to use.
     
    357349
    358350        const bool low_speed = instance->ep->speed == USB_SPEED_LOW;
    359         int toggle = 0;
    360351        const usb_target_t target =
    361352            { instance->ep->address, instance->ep->endpoint };
     
    363354        /* setup stage */
    364355        td_init(
    365             data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, toggle, false,
     356            data->tds, DEFAULT_ERROR_COUNT, instance->setup_size, 0, false,
    366357            low_speed, target, USB_PID_SETUP, instance->setup_buffer,
    367358            &data->tds[1]);
     
    369360        /* data stage */
    370361        size_t td = 1;
     362        unsigned toggle = 1;
    371363        size_t remain_size = instance->buffer_size;
     364        char *buffer = instance->data_buffer;
    372365        while (remain_size > 0) {
    373                 char *control_data =
    374                     instance->data_buffer + instance->buffer_size
    375                     - remain_size;
    376 
    377                 toggle = 1 - toggle;
    378 
    379366                const size_t packet_size =
    380367                    (instance->ep->max_packet_size > remain_size) ?
     
    384371                    &data->tds[td], DEFAULT_ERROR_COUNT, packet_size,
    385372                    toggle, false, low_speed, target, data_stage,
    386                     control_data, &data->tds[td + 1]);
     373                    buffer, &data->tds[td + 1]);
    387374
    388375                ++td;
     376                toggle = 1 - toggle;
     377                buffer += packet_size;
    389378                assert(td < data->td_count);
    390379                assert(packet_size <= remain_size);
     
    412401}
    413402/*----------------------------------------------------------------------------*/
    414 /** Helper function calls callback and correctly disposes of batch structure.
     403/** Helper function, calls callback and correctly destroys batch structure.
    415404 *
    416405 * @param[in] instance Batch structure to use.
     
    423412}
    424413/*----------------------------------------------------------------------------*/
    425 /** Helper function calls callback and correctly disposes of batch structure.
     414/** Helper function calls callback and correctly destroys batch structure.
    426415 *
    427416 * @param[in] instance Batch structure to use.
Note: See TracChangeset for help on using the changeset viewer.