Changeset 9efad54 in mainline for uspace/lib/drv/include


Ignore:
Timestamp:
2018-01-06T21:15:48Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
56257ba
Parents:
c901632
Message:

usb: move endpoint descriptor parsing to HC

This better separates responsibilities. Now the device driver does not
care about the contents of an endpoint descriptor, and HC can parse the
values according to device's actual speed.

Currently, it is device driver's responsibility to fetch endpoint
descriptors, map them and register pipes - sending the endpoint
descriptor back to HC. HC then parses it, and fills the pipe
description, which then sends back to device driver. We shall probably
fetch the endpoint descriptor from inside the HC (also fixing the USB
spec violation of communication with EP0).

Location:
uspace/lib/drv/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/usb_iface.h

    rc901632 r9efad54  
    100100} usb_target_t;
    101101
    102 /** Description of an usb endpoint.
    103  */
    104 typedef struct {
    105         unsigned max_burst;
    106         unsigned max_streams;
    107         unsigned mult;
    108         unsigned bytes_per_interval;
    109 } usb3_endpoint_desc_t;
    110 
    111 typedef struct usb_endpoint_desc {
    112         /** Endpoint number. */
    113         usb_endpoint_t endpoint_no;
    114 
    115         /** Endpoint transfer type. */
    116         usb_transfer_type_t transfer_type;
    117 
    118         /** Endpoint direction. */
    119         usb_direction_t direction;
    120 
    121         /** Maximum packet size for the endpoint. */
    122         size_t max_packet_size;
    123 
    124         /** Scheduling interval for HC. Only valid for interrupt/isoch transfer. */
    125         size_t interval;
    126 
    127         /** Number of packets per frame/uframe.
    128          * Only valid for HS INT and ISO transfers. All others should set to 1*/
    129         unsigned packets;
    130 
    131         /** Superspeed-specific information */
    132         usb3_endpoint_desc_t usb3;
    133 } usb_endpoint_desc_t;
    134 
    135 
    136102extern usb_dev_session_t *usb_dev_connect(devman_handle_t);
    137103extern usb_dev_session_t *usb_dev_connect_to_self(ddf_dev_t *);
  • uspace/lib/drv/include/usbhc_iface.h

    rc901632 r9efad54  
    4444#include <async.h>
    4545
     46typedef struct usb_pipe_desc {
     47        /** Endpoint number. */
     48        usb_endpoint_t endpoint_no;
     49
     50        /** Endpoint transfer type. */
     51        usb_transfer_type_t transfer_type;
     52
     53        /** Endpoint direction. */
     54        usb_direction_t direction;
     55
     56        /** Maximum size of one transfer */
     57        size_t max_transfer_size;
     58} usb_pipe_desc_t;
     59
     60/** This structure follows standard endpoint descriptor + superspeed companion
     61 * descriptor, and exists to avoid dependency of libdrv on libusb. Keep the
     62 * internal fields named exactly like their source (because we want to use the
     63 * same macros to access them).
     64 * Callers shall fill it with bare contents of respective descriptors (in usb endianity).
     65 */
     66typedef struct {
     67        struct {
     68                uint8_t endpoint_address;
     69                uint8_t attributes;
     70                uint16_t max_packet_size;
     71                uint8_t poll_interval;
     72        } endpoint;
     73
     74        /* Superspeed companion descriptor */
     75        struct companion_desc_t {
     76                uint8_t max_burst;
     77                uint8_t attributes;
     78                uint16_t bytes_per_interval;
     79        } companion;
     80} usb_endpoint_descriptors_t;
     81
    4682extern int usbhc_reserve_default_address(async_exch_t *, usb_speed_t);
    4783extern int usbhc_release_default_address(async_exch_t *);
     
    5086extern int usbhc_device_remove(async_exch_t *, unsigned port);
    5187
    52 extern int usbhc_register_endpoint(async_exch_t *, usb_endpoint_desc_t *);
    53 extern int usbhc_unregister_endpoint(async_exch_t *, usb_endpoint_desc_t *);
     88extern int usbhc_register_endpoint(async_exch_t *, usb_pipe_desc_t *, const usb_endpoint_descriptors_t *);
     89extern int usbhc_unregister_endpoint(async_exch_t *, const usb_pipe_desc_t *);
     90
    5491extern int usbhc_read(async_exch_t *, usb_endpoint_t, uint64_t, void *, size_t,
    5592    size_t *);
     
    68105        int (*device_remove)(ddf_fun_t *, unsigned);
    69106
    70         int (*register_endpoint)(ddf_fun_t *, usb_endpoint_desc_t *);
    71         int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_desc_t *);
     107        int (*register_endpoint)(ddf_fun_t *, usb_pipe_desc_t *, const usb_endpoint_descriptors_t *);
     108        int (*unregister_endpoint)(ddf_fun_t *, const usb_pipe_desc_t *);
    72109
    73110        int (*read)(ddf_fun_t *, usb_target_t,
Note: See TracChangeset for help on using the changeset viewer.