Ignore:
Timestamp:
2018-01-06T21:15:48Z (6 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/usb/include/usb/descriptor.h

    rc901632 r9efad54  
    200200        /** Endpoint address together with data flow direction. */
    201201        uint8_t endpoint_address;
     202#define USB_ED_GET_EP(ed)       ((ed).endpoint_address & 0xf)
     203#define USB_ED_GET_DIR(ed)      (!(((ed).endpoint_address >> 7) & 0x1))
     204
    202205        /** Endpoint attributes.
    203206         * Includes transfer type (usb_transfer_type_t).
    204207         */
    205208        uint8_t attributes;
     209#define USB_ED_GET_TRANSFER_TYPE(ed)    ((ed).attributes & 0x3)
    206210        /** Maximum packet size.
    207211         * Lower 10 bits represent the actuall size
     
    209213         * HS INT and ISO transfers. */
    210214        uint16_t max_packet_size;
    211 
    212 #define ED_MPS_PACKET_SIZE_MASK  0x3ff
    213 #define ED_MPS_PACKET_SIZE_GET(value) \
    214         ((value) & ED_MPS_PACKET_SIZE_MASK)
    215 #define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \
    216         ((((value) >> 10) & 0x3) + 1)
    217 
     215#define USB_ED_GET_MPS(ed) \
     216        (uint16_usb2host((ed).max_packet_size) & 0x7ff)
     217#define USB_ED_GET_ADD_OPPS(ed) \
     218        ((uint16_usb2host((ed).max_packet_size) >> 11) & 0x3)
    218219        /** Polling interval in milliseconds.
    219220         * Ignored for bulk and control endpoints.
     
    246247         */
    247248        uint8_t attributes;
    248 #define SS_COMPANION_MAX_STREAMS(attributes) \
    249         (attributes & 0x1f)
    250 #define SS_COMPANION_MULT(attributes) \
    251         (attributes & 0x3)
     249#define USB_SSC_MAX_STREAMS(sscd) ((sscd).attributes & 0x1f)
     250#define USB_SSC_MULT(sscd) ((sscd).attributes & 0x3)
    252251        /** The total number of bytes this endpoint will transfer
    253252         * every service interval (SI).
Note: See TracChangeset for help on using the changeset viewer.