Changeset 9efad54 in mainline for uspace/lib/drv/include/usbhc_iface.h


Ignore:
Timestamp:
2018-01-06T21:15:48Z (7 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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.