Changeset 2770b66 in mainline for uspace/drv/bus/usb/xhci/rh.c


Ignore:
Timestamp:
2017-10-15T15:05:06Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
816f5f4
Parents:
20eaa82
Message:

Fixed few bugs related to control transfers and some deadlocks. Registering control endpoint with HelenOS. Can read out device descriptors through MID and initialize mouse driver!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/rh.c

    r20eaa82 r2770b66  
    3636#include <errno.h>
    3737#include <str_error.h>
     38#include <usb/request.h>
    3839#include <usb/debug.h>
    3940#include <usb/host/utils/malloc32.h>
    4041#include <usb/host/bus.h>
    4142#include <usb/host/ddf_helpers.h>
     43#include <usb/host/hcd.h>
    4244
    4345#include "debug.h"
     
    7476// TODO: This currently assumes the device is attached to rh directly.
    7577//       Also, we should consider moving a lot of functionailty to xhci bus
    76 int xhci_rh_address_device(xhci_rh_t *rh, device_t *dev)
     78int xhci_rh_address_device(xhci_rh_t *rh, device_t *dev, xhci_bus_t *bus)
    7779{
    7880        int err;
     
    160162        usb_log_debug2("Obtained USB address: %d.\n", dev->address);
    161163
    162         // TODO: Ask libusbhost to create a control endpoint for EP0.
    163 
    164         // TODO: Save all data structures in the corresponding xhci_device_t.
    165 
    166         return EOK;
    167 
     164        // Ask libusbhost to create a control endpoint for EP0.
     165        bus_t *bus_base = &bus->base;
     166        usb_target_t ep0_target = { .address = dev->address, .endpoint = 0 };
     167        usb_direction_t ep0_direction = USB_DIRECTION_BOTH;
     168
     169        // TODO: Should this call be unified with other calls to `bus_add_ep()`?
     170        err = bus_add_ep(bus_base, dev, ep0_target.endpoint, ep0_direction,
     171            USB_TRANSFER_CONTROL, CTRL_PIPE_MIN_PACKET_SIZE, CTRL_PIPE_MIN_PACKET_SIZE, 1);
     172
     173        if (err != EOK)
     174                goto err_add_ep;
     175
     176        // Save all data structures in the corresponding xhci_device_t.
     177        endpoint_t *ep0_base = bus_find_endpoint(bus_base, ep0_target, ep0_direction);
     178        xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base);
     179        xhci_device_t *xhci_dev = ep0->device;
     180
     181        xhci_dev->device = dev;
     182        xhci_dev->slot_id = slot_id;
     183
     184        // TODO: Save anything else?
     185
     186        return EOK;
     187
     188err_add_ep:
    168189err_dctx:
    169190        if (dctx) {
Note: See TracChangeset for help on using the changeset viewer.