Ignore:
File:
1 edited

Legend:

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

    r17ceb72 ra9f91cd  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhcihc
     28/** @addtogroup usb
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver USB transaction structure
     32 * @brief UHCI driver
    3333 */
    3434#include <errno.h>
     
    4444
    4545#define DEFAULT_ERROR_COUNT 3
     46
     47static int batch_schedule(batch_t *instance);
    4648
    4749static void batch_control(batch_t *instance,
     
    5254static void batch_call_in_and_dispose(batch_t *instance);
    5355static void batch_call_out_and_dispose(batch_t *instance);
    54 
    55 
    56 /** Allocate memory and initialize internal data structure.
     56static void batch_dispose(batch_t *instance);
     57
     58
     59/** Allocates memory and initializes internal data structures.
    5760 *
    5861 * @param[in] fun DDF function to pass to callback.
     
    6972 * @param[in] arg additional parameter to func_in or func_out
    7073 * @param[in] manager Pointer to toggle management structure.
    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.
     74 * @return False, if there is an active TD, true otherwise.
    7775 */
    7876batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     
    153151}
    154152/*----------------------------------------------------------------------------*/
    155 /** Check batch TDs for activity.
     153/** Checks batch TDs for activity.
    156154 *
    157155 * @param[in] instance Batch structure to use.
    158156 * @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.
    163157 */
    164158bool batch_is_complete(batch_t *instance)
     
    199193 *
    200194 * @param[in] instance Batch structure to use.
    201  *
    202  * Uses genercir control function with pids OUT and IN.
    203195 */
    204196void batch_control_write(batch_t *instance)
    205197{
    206198        assert(instance);
    207         /* We are data out, we are supposed to provide data */
     199        /* we are data out, we are supposed to provide data */
    208200        memcpy(instance->transport_buffer, instance->buffer,
    209201            instance->buffer_size);
     
    211203        instance->next_step = batch_call_out_and_dispose;
    212204        usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance);
     205        batch_schedule(instance);
    213206}
    214207/*----------------------------------------------------------------------------*/
     
    216209 *
    217210 * @param[in] instance Batch structure to use.
    218  *
    219  * Uses generic control with pids IN and OUT.
    220211 */
    221212void batch_control_read(batch_t *instance)
     
    225216        instance->next_step = batch_call_in_and_dispose;
    226217        usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance);
    227 }
    228 /*----------------------------------------------------------------------------*/
    229 /** Prepare interrupt in transaction.
    230  *
    231  * @param[in] instance Batch structure to use.
    232  *
    233  * Data transaction with PID_IN.
     218        batch_schedule(instance);
     219}
     220/*----------------------------------------------------------------------------*/
     221/** Prepares interrupt in transaction.
     222 *
     223 * @param[in] instance Batch structure to use.
    234224 */
    235225void batch_interrupt_in(batch_t *instance)
     
    239229        instance->next_step = batch_call_in_and_dispose;
    240230        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
    241 }
    242 /*----------------------------------------------------------------------------*/
    243 /** Prepare interrupt out transaction.
    244  *
    245  * @param[in] instance Batch structure to use.
    246  *
    247  * Data transaction with PID_OUT.
     231        batch_schedule(instance);
     232}
     233/*----------------------------------------------------------------------------*/
     234/** Prepares interrupt out transaction.
     235 *
     236 * @param[in] instance Batch structure to use.
    248237 */
    249238void batch_interrupt_out(batch_t *instance)
    250239{
    251240        assert(instance);
    252         /* We are data out, we are supposed to provide data */
     241        /* we are data out, we are supposed to provide data */
    253242        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    254243        batch_data(instance, USB_PID_OUT);
    255244        instance->next_step = batch_call_out_and_dispose;
    256245        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    257 }
    258 /*----------------------------------------------------------------------------*/
    259 /** Prepare bulk in transaction.
    260  *
    261  * @param[in] instance Batch structure to use.
    262  *
    263  * Data transaction with PID_IN.
     246        batch_schedule(instance);
     247}
     248/*----------------------------------------------------------------------------*/
     249/** Prepares bulk in transaction.
     250 *
     251 * @param[in] instance Batch structure to use.
    264252 */
    265253void batch_bulk_in(batch_t *instance)
     
    269257        instance->next_step = batch_call_in_and_dispose;
    270258        usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    271 }
    272 /*----------------------------------------------------------------------------*/
    273 /** Prepare bulk out transaction.
    274  *
    275  * @param[in] instance Batch structure to use.
    276  *
    277  * Data transaction with PID_OUT.
     259        batch_schedule(instance);
     260}
     261/*----------------------------------------------------------------------------*/
     262/** Prepares bulk out transaction.
     263 *
     264 * @param[in] instance Batch structure to use.
    278265 */
    279266void batch_bulk_out(batch_t *instance)
    280267{
    281268        assert(instance);
    282         /* We are data out, we are supposed to provide data */
    283269        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    284270        batch_data(instance, USB_PID_OUT);
    285271        instance->next_step = batch_call_out_and_dispose;
    286272        usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
    287 }
    288 /*----------------------------------------------------------------------------*/
    289 /** Prepare generic data transaction
     273        batch_schedule(instance);
     274}
     275/*----------------------------------------------------------------------------*/
     276/** Prepares generic data transaction
    290277 *
    291278 * @param[in] instance Batch structure to use.
    292279 * @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.
    296280 */
    297281void batch_data(batch_t *instance, usb_packet_id pid)
     
    334318}
    335319/*----------------------------------------------------------------------------*/
    336 /** Prepare generic control transaction
     320/** Prepares generic control transaction
    337321 *
    338322 * @param[in] instance Batch structure to use.
    339323 * @param[in] data_stage to use for data packets.
    340324 * @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.
    346325 */
    347326void batch_control(batch_t *instance,
     
    392371}
    393372/*----------------------------------------------------------------------------*/
    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.
     373/** Prepares data, gets error status and calls callback in.
     374 *
     375 * @param[in] instance Batch structure to use.
    399376 */
    400377void batch_call_in(batch_t *instance)
     
    403380        assert(instance->callback_in);
    404381
    405         /* We are data in, we need data */
     382        /* we are data in, we need data */
    406383        memcpy(instance->buffer, instance->transport_buffer,
    407384            instance->buffer_size);
     
    416393}
    417394/*----------------------------------------------------------------------------*/
    418 /** Get error status and call callback out.
     395/** Gets error status and calls callback out.
    419396 *
    420397 * @param[in] instance Batch structure to use.
     
    432409}
    433410/*----------------------------------------------------------------------------*/
    434 /** Helper function calls callback and correctly disposes of batch structure.
     411/** Prepares data, gets error status, calls callback in and dispose.
    435412 *
    436413 * @param[in] instance Batch structure to use.
     
    443420}
    444421/*----------------------------------------------------------------------------*/
    445 /** Helper function calls callback and correctly disposes of batch structure.
     422/** Gets error status, calls callback out and dispose.
    446423 *
    447424 * @param[in] instance Batch structure to use.
     
    454431}
    455432/*----------------------------------------------------------------------------*/
    456 /** Correctly dispose all used data structures.
     433/** Correctly disposes all used data structures.
    457434 *
    458435 * @param[in] instance Batch structure to use.
     
    469446        free(instance);
    470447}
     448/*----------------------------------------------------------------------------*/
     449int 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}
    471456/**
    472457 * @}
Note: See TracChangeset for help on using the changeset viewer.