Changeset d15809b4 in mainline for uspace/drv/uhci-hcd/transfer_list.c
- Timestamp:
- 2011-02-14T10:14:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 962ce100
- Parents:
- 0d36c20 (diff), 45c01a1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/transfer_list.c
r0d36c20 rd15809b4 51 51 52 52 queue_head_init(instance->queue_head); 53 list_initialize(&instance->batch_list); 54 fibril_mutex_initialize(&instance->guard); 53 55 return EOK; 54 56 } … … 58 60 assert(instance); 59 61 assert(next); 60 instance->next = next;61 62 if (!instance->queue_head) 62 63 return; 63 queue_head_add_next(instance->queue_head, next->queue_head_pa); 64 queue_head_append_qh(instance->queue_head, next->queue_head_pa); 65 instance->queue_head->element = instance->queue_head->next_queue; 64 66 } 65 67 /*----------------------------------------------------------------------------*/ 66 void transfer_list_add_ tracker(transfer_list_t *instance, tracker_t *tracker)68 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch) 67 69 { 68 70 assert(instance); 69 assert( tracker);71 assert(batch); 70 72 71 uint32_t pa = (uintptr_t)addr_to_phys( tracker->td);73 uint32_t pa = (uintptr_t)addr_to_phys(batch->qh); 72 74 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 75 pa |= LINK_POINTER_QUEUE_HEAD_FLAG; 73 76 77 batch->qh->next_queue = instance->queue_head->next_queue; 74 78 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);79 fibril_mutex_lock(&instance->guard); 80 81 if (instance->queue_head->element == instance->queue_head->next_queue) { 78 82 /* there is nothing scheduled */ 79 instance->last_tracker = tracker;83 list_append(&batch->link, &instance->batch_list); 80 84 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); 85 usb_log_debug2("Added batch(%p) to queue %s first.\n", 86 batch, instance->name); 87 fibril_mutex_unlock(&instance->guard); 83 88 return; 84 89 } 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; 90 /* now we can be sure that there is someting scheduled */ 91 assert(!list_empty(&instance->batch_list)); 92 batch_t *first = list_get_instance( 93 instance->batch_list.next, batch_t, link); 94 batch_t *last = list_get_instance( 95 instance->batch_list.prev, batch_t, link); 96 queue_head_append_qh(last->qh, pa); 97 list_append(&batch->link, &instance->batch_list); 98 usb_log_debug2("Added batch(%p) to queue %s last, first is %p.\n", 99 batch, instance->name, first ); 100 fibril_mutex_unlock(&instance->guard); 101 } 102 /*----------------------------------------------------------------------------*/ 103 static void transfer_list_remove_batch( 104 transfer_list_t *instance, batch_t *batch) 105 { 106 assert(instance); 107 assert(batch); 108 assert(instance->queue_head); 109 assert(batch->qh); 91 110 92 usb_log_debug2("Added td(%X:%X) to queue %s last.\n", 93 tracker->td->status, tracker->td->device, instance->name); 111 /* I'm the first one here */ 112 if (batch->link.prev == &instance->batch_list) { 113 usb_log_debug("Removing tracer %p was first, next element %x.\n", 114 batch, batch->qh->next_queue); 115 instance->queue_head->element = batch->qh->next_queue; 116 } else { 117 usb_log_debug("Removing tracer %p was NOT first, next element %x.\n", 118 batch, batch->qh->next_queue); 119 batch_t *prev = list_get_instance(batch->link.prev, batch_t, link); 120 prev->qh->next_queue = batch->qh->next_queue; 121 } 122 list_remove(&batch->link); 123 } 124 /*----------------------------------------------------------------------------*/ 125 void transfer_list_check(transfer_list_t *instance) 126 { 127 assert(instance); 128 fibril_mutex_lock(&instance->guard); 129 link_t *current = instance->batch_list.next; 130 while (current != &instance->batch_list) { 131 link_t *next = current->next; 132 batch_t *batch = list_get_instance(current, batch_t, link); 94 133 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);134 if (batch_is_complete(batch)) { 135 transfer_list_remove_batch(instance, batch); 136 batch->next_step(batch); 137 } 138 current = next; 100 139 } 140 fibril_mutex_unlock(&instance->guard); 101 141 } 102 142 /**
Note:
See TracChangeset
for help on using the changeset viewer.