Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ec700c7 in mainline


Ignore:
Timestamp:
2017-10-23T23:17:14Z (3 years ago)
Author:
Michal Staruch <salmelu@…>
Branches:
master
Children:
894f58c
Parents:
b724494
Message:

Superspeed companion descriptor is processed

Superspeed endpoint companion is now correctly read and processed while parsing descriptors.
As a side effect, mass storage endpoints now initialize correctly and therefore mass storage driver starts.

Location:
uspace/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/descriptor.h

    rb724494 rec700c7  
    245245         */
    246246        uint8_t attributes;
     247#define SS_COMPANION_MAX_STREAMS(attributes) \
     248        (attributes & 0x1f)
    247249        /** The total number of bytes this endpoint will transfer
    248250         * every service interval (SI).
  • uspace/lib/usb/include/usb/usb.h

    rb724494 rec700c7  
    197197                unsigned polling_interval;
    198198        } usb2;
     199
     200        struct {
     201                unsigned max_burst;
     202                unsigned max_streams;
     203        } usb3;
    199204} usb_endpoint_desc_t;
    200205
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    rb724494 rec700c7  
    8888        /** Found descriptor fitting the description. */
    8989        const usb_standard_endpoint_descriptor_t *descriptor;
     90        /** Relevant superspeed companion descriptor. */
     91        const usb_superspeed_endpoint_companion_descriptor_t *companion_descriptor;
    9092        /** Interface descriptor the endpoint belongs to. */
    9193        const usb_standard_interface_descriptor_t *interface;
     
    9597
    9698int usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
    97     size_t, usb_direction_t, unsigned, usb_dev_session_t *);
     99    size_t, usb_direction_t, unsigned, unsigned, unsigned, usb_dev_session_t *);
    98100int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
    99101
  • uspace/lib/usbdev/src/pipes.c

    rb724494 rec700c7  
    254254int usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no,
    255255    usb_transfer_type_t transfer_type, size_t max_packet_size,
    256     usb_direction_t direction, unsigned packets, usb_dev_session_t *bus_session)
    257 {
     256    usb_direction_t direction, unsigned packets,
     257    unsigned max_burst, unsigned max_streams, usb_dev_session_t *bus_session)
     258{
     259        // FIXME refactor this function
    258260        assert(pipe);
    259261
     
    263265        pipe->desc.max_packet_size = max_packet_size;
    264266        pipe->desc.direction = direction;
     267        pipe->desc.usb3.max_burst = max_burst;
     268        pipe->desc.usb3.max_streams = max_streams;
    265269        pipe->auto_reset_halt = false;
    266270        pipe->bus_session = bus_session;
     
    280284
    281285        const int rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL,
    282             CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, 1, bus_session);
     286            CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, 1, 0, 0, bus_session);
    283287
    284288        pipe->auto_reset_halt = true;
  • uspace/lib/usbdev/src/pipesinit.c

    rb724494 rec700c7  
    3838#include <usb/dev/request.h>
    3939#include <usb/usb.h>
     40#include <usb/debug.h>
    4041#include <usb/descriptor.h>
    4142
     
    5960        NESTING(INTERFACE, HID),
    6061        NESTING(HID, HID_REPORT),
     62        NESTING(ENDPOINT, SSPEED_EP_COMPANION),
    6163        LAST_NESTING
    6264};
     
    7072{
    7173        return descriptor[1] == USB_DESCTYPE_ENDPOINT;
     74}
     75
     76/** Tells whether given descriptor is of superspeed companion type.
     77 *
     78 * @param descriptor Descriptor in question.
     79 * @return Whether the given descriptor is superspeed companion descriptor.
     80 */
     81static inline bool is_superspeed_companion_descriptor(const uint8_t *descriptor)
     82{
     83        return descriptor[1] == USB_DESCTYPE_SSPEED_EP_COMPANION;
    7284}
    7385
     
    150162 * @param interface Interface descriptor under which belongs the @p endpoint.
    151163 * @param endpoint Endpoint descriptor.
     164 * @param companion Superspeed companion descriptor.
    152165 * @return Error code.
    153166 */
     
    156169    usb_standard_interface_descriptor_t *interface,
    157170    usb_standard_endpoint_descriptor_t *endpoint_desc,
     171    usb_superspeed_endpoint_companion_descriptor_t *companion_desc,
    158172    usb_dev_session_t *bus_session)
    159173{
     
    194208        }
    195209
     210        unsigned max_burst = 0;
     211        unsigned max_streams = 0;
     212        if(companion_desc) {
     213                max_burst = companion_desc->max_burst;
     214                max_streams = SS_COMPANION_MAX_STREAMS(companion_desc->attributes);
     215        }
     216
    196217        int rc = usb_pipe_initialize(&ep_mapping->pipe,
    197218            ep_no, description.transfer_type,
    198219            ED_MPS_PACKET_SIZE_GET(
    199220                uint16_usb2host(endpoint_desc->max_packet_size)),
    200             description.direction,
     221            description.direction, max_burst, max_streams,
    201222            ED_MPS_TRANS_OPPORTUNITIES_GET(
    202223                uint16_usb2host(endpoint_desc->max_packet_size)), bus_session);
     
    207228        ep_mapping->present = true;
    208229        ep_mapping->descriptor = endpoint_desc;
     230        ep_mapping->companion_descriptor = companion_desc;
    209231        ep_mapping->interface = interface;
    210232
     
    235257        do {
    236258                if (is_endpoint_descriptor(descriptor)) {
     259                        /* Check if companion descriptor is present too, it should immediatelly follow. */
     260                        const uint8_t *companion_desc = usb_dp_get_nested_descriptor(parser,
     261                                parser_data, descriptor);
     262                        if (companion_desc && !is_superspeed_companion_descriptor(companion_desc)) {
     263                                /* Not what we wanted, don't pass it further. */
     264                                companion_desc = NULL;
     265                        }
     266
    237267                        (void) process_endpoint(mapping, mapping_count,
    238268                            (usb_standard_interface_descriptor_t *)
     
    240270                            (usb_standard_endpoint_descriptor_t *)
    241271                                descriptor,
     272                            (usb_superspeed_endpoint_companion_descriptor_t *)
     273                                companion_desc,
    242274                            bus_session);
    243275                }
  • uspace/lib/usbhost/src/ddf_helpers.c

    rb724494 rec700c7  
    105105                usb_str_direction(endpoint_desc->direction),
    106106                endpoint_desc->max_packet_size, endpoint_desc->usb2.polling_interval);
     107
     108        // FIXME: we now have max_streams and max_burst in endpoint_desc->usb3 struct
     109        // Hand it down to XHCI, refactor, whatever
    107110
    108111        return bus_add_ep(hcd->bus, dev, endpoint_desc->endpoint_no,
Note: See TracChangeset for help on using the changeset viewer.