Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/transfer_list.c

    r4c70554 r4fd3faf  
    5757                return ENOMEM;
    5858        }
    59         uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
     59        instance->queue_head_pa = addr_to_phys(instance->queue_head);
    6060        usb_log_debug2("Transfer list %s setup with QH: %p(%p).\n",
    61             name, instance->queue_head, queue_head_pa);
     61            name, instance->queue_head, instance->queue_head_pa);
    6262
    6363        qh_init(instance->queue_head);
     
    6767}
    6868/*----------------------------------------------------------------------------*/
    69 /** Dispose transfer list structures.
    70  *
    71  * @param[in] instance Memory place to use.
    72  *
    73  * Frees memory for internal qh_t structure.
    74  */
    75 void transfer_list_fini(transfer_list_t *instance)
    76 {
    77         assert(instance);
    78         free32(instance->queue_head);
    79 }
    8069/** Set the next list in transfer list chain.
    8170 *
     
    9281        if (!instance->queue_head)
    9382                return;
    94         /* Set queue_head.next to point to the follower */
    95         qh_set_next_qh(instance->queue_head, next->queue_head);
    96 }
    97 /*----------------------------------------------------------------------------*/
    98 /** Add transfer batch to the list and queue.
     83        /* Set both queue_head.next to point to the follower */
     84        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
     85}
     86/*----------------------------------------------------------------------------*/
     87/** Submit transfer batch to the list and queue.
    9988 *
    10089 * @param[in] instance List to use.
    10190 * @param[in] batch Transfer batch to submit.
     91 * @return Error code
    10292 *
    10393 * The batch is added to the end of the list and queue.
     
    119109        } else {
    120110                /* There is something scheduled */
    121                 usb_transfer_batch_t *last =
    122                     usb_transfer_batch_from_link(instance->batch_list.prev);
     111                usb_transfer_batch_t *last = list_get_instance(
     112                    instance->batch_list.prev, usb_transfer_batch_t, link);
    123113                last_qh = batch_qh(last);
    124114        }
     
    128118        /* keep link */
    129119        batch_qh(batch)->next = last_qh->next;
    130         qh_set_next_qh(last_qh, batch_qh(batch));
     120        qh_set_next_qh(last_qh, pa);
    131121
    132122        asm volatile ("": : :"memory");
     
    142132}
    143133/*----------------------------------------------------------------------------*/
    144 /** Add completed bantches to the provided list.
     134/** Create list for finished batches.
    145135 *
    146136 * @param[in] instance List to use.
     
    157147                link_t *next = current->next;
    158148                usb_transfer_batch_t *batch =
    159                     usb_transfer_batch_from_link(current);
     149                    list_get_instance(current, usb_transfer_batch_t, link);
    160150
    161151                if (batch_is_complete(batch)) {
    162                         /* Save for processing */
     152                        /* Save for post-processing */
    163153                        transfer_list_remove_batch(instance, batch);
    164154                        list_append(current, done);
     
    169159}
    170160/*----------------------------------------------------------------------------*/
    171 /** Walk the list and finish all batches with EINTR.
     161/** Walk the list and abort all batches.
    172162 *
    173163 * @param[in] instance List to use.
     
    179169                link_t *current = instance->batch_list.next;
    180170                usb_transfer_batch_t *batch =
    181                     usb_transfer_batch_from_link(current);
     171                    list_get_instance(current, usb_transfer_batch_t, link);
    182172                transfer_list_remove_batch(instance, batch);
    183                 usb_transfer_batch_finish_error(batch, EINTR);
     173                usb_transfer_batch_finish_error(batch, EIO);
    184174        }
    185175        fibril_mutex_unlock(&instance->guard);
     
    190180 * @param[in] instance List to use.
    191181 * @param[in] batch Transfer batch to remove.
     182 * @return Error code
    192183 *
    193184 * Does not lock the transfer list, caller is responsible for that.
     
    206197
    207198        const char *qpos = NULL;
    208         qh_t *prev_qh = NULL;
    209199        /* Remove from the hardware queue */
    210200        if (instance->batch_list.next == &batch->link) {
    211201                /* I'm the first one here */
    212                 prev_qh = instance->queue_head;
     202                assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
     203                    == addr_to_phys(batch_qh(batch)));
     204                instance->queue_head->next = batch_qh(batch)->next;
    213205                qpos = "FIRST";
    214206        } else {
    215                 /* The thing before me is a batch too */
    216207                usb_transfer_batch_t *prev =
    217                     usb_transfer_batch_from_link(batch->link.prev);
    218                 prev_qh = batch_qh(prev);
     208                    list_get_instance(
     209                        batch->link.prev, usb_transfer_batch_t, link);
     210                assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
     211                    == addr_to_phys(batch_qh(batch)));
     212                batch_qh(prev)->next = batch_qh(batch)->next;
    219213                qpos = "NOT FIRST";
    220214        }
    221         assert((prev_qh->next & LINK_POINTER_ADDRESS_MASK)
    222             == addr_to_phys(batch_qh(batch)));
    223         prev_qh->next = batch_qh(batch)->next;
    224215        asm volatile ("": : :"memory");
    225216        /* Remove from the batch list */
    226217        list_remove(&batch->link);
    227         usb_log_debug("Batch(%p) removed (%s) from %s, next: %x.\n",
     218        usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
    228219            batch, qpos, instance->name, batch_qh(batch)->next);
    229220}
Note: See TracChangeset for help on using the changeset viewer.