Changeset 3de7a62 in mainline


Ignore:
Timestamp:
2014-01-24T01:24:58Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e732f1a
Parents:
a24d6825
Message:

ehci: Implement endpoint list append

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

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_endpoint.h

    ra24d6825 r3de7a62  
    6666}
    6767
     68static inline ehci_endpoint_t * ehci_endpoint_list_instance(link_t *l)
     69{
     70        return list_get_instance(l, ehci_endpoint_t, link);
     71}
     72
    6873#endif
    6974/**
  • uspace/drv/bus/usb/ehci/endpoint_list.c

    ra24d6825 r3de7a62  
    6464            name, instance->list_head, instance->list_head_pa);
    6565
    66 //      qh_init(instance->list_head, NULL, NULL);
     66        qh_init(instance->list_head, NULL);
    6767        list_initialize(&instance->endpoint_list);
    6868        fibril_mutex_initialize(&instance->guard);
     
    7070}
    7171
    72 /** Add endpoint to the list and queue.
     72/** Add endpoint to the end of the list and queue.
    7373 *
    7474 * @param[in] instance List to use.
     
    7777 * The endpoint is added to the end of the list and queue.
    7878 */
    79 void endpoint_list_add_ep(endpoint_list_t *instance, ehci_endpoint_t *ep)
     79void endpoint_list_append_ep(endpoint_list_t *instance, ehci_endpoint_t *ep)
    8080{
    8181        assert(instance);
    8282        assert(ep);
     83        assert(ep->qh);
    8384        usb_log_debug2("Queue %s: Adding endpoint(%p).\n", instance->name, ep);
    8485
    8586        fibril_mutex_lock(&instance->guard);
    8687
    87 #if 0
    88         //TODO Implement this
    89         ed_t *last_ed = NULL;
     88        qh_t *last_qh = NULL;
    9089        /* Add to the hardware queue. */
    9190        if (list_empty(&instance->endpoint_list)) {
    9291                /* There are no active EDs */
    93                 last_ed = instance->list_head;
     92                last_qh = instance->list_head;
    9493        } else {
    9594                /* There are active EDs, get the last one */
    96                 ehci_endpoint_t *last = list_get_instance(
    97                     list_last(&instance->endpoint_list), ehci_endpoint_t, link);
    98                 last_ed = last->ed;
     95                ehci_endpoint_t *last = ehci_endpoint_list_instance(
     96                    list_last(&instance->endpoint_list));
     97                last_qh = last->qh;
    9998        }
     99        assert(last_qh);
    100100        /* Keep link */
    101         ep->ed->next = last_ed->next;
    102         /* Make sure ED is written to the memory */
     101        ep->qh->horizontal = last_qh->horizontal;
     102        /* Make sure QH update is written to the memory */
    103103        write_barrier();
    104104
    105105        /* Add ed to the hw queue */
    106         ed_append_ed(last_ed, ep->ed);
     106        qh_append_qh(last_qh, ep->qh);
    107107        /* Make sure ED is updated */
    108108        write_barrier();
     
    110110        list_append(&ep->link, &instance->endpoint_list);
    111111
    112         ehci_endpoint_t *first = list_get_instance(
    113             list_first(&instance->endpoint_list), ehci_endpoint_t, link);
     112        ehci_endpoint_t *first = ehci_endpoint_list_instance(
     113            list_first(&instance->endpoint_list));
    114114        usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n",
    115                 ep, instance->name, first, first->ed);
    116         if (last_ed == instance->list_head) {
    117                 usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.\n",
    118                     instance->name, last_ed, instance->list_head_pa,
    119                     last_ed->status, last_ed->td_tail, last_ed->td_head,
    120                     last_ed->next);
     115                ep, instance->name, first, first->qh);
     116        if (last_qh == instance->list_head) {
     117                usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x.\n",
     118                    instance->name, last_qh, instance->list_head_pa,
     119                    last_qh->status, last_qh->horizontal);
    121120        }
    122 #endif
    123121        fibril_mutex_unlock(&instance->guard);
    124122}
     
    153151                qpos = "NOT FIRST";
    154152        }
    155 //      assert(ed_next(prev_qh) == addr_to_phys(ep->eq));
     153        assert(qh_next(prev_qh) == addr_to_phys(ep->qh));
    156154        prev_qh->next = ep->qh->next;
    157155        /* Make sure ED is updated */
  • uspace/drv/bus/usb/ehci/endpoint_list.h

    ra24d6825 r3de7a62  
    6969        free32(instance->list_head);
    7070        instance->list_head = NULL;
     71        instance->list_head_pa = 0;
    7172}
    7273
    7374int endpoint_list_init(endpoint_list_t *instance, const char *name);
    74 void endpoint_list_set_next(
    75     const endpoint_list_t *instance, const endpoint_list_t *next);
    76 void endpoint_list_add_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
     75void endpoint_list_append_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
    7776void endpoint_list_remove_ep(endpoint_list_t *instance, ehci_endpoint_t *ep);
    7877#endif
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    ra24d6825 r3de7a62  
    4040
    4141#include "link_pointer.h"
     42#include "mem_access.h"
    4243
    4344/** This structure is defined in EHCI design guide p. 46 */
     
    140141} qh_t;
    141142
     143static inline void qh_append_qh(qh_t *qh, const qh_t *next)
     144{
     145        assert(qh);
     146        assert(next);
     147        const uint32_t pa = addr_to_phys(next);
     148        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     149        EHCI_MEM32_WR(qh->horizontal, LINK_POINTER_QH(pa));
     150}
     151
     152static inline uintptr_t qh_next(const qh_t *qh)
     153{
     154        assert(qh);
     155        return (qh->horizontal & LINK_POINTER_ADDRESS_MASK);
     156}
     157
    142158void qh_init(qh_t *instance, const endpoint_t *ep);
    143159#endif
Note: See TracChangeset for help on using the changeset viewer.