Changeset 62f4212 in mainline for uspace/drv/uhci-hcd/transfer_list.c
- Timestamp:
- 2011-03-22T10:07:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f8e4cb6
- Parents:
- 18b3cfd (diff), b01995b (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
r18b3cfd r62f4212 38 38 39 39 static void transfer_list_remove_batch( 40 transfer_list_t *instance, batch_t *batch);40 transfer_list_t *instance, usb_transfer_batch_t *batch); 41 41 /*----------------------------------------------------------------------------*/ 42 42 /** Initialize transfer list structures. … … 79 79 if (!instance->queue_head) 80 80 return; 81 /* Set both next and element to point to the same QH*/81 /* Set both queue_head.next to point to the follower */ 82 82 qh_set_next_qh(instance->queue_head, next->queue_head_pa); 83 qh_set_element_qh(instance->queue_head, next->queue_head_pa);84 83 } 85 84 /*----------------------------------------------------------------------------*/ … … 92 91 * The batch is added to the end of the list and queue. 93 92 */ 94 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch)93 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 95 94 { 96 95 assert(instance); … … 98 97 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch); 99 98 100 const uint32_t pa = addr_to_phys(batch->qh);101 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);102 103 /* New batch will be added to the end of the current list104 * so set the link accordingly */105 qh_set_next_qh(batch->qh, instance->queue_head->next);106 107 99 fibril_mutex_lock(&instance->guard); 108 100 101 qh_t *last_qh = NULL; 109 102 /* Add to the hardware queue. */ 110 103 if (list_empty(&instance->batch_list)) { 111 104 /* There is nothing scheduled */ 112 qh_t *qh = instance->queue_head; 113 assert(qh->element == qh->next); 114 qh_set_element_qh(qh, pa); 105 last_qh = instance->queue_head; 115 106 } else { 116 107 /* There is something scheduled */ 117 batch_t *last = list_get_instance( 118 instance->batch_list.prev, batch_t, link); 119 qh_set_next_qh(last->qh, pa); 120 } 108 usb_transfer_batch_t *last = list_get_instance( 109 instance->batch_list.prev, usb_transfer_batch_t, link); 110 last_qh = batch_qh(last); 111 } 112 const uint32_t pa = addr_to_phys(batch_qh(batch)); 113 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 114 115 /* keep link */ 116 batch_qh(batch)->next = last_qh->next; 117 qh_set_next_qh(last_qh, pa); 118 121 119 /* Add to the driver list */ 122 120 list_append(&batch->link, &instance->batch_list); 123 121 124 batch_t *first = list_get_instance(125 instance->batch_list.next, batch_t, link);122 usb_transfer_batch_t *first = list_get_instance( 123 instance->batch_list.next, usb_transfer_batch_t, link); 126 124 usb_log_debug("Batch(%p) added to queue %s, first is %p.\n", 127 125 batch, instance->name, first); … … 148 146 while (current != &instance->batch_list) { 149 147 link_t *next = current->next; 150 batch_t *batch = list_get_instance(current,batch_t, link);148 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 151 149 152 150 if (batch_is_complete(batch)) { … … 162 160 link_t *item = done.next; 163 161 list_remove(item); 164 batch_t *batch = list_get_instance(item,batch_t, link);162 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link); 165 163 batch->next_step(batch); 166 164 } … … 174 172 { 175 173 fibril_mutex_lock(&instance->guard); 176 while ( list_empty(&instance->batch_list)) {174 while (!list_empty(&instance->batch_list)) { 177 175 link_t *current = instance->batch_list.next; 178 batch_t *batch = list_get_instance(current,batch_t, link);176 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link); 179 177 transfer_list_remove_batch(instance, batch); 180 batch_abort(batch);178 usb_transfer_batch_finish(batch, EIO); 181 179 } 182 180 fibril_mutex_unlock(&instance->guard); … … 191 189 * Does not lock the transfer list, caller is responsible for that. 192 190 */ 193 void transfer_list_remove_batch(transfer_list_t *instance, batch_t *batch) 194 { 195 assert(instance); 191 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch) 192 { 193 assert(instance); 194 assert(instance->queue_head); 196 195 assert(batch); 197 assert(instance->queue_head); 198 assert(batch->qh); 196 assert(batch_qh(batch)); 197 assert(fibril_mutex_is_locked(&instance->guard)); 198 199 199 usb_log_debug2( 200 200 "Queue %s: removing batch(%p).\n", instance->name, batch); 201 201 202 const char * 202 const char *qpos = NULL; 203 203 /* Remove from the hardware queue */ 204 if ( batch->link.prev == &instance->batch_list) {204 if (instance->batch_list.next == &batch->link) { 205 205 /* I'm the first one here */ 206 qh_set_element_qh(instance->queue_head, batch->qh->next); 207 pos = "FIRST"; 206 assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK) 207 == addr_to_phys(batch_qh(batch))); 208 instance->queue_head->next = batch_qh(batch)->next; 209 qpos = "FIRST"; 208 210 } else { 209 batch_t *prev = 210 list_get_instance(batch->link.prev, batch_t, link); 211 qh_set_next_qh(prev->qh, batch->qh->next); 212 pos = "NOT FIRST"; 213 } 214 /* Remove from the driver list */ 211 usb_transfer_batch_t *prev = 212 list_get_instance(batch->link.prev, usb_transfer_batch_t, link); 213 assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK) 214 == addr_to_phys(batch_qh(batch))); 215 batch_qh(prev)->next = batch_qh(batch)->next; 216 qpos = "NOT FIRST"; 217 } 218 /* Remove from the batch list */ 215 219 list_remove(&batch->link); 216 usb_log_debug("Batch(%p) removed (%s) from %s, next element%x.\n",217 batch, pos, instance->name, batch->qh->next);220 usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n", 221 batch, qpos, instance->name, batch_qh(batch)->next); 218 222 } 219 223 /**
Note:
See TracChangeset
for help on using the changeset viewer.