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


Ignore:
Timestamp:
2011-03-14T22:51:09Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2180979
Parents:
7ffe82f (diff), fcf07e6 (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 development/ changes

File:
1 edited

Legend:

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

    r7ffe82f r2ef036a  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver USB transaction structure
    3333 */
    3434#include <errno.h>
     
    4444
    4545#define DEFAULT_ERROR_COUNT 3
    46 
    47 static int batch_schedule(batch_t *instance);
    4846
    4947static void batch_control(batch_t *instance,
     
    5452static void batch_call_in_and_dispose(batch_t *instance);
    5553static void batch_call_out_and_dispose(batch_t *instance);
    56 static void batch_dispose(batch_t *instance);
    57 
    58 
    59 /** Allocates memory and initializes internal data structures.
     54
     55
     56/** Allocate memory and initialize internal data structure.
    6057 *
    6158 * @param[in] fun DDF function to pass to callback.
     
    7269 * @param[in] arg additional parameter to func_in or func_out
    7370 * @param[in] manager Pointer to toggle management structure.
    74  * @return False, if there is an active TD, true otherwise.
     71 * @return Valid pointer if all substructures were successfully created,
     72 * NULL otherwise.
     73 *
     74 * Determines the number of needed packets (TDs). Prepares a transport buffer
     75 * (that is accessible by the hardware). Initializes parameters needed for the
     76 * transaction and callback.
    7577 */
    7678batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     
    151153}
    152154/*----------------------------------------------------------------------------*/
    153 /** Checks batch TDs for activity.
     155/** Check batch TDs for activity.
    154156 *
    155157 * @param[in] instance Batch structure to use.
    156158 * @return False, if there is an active TD, true otherwise.
     159 *
     160 * Walk all TDs. Stop with false if there is an active one (it is to be
     161 * processed). Stop with true if an error is found. Return true if the last TS
     162 * is reached.
    157163 */
    158164bool batch_is_complete(batch_t *instance)
     
    193199 *
    194200 * @param[in] instance Batch structure to use.
     201 *
     202 * Uses genercir control function with pids OUT and IN.
    195203 */
    196204void batch_control_write(batch_t *instance)
    197205{
    198206        assert(instance);
    199         /* we are data out, we are supposed to provide data */
     207        /* We are data out, we are supposed to provide data */
    200208        memcpy(instance->transport_buffer, instance->buffer,
    201209            instance->buffer_size);
     
    203211        instance->next_step = batch_call_out_and_dispose;
    204212        usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance);
    205         batch_schedule(instance);
    206213}
    207214/*----------------------------------------------------------------------------*/
     
    209216 *
    210217 * @param[in] instance Batch structure to use.
     218 *
     219 * Uses generic control with pids IN and OUT.
    211220 */
    212221void batch_control_read(batch_t *instance)
     
    216225        instance->next_step = batch_call_in_and_dispose;
    217226        usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance);
    218         batch_schedule(instance);
    219 }
    220 /*----------------------------------------------------------------------------*/
    221 /** Prepares interrupt in transaction.
    222  *
    223  * @param[in] instance Batch structure to use.
     227}
     228/*----------------------------------------------------------------------------*/
     229/** Prepare interrupt in transaction.
     230 *
     231 * @param[in] instance Batch structure to use.
     232 *
     233 * Data transaction with PID_IN.
    224234 */
    225235void batch_interrupt_in(batch_t *instance)
     
    229239        instance->next_step = batch_call_in_and_dispose;
    230240        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    231         batch_schedule(instance);
    232 }
    233 /*----------------------------------------------------------------------------*/
    234 /** Prepares interrupt out transaction.
    235  *
    236  * @param[in] instance Batch structure to use.
     241}
     242/*----------------------------------------------------------------------------*/
     243/** Prepare interrupt out transaction.
     244 *
     245 * @param[in] instance Batch structure to use.
     246 *
     247 * Data transaction with PID_OUT.
    237248 */
    238249void batch_interrupt_out(batch_t *instance)
    239250{
    240251        assert(instance);
    241         /* we are data out, we are supposed to provide data */
     252        /* We are data out, we are supposed to provide data */
    242253        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    243254        batch_data(instance, USB_PID_OUT);
    244255        instance->next_step = batch_call_out_and_dispose;
    245256        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    246         batch_schedule(instance);
    247 }
    248 /*----------------------------------------------------------------------------*/
    249 /** Prepares bulk in transaction.
    250  *
    251  * @param[in] instance Batch structure to use.
     257}
     258/*----------------------------------------------------------------------------*/
     259/** Prepare bulk in transaction.
     260 *
     261 * @param[in] instance Batch structure to use.
     262 *
     263 * Data transaction with PID_IN.
    252264 */
    253265void batch_bulk_in(batch_t *instance)
     
    257269        instance->next_step = batch_call_in_and_dispose;
    258270        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    259         batch_schedule(instance);
    260 }
    261 /*----------------------------------------------------------------------------*/
    262 /** Prepares bulk out transaction.
    263  *
    264  * @param[in] instance Batch structure to use.
     271}
     272/*----------------------------------------------------------------------------*/
     273/** Prepare bulk out transaction.
     274 *
     275 * @param[in] instance Batch structure to use.
     276 *
     277 * Data transaction with PID_OUT.
    265278 */
    266279void batch_bulk_out(batch_t *instance)
    267280{
    268281        assert(instance);
     282        /* We are data out, we are supposed to provide data */
    269283        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    270284        batch_data(instance, USB_PID_OUT);
    271285        instance->next_step = batch_call_out_and_dispose;
    272286        usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
    273         batch_schedule(instance);
    274 }
    275 /*----------------------------------------------------------------------------*/
    276 /** Prepares generic data transaction
     287}
     288/*----------------------------------------------------------------------------*/
     289/** Prepare generic data transaction
    277290 *
    278291 * @param[in] instance Batch structure to use.
    279292 * @param[in] pid to use for data packets.
     293 *
     294 * Packets with alternating toggle bit and supplied pid value.
     295 * The last packet is marked with IOC flag.
    280296 */
    281297void batch_data(batch_t *instance, usb_packet_id pid)
     
    318334}
    319335/*----------------------------------------------------------------------------*/
    320 /** Prepares generic control transaction
     336/** Prepare generic control transaction
    321337 *
    322338 * @param[in] instance Batch structure to use.
    323339 * @param[in] data_stage to use for data packets.
    324340 * @param[in] status_stage to use for data packets.
     341 *
     342 * Setup stage with toggle 0 and USB_PID_SETUP.
     343 * Data stage with alternating toggle and pid supplied by parameter.
     344 * Status stage with toggle 1 and pid supplied by parameter.
     345 * The last packet is marked with IOC.
    325346 */
    326347void batch_control(batch_t *instance,
     
    371392}
    372393/*----------------------------------------------------------------------------*/
    373 /** Prepares data, gets error status and calls callback in.
    374  *
    375  * @param[in] instance Batch structure to use.
     394/** Prepare data, get error status and call callback in.
     395 *
     396 * @param[in] instance Batch structure to use.
     397 * Copies data from transport buffer, and calls callback with appropriate
     398 * parameters.
    376399 */
    377400void batch_call_in(batch_t *instance)
     
    380403        assert(instance->callback_in);
    381404
    382         /* we are data in, we need data */
     405        /* We are data in, we need data */
    383406        memcpy(instance->buffer, instance->transport_buffer,
    384407            instance->buffer_size);
     
    393416}
    394417/*----------------------------------------------------------------------------*/
    395 /** Gets error status and calls callback out.
     418/** Get error status and call callback out.
    396419 *
    397420 * @param[in] instance Batch structure to use.
     
    409432}
    410433/*----------------------------------------------------------------------------*/
    411 /** Prepares data, gets error status, calls callback in and dispose.
     434/** Helper function calls callback and correctly disposes of batch structure.
    412435 *
    413436 * @param[in] instance Batch structure to use.
     
    420443}
    421444/*----------------------------------------------------------------------------*/
    422 /** Gets error status, calls callback out and dispose.
     445/** Helper function calls callback and correctly disposes of batch structure.
    423446 *
    424447 * @param[in] instance Batch structure to use.
     
    431454}
    432455/*----------------------------------------------------------------------------*/
    433 /** Correctly disposes all used data structures.
     456/** Correctly dispose all used data structures.
    434457 *
    435458 * @param[in] instance Batch structure to use.
     
    446469        free(instance);
    447470}
    448 /*----------------------------------------------------------------------------*/
    449 int batch_schedule(batch_t *instance)
    450 {
    451         assert(instance);
    452         uhci_hc_t *hc = fun_to_uhci_hc(instance->fun);
    453         assert(hc);
    454         return uhci_hc_schedule(hc, instance);
    455 }
    456471/**
    457472 * @}
Note: See TracChangeset for help on using the changeset viewer.