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

Changeset 766043c in mainline


Ignore:
Timestamp:
2017-10-21T23:18:09Z (3 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
master
Children:
2b61945
Parents:
5fd9c30
Message:

Keeping track of root hub devices by port id.

Location:
uspace/drv/bus/usb/xhci
Files:
2 edited

Legend:

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

    r5fd9c30 r766043c  
    6868        rh->hc = hc;
    6969        rh->max_ports = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_PORTS);
     70        rh->devices = (xhci_device_t **) malloc(rh->max_ports * sizeof(xhci_device_t *));
    7071        hc->rh.hc_device = device;
     72
     73        memset(rh->devices, 0, rh->max_ports * sizeof(xhci_device_t *));
    7174
    7275        return device_init(&hc->rh.device);
     
    175178        xhci_dev->hc = hc;
    176179
    177         // TODO: Save anything else?
     180        if (!rh->devices[dev->port - 1]) {
     181                /* Only save the device if it's the first one connected to this port. */
     182                rh->devices[dev->port - 1] = xhci_dev;
     183        }
    178184
    179185        return EOK;
     
    280286static int handle_disconnected_device(xhci_rh_t *rh, uint8_t port_id)
    281287{
    282         // TODO: Find XHCI device by the port.
     288        /* Find XHCI device by the port. */
     289        xhci_device_t *dev = rh->devices[port_id - 1];
     290        if (!dev) {
     291                /* Must be extraneous call */
     292                return EOK;
     293        }
     294
     295        usb_log_info("Device at port %u has been disconnected.", port_id);
     296
    283297        // TODO: Destroy DDF function using _gone.
    284298        // TODO: Remove device endpoints on the bus.
     
    437451        /* TODO: Implement me! */
    438452        usb_log_debug2("Called xhci_rh_fini().");
     453
     454        free(rh->devices);
     455
    439456        return EOK;
    440457}
  • uspace/drv/bus/usb/xhci/rh.h

    r5fd9c30 r766043c  
    5555typedef struct hcd_roothub hcd_roothub_t;
    5656typedef struct xhci_bus xhci_bus_t;
     57typedef struct xhci_device xhci_device_t;
    5758
    5859/* XHCI root hub instance */
     
    7576        /* Number of hub ports. */
    7677        uint8_t max_ports;
     78
     79        /* Device pointers connected to RH ports or NULL. (size is `max_ports`) */
     80        xhci_device_t **devices;
    7781} xhci_rh_t;
    7882
Note: See TracChangeset for help on using the changeset viewer.