Changeset 5f5321ee in mainline


Ignore:
Timestamp:
2014-01-24T16:12:32Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
763dbcb
Parents:
dc44023
Message:

ehci: Implement endpoint list enqueue

Location:
uspace/drv/bus/usb/ehci
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/endpoint_list.c

    rdc44023 r5f5321ee  
    8282        assert(ep);
    8383        assert(ep->qh);
    84         usb_log_debug2("Queue %s: Adding endpoint(%p).\n", instance->name, ep);
     84        usb_log_debug2("Queue %s: Append endpoint(%p).\n", instance->name, ep);
    8585
    8686        fibril_mutex_lock(&instance->guard);
     
    103103        write_barrier();
    104104
    105         /* Add ed to the hw queue */
     105        /* Add QH to the hw queue */
    106106        qh_append_qh(last_qh, ep->qh);
    107         /* Make sure ED is updated */
     107        /* Make sure QH is updated */
    108108        write_barrier();
    109109        /* Add to the sw list */
     
    122122}
    123123
     124/** Add endpoint to the beginning of the list and queue.
     125 *
     126 * @param[in] instance List to use.
     127 * @param[in] endpoint Endpoint to add.
     128 *
     129 * The endpoint is added to the end of the list and queue.
     130 */
     131void endpoint_list_prepend_ep(endpoint_list_t *instance, ehci_endpoint_t *ep)
     132{
     133        assert(instance);
     134        assert(ep);
     135        assert(ep->qh);
     136        usb_log_debug2("Queue %s: Prepend endpoint(%p).\n", instance->name, ep);
     137
     138        fibril_mutex_lock(&instance->guard);
     139        ep->qh->horizontal = instance->list_head->horizontal;
     140        /* Make sure QH is updated */
     141        write_barrier();
     142        /* Add QH to the hw queue */
     143        qh_append_qh(instance->list_head, ep->qh);
     144        /* Add to the sw list */
     145        list_prepend(&ep->link, &instance->endpoint_list);
     146        fibril_mutex_unlock(&instance->guard);
     147
     148}
    124149/** Remove endpoint from the list and queue.
    125150 *
  • uspace/drv/bus/usb/ehci/endpoint_list.h

    rdc44023 r5f5321ee  
    7474int endpoint_list_init(endpoint_list_t *instance, const char *name);
    7575void endpoint_list_append_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
     76void endpoint_list_prepend_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
    7677void endpoint_list_remove_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
    7778#endif
  • uspace/drv/bus/usb/ehci/hc.c

    rdc44023 r5f5321ee  
    198198{
    199199        assert(instance);
    200         /* TODO: implement*/
     200        //TODO: stop the hw
     201#if 0
     202        endpoint_list_fini(&instance->async_list);
     203        endpoint_list_fini(&instance->int_list);
     204        return_page(instance->periodic_list_base);
     205#endif
    201206};
    202207
    203208void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
    204209{
     210        assert(instance);
     211        assert(ep);
     212        ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
     213        switch (ep->transfer_type)
     214        {
     215        case USB_TRANSFER_CONTROL:
     216                endpoint_list_prepend_ep(&instance->async_list, ehci_ep);
     217                break;
     218        case USB_TRANSFER_BULK:
     219                endpoint_list_append_ep(&instance->async_list, ehci_ep);
     220                break;
     221        case USB_TRANSFER_INTERRUPT:
     222                endpoint_list_append_ep(&instance->int_list, ehci_ep);
     223                break;
     224        case USB_TRANSFER_ISOCHRONOUS:
     225                /* NOT SUPPORTED */
     226                break;
     227        }
    205228}
    206229
     
    343366{
    344367        assert(instance);
     368        int ret = endpoint_list_init(&instance->async_list, "ASYNC");
     369        if (ret != EOK) {
     370                usb_log_error("Failed to setup ASYNC list: %s", str_error(ret));
     371                return ret;
     372        }
     373
     374        ret = endpoint_list_init(&instance->int_list, "INT");
     375        if (ret != EOK) {
     376                usb_log_error("Failed to setup INT list: %s", str_error(ret));
     377                endpoint_list_fini(&instance->async_list);
     378                return ret;
     379        }
    345380
    346381        /* Take 1024 periodic list heads, we ignore low mem options */
    347382        instance->periodic_list_base = get_page();
    348         if (!instance->periodic_list_base)
     383        if (!instance->periodic_list_base) {
     384                usb_log_error("Failed to get ISO schedule page.");
     385                endpoint_list_fini(&instance->async_list);
     386                endpoint_list_fini(&instance->int_list);
    349387                return ENOMEM;
     388        }
    350389        for (unsigned i = 0;
    351390            i < PAGE_SIZE/sizeof(instance->periodic_list_base[0]); ++i)
    352391        {
    353392                /* Disable everything for now */
    354                 instance->periodic_list_base[i] = LINK_POINTER_TERM;
     393                instance->periodic_list_base[i] =
     394                    LINK_POINTER_QH(instance->int_list.list_head_pa);
    355395        }
    356396        return EOK;
  • uspace/drv/bus/usb/ehci/hc.h

    rdc44023 r5f5321ee  
    5151#include "ehci_rh.h"
    5252#include "hw_struct/link_pointer.h"
    53 //#include "endpoint_list.h"
     53#include "endpoint_list.h"
    5454
    5555/** Main EHCI driver structure */
     
    6363        link_pointer_t *periodic_list_base;
    6464
    65         /** Transfer schedules */
    66 //      endpoint_list_t lists[4];
     65        /** CONTROL and BULK schedules */
     66        endpoint_list_t async_list;
     67
     68        /** INT schedule */
     69        endpoint_list_t int_list;
     70
    6771        /** List of active transfers */
    6872        list_t pending_batches;
Note: See TracChangeset for help on using the changeset viewer.