Changeset 4e732f1a in mainline for uspace/lib/drv/generic/remote_usb.c


Ignore:
Timestamp:
2014-01-24T02:10:16Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42de21a
Parents:
3de7a62
Message:

usb: Add support for multiple packets per microframe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usb.c

    r3de7a62 r4e732f1a  
    161161}
    162162
     163int static_assert[sizeof(sysarg_t) >= 4 ? 1 : -1];
     164typedef union {
     165        uint8_t arr[sizeof(sysarg_t)];
     166        sysarg_t arg;
     167} pack8_t;
     168
    163169int usb_register_endpoint(async_exch_t *exch, usb_endpoint_t endpoint,
    164170    usb_transfer_type_t type, usb_direction_t direction,
    165     size_t mps, unsigned interval)
    166 {
    167         if (!exch)
    168                 return EBADMEM;
    169 #define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff))
     171    size_t mps, unsigned packets, unsigned interval)
     172{
     173        if (!exch)
     174                return EBADMEM;
     175        pack8_t pack;
     176        pack.arr[0] = type;
     177        pack.arr[1] = direction;
     178        pack.arr[2] = interval;
     179        pack.arr[3] = packets;
    170180
    171181        return async_req_4_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    172             IPC_M_USB_REGISTER_ENDPOINT, endpoint,
    173             _PACK2(type, direction), _PACK2(mps, interval));
    174 
    175 #undef _PACK2
     182            IPC_M_USB_REGISTER_ENDPOINT, endpoint, pack.arg, mps);
     183
    176184}
    177185
     
    408416        }
    409417
    410 #define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \
    411         type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) >> 16)
    412 #define _INIT_FROM_LOW_DATA2(type, var, arg_no) \
    413         type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) & 0xffff)
    414 
    415418        const usb_endpoint_t endpoint = DEV_IPC_GET_ARG1(*call);
    416 
    417         _INIT_FROM_HIGH_DATA2(usb_transfer_type_t, transfer_type, 2);
    418         _INIT_FROM_LOW_DATA2(usb_direction_t, direction, 2);
    419 
    420         _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3);
    421         _INIT_FROM_LOW_DATA2(unsigned int, interval, 3);
    422 
    423 #undef _INIT_FROM_HIGH_DATA2
    424 #undef _INIT_FROM_LOW_DATA2
     419        const pack8_t pack = { .arg = DEV_IPC_GET_ARG2(*call)};
     420        const size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
     421
     422        const usb_transfer_type_t transfer_type = pack.arr[0];
     423        const usb_direction_t direction = pack.arr[1];
     424        unsigned packets = pack.arr[2];
     425        unsigned interval = pack.arr[3];
    425426
    426427        const int ret = usb_iface->register_endpoint(fun, endpoint,
    427             transfer_type, direction, max_packet_size, interval);
     428            transfer_type, direction, max_packet_size, packets, interval);
    428429
    429430        async_answer_0(callid, ret);
Note: See TracChangeset for help on using the changeset viewer.