Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/endpoint_list.c

    rd736fe38 r4125b7d  
    3434#include <errno.h>
    3535#include <usb/debug.h>
    36 #include <arch/barrier.h>
    3736
    3837#include "endpoint_list.h"
     
    4443 * @return Error code
    4544 *
    46  * Allocates memory for internal ed_t structure.
     45 * Allocates memory for internal qh_t structure.
    4746 */
    4847int endpoint_list_init(endpoint_list_t *instance, const char *name)
     
    6968 * @param[in] instance List to lead.
    7069 * @param[in] next List to append.
    71  *
    72  * Does not check whether this replaces an existing list.
     70 * @return Error code
     71 *
     72 * Does not check whether this replaces an existing list .
    7373 */
    7474void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next)
     
    7979}
    8080/*----------------------------------------------------------------------------*/
    81 /** Add endpoint to the list and queue.
    82  *
    83  * @param[in] instance List to use.
    84  * @param[in] endpoint Endpoint to add.
     81/** Submit transfer endpoint to the list and queue.
     82 *
     83 * @param[in] instance List to use.
     84 * @param[in] endpoint Transfer endpoint to submit.
     85 * @return Error code
    8586 *
    8687 * The endpoint is added to the end of the list and queue.
     
    9899        /* Add to the hardware queue. */
    99100        if (list_empty(&instance->endpoint_list)) {
    100                 /* There are no active EDs */
     101                /* There is nothing scheduled */
    101102                last_ed = instance->list_head;
    102103        } else {
    103                 /* There are active EDs, get the last one */
     104                /* There is something scheduled */
    104105                hcd_endpoint_t *last = list_get_instance(
    105106                    instance->endpoint_list.prev, hcd_endpoint_t, link);
    106                 assert(last);
    107107                last_ed = last->ed;
    108108        }
    109         /* Keep link */
     109        /* keep link */
    110110        hcd_ep->ed->next = last_ed->next;
    111         /* Make sure ED is written to the memory */
    112         write_barrier();
    113 
    114         /* Add ed to the hw queue */
    115111        ed_append_ed(last_ed, hcd_ep->ed);
    116         /* Make sure ED is updated */
    117         write_barrier();
    118 
    119         /* Add to the sw list */
     112
     113        asm volatile ("": : :"memory");
     114
     115        /* Add to the driver list */
    120116        list_append(&hcd_ep->link, &instance->endpoint_list);
    121117
     
    133129}
    134130/*----------------------------------------------------------------------------*/
    135 /** Remove endpoint from the list and queue.
    136  *
    137  * @param[in] instance List to use.
    138  * @param[in] endpoint Endpoint to remove.
     131#if 0
     132/** Create list for finished endpoints.
     133 *
     134 * @param[in] instance List to use.
     135 * @param[in] done list to fill
     136 */
     137void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done)
     138{
     139        assert(instance);
     140        assert(done);
     141
     142        fibril_mutex_lock(&instance->guard);
     143        usb_log_debug2("Checking list %s for completed endpointes(%d).\n",
     144            instance->name, list_count(&instance->endpoint_list));
     145        link_t *current = instance->endpoint_list.next;
     146        while (current != &instance->endpoint_list) {
     147                link_t *next = current->next;
     148                hcd_endpoint_t *endpoint =
     149                    list_get_instance(current, hcd_endpoint_t, link);
     150
     151                if (endpoint_is_complete(endpoint)) {
     152                        /* Save for post-processing */
     153                        endpoint_list_remove_endpoint(instance, endpoint);
     154                        list_append(current, done);
     155                }
     156                current = next;
     157        }
     158        fibril_mutex_unlock(&instance->guard);
     159}
     160/*----------------------------------------------------------------------------*/
     161/** Walk the list and abort all endpointes.
     162 *
     163 * @param[in] instance List to use.
     164 */
     165void endpoint_list_abort_all(endpoint_list_t *instance)
     166{
     167        fibril_mutex_lock(&instance->guard);
     168        while (!list_empty(&instance->endpoint_list)) {
     169                link_t *current = instance->endpoint_list.next;
     170                hcd_endpoint_t *endpoint =
     171                    list_get_instance(current, hcd_endpoint_t, link);
     172                endpoint_list_remove_endpoint(instance, endpoint);
     173                hcd_endpoint_finish_error(endpoint, EIO);
     174        }
     175        fibril_mutex_unlock(&instance->guard);
     176}
     177#endif
     178/*----------------------------------------------------------------------------*/
     179/** Remove a transfer endpoint from the list and queue.
     180 *
     181 * @param[in] instance List to use.
     182 * @param[in] endpoint Transfer endpoint to remove.
     183 * @return Error code
     184 *
     185 * Does not lock the transfer list, caller is responsible for that.
    139186 */
    140187void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)
     
    165212        assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(hcd_ep->ed));
    166213        prev_ed->next = hcd_ep->ed->next;
    167         /* Make sure ED is updated */
    168         write_barrier();
    169 
     214
     215        asm volatile ("": : :"memory");
    170216        usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n",
    171217            hcd_ep, qpos, instance->name, hcd_ep->ed->next);
Note: See TracChangeset for help on using the changeset viewer.