Changeset 7dd3318 in mainline for uspace/drv/uhci-hcd/transfer_list.c


Ignore:
Timestamp:
2011-02-12T02:00:54Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
83c439c
Parents:
f6309b6
Message:

Add support for batch processing

File:
1 edited

Legend:

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

    rf6309b6 r7dd3318  
    5151
    5252        queue_head_init(instance->queue_head);
     53        list_initialize(&instance->tracker_list);
    5354        return EOK;
    5455}
     
    5859        assert(instance);
    5960        assert(next);
    60         instance->next = next;
    6161        if (!instance->queue_head)
    6262                return;
    63         queue_head_add_next(instance->queue_head, next->queue_head_pa);
     63        queue_head_append_qh(instance->queue_head, next->queue_head_pa);
    6464}
    6565/*----------------------------------------------------------------------------*/
     
    6969        assert(tracker);
    7070
    71         uint32_t pa = (uintptr_t)addr_to_phys(tracker->td);
     71        uint32_t pa = (uintptr_t)addr_to_phys(tracker->qh);
    7272        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     73        pa |= LINK_POINTER_QUEUE_HEAD_FLAG;
    7374
    7475
    75         if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
    76                 usb_log_debug2("Adding td(%X:%X) to queue %s first.\n",
    77                         tracker->td->status, tracker->td->device, instance->name);
     76        if ((instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) != 0) {
    7877                /* there is nothing scheduled */
    79                 instance->last_tracker = tracker;
     78                list_append(&tracker->link, &instance->tracker_list);
    8079                instance->queue_head->element = pa;
    81                 usb_log_debug2("Added td(%X:%X) to queue %s first.\n",
    82                         tracker->td->status, tracker->td->device, instance->name);
     80                usb_log_debug2("Added tracker(%p) to queue %s first.\n",
     81                        tracker, instance->name);
    8382                return;
    8483        }
    85         usb_log_debug2("Adding td(%X:%X) to queue %s last.%p\n",
    86             tracker->td->status, tracker->td->device, instance->name,
    87             instance->last_tracker);
    88         /* now we can be sure that last_tracker is a valid pointer */
    89         instance->last_tracker->td->next = pa;
    90         instance->last_tracker = tracker;
    91 
    92         usb_log_debug2("Added td(%X:%X) to queue %s last.\n",
    93                 tracker->td->status, tracker->td->device, instance->name);
    94 
    95         /* check again, may be use atomic compare and swap */
    96         if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
    97                 instance->queue_head->element = pa;
    98                 usb_log_debug2("Added td(%X:%X) to queue first2 %s.\n",
    99                         tracker->td->status, tracker->td->device, instance->name);
    100         }
     84        /* now we can be sure that there is someting scheduled */
     85        assert(!list_empty(&instance->tracker_list));
     86        tracker_t *first = list_get_instance(
     87                  instance->tracker_list.next, tracker_t, link);
     88        tracker_t *last = list_get_instance(
     89            instance->tracker_list.prev, tracker_t, link);
     90        queue_head_append_qh(last->qh, pa);
     91        list_append(&tracker->link, &instance->tracker_list);
     92        usb_log_debug2("Added tracker(%p) to queue %s last, first is %p.\n",
     93                tracker, instance->name, first );
    10194}
    10295/*----------------------------------------------------------------------------*/
    103 void transfer_list_remove_tracker(transfer_list_t *instance, tracker_t *tracker)
     96static void transfer_list_remove_tracker(
     97    transfer_list_t *instance, tracker_t *tracker)
    10498{
    10599        assert(instance);
    106100        assert(tracker);
    107101        assert(instance->queue_head);
    108         assert(tracker->td);
     102        assert(tracker->qh);
    109103
    110         uint32_t pa = (uintptr_t)addr_to_phys(tracker->td);
    111         if ((instance->queue_head->element & LINK_POINTER_ADDRESS_MASK) == pa) {
    112                 instance->queue_head->element = tracker->td->next;
     104        /* I'm the first one here */
     105        if (tracker->link.next == &instance->tracker_list) {
     106                usb_log_debug("Removing tracer %p was first, next element %x.\n",
     107                        tracker, tracker->qh->next_queue);
     108                instance->queue_head->element = tracker->qh->next_queue;
     109        } else {
     110                usb_log_debug("Removing tracer %p was NOT first, next element %x.\n",
     111                        tracker, tracker->qh->next_queue);
     112                tracker_t *prev = list_get_instance(tracker->link.prev, tracker_t, link);
     113                prev->qh->next_queue = tracker->qh->next_queue;
     114        }
     115        list_remove(&tracker->link);
     116}
     117/*----------------------------------------------------------------------------*/
     118void transfer_list_check(transfer_list_t *instance)
     119{
     120        assert(instance);
     121        link_t *current = instance->tracker_list.next;
     122        while (current != &instance->tracker_list) {
     123                link_t *next = current->next;
     124                tracker_t *tracker = list_get_instance(current, tracker_t, link);
     125
     126                if (tracker_is_complete(tracker)) {
     127                        transfer_list_remove_tracker(instance, tracker);
     128                        tracker->next_step(tracker);
     129                }
     130                current = next;
    113131        }
    114132}
Note: See TracChangeset for help on using the changeset viewer.