Changeset 7dd3318 in mainline for uspace/drv/uhci-hcd/transfer_list.c
- Timestamp:
- 2011-02-12T02:00:54Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 83c439c
- Parents:
- f6309b6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/transfer_list.c
rf6309b6 r7dd3318 51 51 52 52 queue_head_init(instance->queue_head); 53 list_initialize(&instance->tracker_list); 53 54 return EOK; 54 55 } … … 58 59 assert(instance); 59 60 assert(next); 60 instance->next = next;61 61 if (!instance->queue_head) 62 62 return; 63 queue_head_a dd_next(instance->queue_head, next->queue_head_pa);63 queue_head_append_qh(instance->queue_head, next->queue_head_pa); 64 64 } 65 65 /*----------------------------------------------------------------------------*/ … … 69 69 assert(tracker); 70 70 71 uint32_t pa = (uintptr_t)addr_to_phys(tracker-> td);71 uint32_t pa = (uintptr_t)addr_to_phys(tracker->qh); 72 72 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 73 pa |= LINK_POINTER_QUEUE_HEAD_FLAG; 73 74 74 75 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) { 78 77 /* there is nothing scheduled */ 79 instance->last_tracker = tracker;78 list_append(&tracker->link, &instance->tracker_list); 80 79 instance->queue_head->element = pa; 81 usb_log_debug2("Added t d(%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); 83 82 return; 84 83 } 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 ); 101 94 } 102 95 /*----------------------------------------------------------------------------*/ 103 void transfer_list_remove_tracker(transfer_list_t *instance, tracker_t *tracker) 96 static void transfer_list_remove_tracker( 97 transfer_list_t *instance, tracker_t *tracker) 104 98 { 105 99 assert(instance); 106 100 assert(tracker); 107 101 assert(instance->queue_head); 108 assert(tracker-> td);102 assert(tracker->qh); 109 103 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 /*----------------------------------------------------------------------------*/ 118 void 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; 113 131 } 114 132 }
Note:
See TracChangeset
for help on using the changeset viewer.