Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c

    rd394f1b8 r70d72dd  
    3535#include "transfer_descriptor.h"
    3636
    37 static unsigned dp[3] =
    38     { TD_STATUS_DP_IN, TD_STATUS_DP_OUT, TD_STATUS_DP_SETUP };
    39 static unsigned togg[2] = { TD_STATUS_T_0, TD_STATUS_T_1 };
     37/** USB direction to OHCI TD values translation table */
     38static const uint32_t dir[] = {
     39        [USB_DIRECTION_IN] = TD_STATUS_DP_IN,
     40        [USB_DIRECTION_OUT] = TD_STATUS_DP_OUT,
     41        [USB_DIRECTION_BOTH] = TD_STATUS_DP_SETUP,
     42};
    4043
    41 void td_init(td_t *instance,
    42     usb_direction_t dir, const void *buffer, size_t size, int toggle)
     44/**
     45 * Initialize OHCI TD.
     46 * @param instance TD structure to initialize.
     47 * @param next Next TD in ED list.
     48 * @param direction Used to determine PID, BOTH means setup PID.
     49 * @param buffer Pointer to the first byte of transferred data.
     50 * @param size Size of the buffer.
     51 * @param toggle Toggle bit value, use 0/1 to set explicitly,
     52 *        any other value means that ED toggle will be used.
     53 */
     54void td_init(td_t *instance, const td_t *next,
     55    usb_direction_t direction, const void *buffer, size_t size, int toggle)
    4356{
    4457        assert(instance);
    4558        bzero(instance, sizeof(td_t));
     59        /* Set PID and Error code */
    4660        instance->status = 0
    47             | ((dp[dir] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
     61            | ((dir[direction] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
    4862            | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT);
     63
    4964        if (toggle == 0 || toggle == 1) {
    50                 instance->status |= togg[toggle] << TD_STATUS_T_SHIFT;
     65                /* Set explicit toggle bit */
     66                instance->status |= TD_STATUS_T_USE_TD_FLAG;
     67                instance->status |= toggle ? TD_STATUS_T_FLAG : 0;
    5168        }
     69
     70        /* Alow less data on input. */
    5271        if (dir == USB_DIRECTION_IN) {
    5372                instance->status |= TD_STATUS_ROUND_FLAG;
    5473        }
     74
    5575        if (buffer != NULL) {
    5676                assert(size != 0);
     
    5878                instance->be = addr_to_phys(buffer + size - 1);
    5979        }
     80
     81        instance->next = addr_to_phys(next) & TD_NEXT_PTR_MASK;
     82
    6083}
    6184/**
Note: See TracChangeset for help on using the changeset viewer.