Changeset c10daa8 in mainline for uspace/drv/bus/usb/xhci/endpoint.c


Ignore:
Timestamp:
2017-10-13T12:32:57Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
063dfe8
Parents:
366e9b6
Message:

Refactored XHCI bus to hold devices instead of endpoints. Added middle layer to keep track of endpoints within devices.

File:
1 edited

Legend:

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

    r366e9b6 rc10daa8  
    5050
    5151        endpoint_init(ep, bus);
    52 
    53         /* FIXME: Set xhci_ep->slot_id */
     52        xhci_ep->device = NULL;
    5453
    5554        usb_log_debug("XHCI Endpoint %d:%d initialized.", ep->target.address, ep->target.endpoint);
     
    6968}
    7069
     70int xhci_device_init(xhci_device_t *dev, xhci_bus_t *bus)
     71{
     72        memset(&dev->endpoints, 0, sizeof(dev->endpoints));
     73        dev->active_endpoint_count = 0;
     74        return EOK;
     75}
     76
     77void xhci_device_fini(xhci_device_t *dev)
     78{
     79        // TODO: Check that all endpoints are dead.
     80}
     81
     82int xhci_device_add_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
     83{
     84        assert(dev->address == ep->base.target.address);
     85        assert(!dev->endpoints[ep->base.target.endpoint]);
     86        assert(!ep->device);
     87
     88        ep->device = dev;
     89        dev->endpoints[ep->base.target.endpoint] = ep;
     90        ++dev->active_endpoint_count;
     91        return EOK;
     92}
     93
     94int xhci_device_remove_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
     95{
     96        assert(dev->address == ep->base.target.address);
     97        assert(dev->endpoints[ep->base.target.endpoint]);
     98        assert(dev == ep->device);
     99
     100        ep->device = NULL;
     101        dev->endpoints[ep->base.target.endpoint] = NULL;
     102        --dev->active_endpoint_count;
     103        return EOK;
     104}
     105
     106xhci_endpoint_t * xhci_device_get_endpoint(xhci_device_t *dev, usb_endpoint_t ep)
     107{
     108        return dev->endpoints[ep];
     109}
     110
    71111/**
    72112 * @}
Note: See TracChangeset for help on using the changeset viewer.