Ignore:
File:
1 edited

Legend:

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

    r70d72dd rd394f1b8  
    3535#include "transfer_descriptor.h"
    3636
    37 /** USB direction to OHCI TD values translation table */
    38 static 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 };
     37static unsigned dp[3] =
     38    { TD_STATUS_DP_IN, TD_STATUS_DP_OUT, TD_STATUS_DP_SETUP };
     39static unsigned togg[2] = { TD_STATUS_T_0, TD_STATUS_T_1 };
    4340
    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  */
    54 void td_init(td_t *instance, const td_t *next,
    55     usb_direction_t direction, const void *buffer, size_t size, int toggle)
     41void td_init(td_t *instance,
     42    usb_direction_t dir, const void *buffer, size_t size, int toggle)
    5643{
    5744        assert(instance);
    5845        bzero(instance, sizeof(td_t));
    59         /* Set PID and Error code */
    6046        instance->status = 0
    61             | ((dir[direction] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
     47            | ((dp[dir] & TD_STATUS_DP_MASK) << TD_STATUS_DP_SHIFT)
    6248            | ((CC_NOACCESS2 & TD_STATUS_CC_MASK) << TD_STATUS_CC_SHIFT);
    63 
    6449        if (toggle == 0 || toggle == 1) {
    65                 /* Set explicit toggle bit */
    66                 instance->status |= TD_STATUS_T_USE_TD_FLAG;
    67                 instance->status |= toggle ? TD_STATUS_T_FLAG : 0;
     50                instance->status |= togg[toggle] << TD_STATUS_T_SHIFT;
    6851        }
    69 
    70         /* Alow less data on input. */
    7152        if (dir == USB_DIRECTION_IN) {
    7253                instance->status |= TD_STATUS_ROUND_FLAG;
    7354        }
    74 
    7555        if (buffer != NULL) {
    7656                assert(size != 0);
     
    7858                instance->be = addr_to_phys(buffer + size - 1);
    7959        }
    80 
    81         instance->next = addr_to_phys(next) & TD_NEXT_PTR_MASK;
    82 
    8360}
    8461/**
Note: See TracChangeset for help on using the changeset viewer.