Changeset 176a70a in mainline


Ignore:
Timestamp:
2017-08-17T17:49:32Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d3dce3f
Parents:
c0ec9e7
Message:

Simple implementation of endpoint management with slot id's.

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

Legend:

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

    rc0ec9e7 r176a70a  
    4040int endpoint_init(hcd_t *hcd, endpoint_t *ep)
    4141{
    42         // TODO: Implement me!
    43         usb_log_debug("Endpoint initialized.");
    44         return ENAK;
     42        assert(ep);
     43        xhci_endpoint_t *xhci_ep = malloc(sizeof(xhci_endpoint_t));
     44        if (xhci_ep == NULL)
     45                return ENOMEM;
     46
     47        /* FIXME: Set xhci_ep->slot_id */
     48
     49        fibril_mutex_lock(&ep->guard);
     50        ep->hc_data.data = xhci_ep;
     51        /* FIXME: The two handlers below should be implemented. */
     52        ep->hc_data.toggle_get = NULL;
     53        ep->hc_data.toggle_set = NULL;
     54        fibril_mutex_unlock(&ep->guard);
     55
     56        usb_log_debug("Endpoint %d:%d initialized.", ep->address, ep->endpoint);
     57        return EOK;
    4558}
    4659
    4760void endpoint_fini(hcd_t *hcd, endpoint_t *ep)
    4861{
    49         // TODO: Implement me!
    50         usb_log_debug("Endpoint destroyed.");
     62        assert(hcd);
     63        assert(ep);
     64        xhci_endpoint_t *xhci_ep = endpoint_get(ep);
     65        /* FIXME: Tear down TR's? */
     66        if (xhci_ep) {
     67                free(xhci_ep);
     68        }
     69
     70        usb_log_debug("Endpoint %d:%d destroyed.", ep->address, ep->endpoint);
    5171}
    5272
  • uspace/drv/bus/usb/xhci/endpoint.h

    rc0ec9e7 r176a70a  
    4343#include <usb/host/hcd.h>
    4444
     45/** Connector structure linking endpoint context to the endpoint. */
     46typedef struct xhci_endpoint {
     47  uint32_t slot_id;
     48} xhci_endpoint_t;
     49
    4550int endpoint_init(hcd_t *hcd, endpoint_t *ep);
    4651void endpoint_fini(hcd_t *hcd, endpoint_t *ep);
     52
     53static inline xhci_endpoint_t * endpoint_get(const endpoint_t *ep)
     54{
     55  assert(ep);
     56        return ep->hc_data.data;
     57}
    4758
    4859#endif
Note: See TracChangeset for help on using the changeset viewer.