Ignore:
Timestamp:
2011-04-09T17:15:28Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97e7e8a
Parents:
5410c04 (diff), 77223f8 (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:

Refactoring: libusb, USBHC interface protocol

Highlights:

  • refactoring of libusb (not complete)
  • max packet size is not send during each transfer
  • reserving of default address is possible via endpoint registration
  • endpoint registration can send speed as well
File:
1 edited

Legend:

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

    r5410c04 ra9d67aa  
    270270        }
    271271
    272         size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    273272        usb_target_t target = {
    274273                .address = DEV_IPC_GET_ARG1(*call),
     
    300299        trans->size = len;
    301300
    302         rc = transfer_func(fun, target, max_packet_size,
     301        rc = transfer_func(fun, target,
    303302            buffer, len,
    304303            callback_out, trans);
     
    326325        }
    327326
    328         size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    329327        usb_target_t target = {
    330328                .address = DEV_IPC_GET_ARG1(*call),
     
    348346        trans->size = len;
    349347
    350         int rc = transfer_func(fun, target, max_packet_size,
     348        int rc = transfer_func(fun, target,
    351349            trans->buffer, len,
    352350            callback_in, trans);
     
    414412        };
    415413        size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
    416         size_t max_packet_size = DEV_IPC_GET_ARG4(*call);
    417414
    418415        int rc;
     
    450447        trans->size = data_buffer_len;
    451448
    452         rc = usb_iface->control_write(fun, target, max_packet_size,
     449        rc = usb_iface->control_write(fun, target,
    453450            setup_packet, setup_packet_len,
    454451            data_buffer, data_buffer_len,
     
    477474                .endpoint = DEV_IPC_GET_ARG2(*call)
    478475        };
    479         size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    480476
    481477        int rc;
     
    515511        }
    516512
    517         rc = usb_iface->control_read(fun, target, max_packet_size,
     513        rc = usb_iface->control_read(fun, target,
    518514            setup_packet, setup_packet_len,
    519515            trans->buffer, trans->size,
     
    537533        }
    538534
    539 #define INIT_FROM_HIGH_DATA(type, var, arg_no) \
    540         type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256
    541 #define INIT_FROM_LOW_DATA(type, var, arg_no) \
    542         type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256
    543 
    544         INIT_FROM_HIGH_DATA(usb_address_t, address, 1);
    545         INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1);
    546         INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2);
    547         INIT_FROM_LOW_DATA(usb_direction_t, direction, 2);
    548 
    549 #undef INIT_FROM_HIGH_DATA
    550 #undef INIT_FROM_LOW_DATA
    551 
    552         size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call);
    553         unsigned int interval  = (unsigned int) DEV_IPC_GET_ARG4(*call);
    554 
    555         int rc = usb_iface->register_endpoint(fun, address, endpoint,
     535#define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \
     536        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16)
     537#define _INIT_FROM_LOW_DATA2(type, var, arg_no) \
     538        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 16)
     539#define _INIT_FROM_HIGH_DATA3(type, var, arg_no) \
     540        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16)
     541#define _INIT_FROM_MIDDLE_DATA3(type, var, arg_no) \
     542        type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) / (1 << 8)) % (1 << 8)
     543#define _INIT_FROM_LOW_DATA3(type, var, arg_no) \
     544        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 8)
     545
     546        _INIT_FROM_HIGH_DATA2(usb_address_t, address, 1);
     547        _INIT_FROM_LOW_DATA2(usb_endpoint_t, endpoint, 1);
     548
     549        _INIT_FROM_HIGH_DATA3(usb_speed_t, speed, 2);
     550        _INIT_FROM_MIDDLE_DATA3(usb_transfer_type_t, transfer_type, 2);
     551        _INIT_FROM_LOW_DATA3(usb_direction_t, direction, 2);
     552
     553        _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3);
     554        _INIT_FROM_LOW_DATA2(unsigned int, interval, 3);
     555
     556#undef _INIT_FROM_HIGH_DATA2
     557#undef _INIT_FROM_LOW_DATA2
     558#undef _INIT_FROM_HIGH_DATA3
     559#undef _INIT_FROM_MIDDLE_DATA3
     560#undef _INIT_FROM_LOW_DATA3
     561
     562        int rc = usb_iface->register_endpoint(fun, address, speed, endpoint,
    556563            transfer_type, direction, max_packet_size, interval);
    557564
Note: See TracChangeset for help on using the changeset viewer.