Changeset 00aece0 in mainline for uspace/drv/bus/usb/uhci/transfer_list.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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/bus/usb/uhci/transfer_list.c
rbd5f3b7 r00aece0 37 37 #include <usb/debug.h> 38 38 #include <libarch/barrier.h> 39 39 40 #include "transfer_list.h" 40 #include "batch.h"41 41 42 42 static void transfer_list_remove_batch( 43 transfer_list_t *instance, u sb_transfer_batch_t *batch);43 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch); 44 44 /*----------------------------------------------------------------------------*/ 45 45 /** Initialize transfer list structures. … … 106 106 */ 107 107 void transfer_list_add_batch( 108 transfer_list_t *instance, usb_transfer_batch_t *batch) 109 { 110 assert(instance); 111 assert(batch); 112 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch); 108 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch) 109 { 110 assert(instance); 111 assert(uhci_batch); 112 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, 113 uhci_batch->usb_batch); 113 114 114 115 fibril_mutex_lock(&instance->guard); 115 116 116 qh_t *last_qh = NULL; 117 /* Assume there is nothing scheduled */ 118 qh_t *last_qh = instance->queue_head; 119 /* There is something scheduled */ 120 if (!list_empty(&instance->batch_list)) { 121 last_qh = uhci_transfer_batch_from_link( 122 list_last(&instance->batch_list))->qh; 123 } 117 124 /* Add to the hardware queue. */ 118 if (list_empty(&instance->batch_list)) { 119 /* There is nothing scheduled */ 120 last_qh = instance->queue_head; 121 } else { 122 /* There is something scheduled */ 123 usb_transfer_batch_t *last = usb_transfer_batch_from_link( 124 list_last(&instance->batch_list)); 125 last_qh = batch_qh(last); 126 } 127 const uint32_t pa = addr_to_phys(batch_qh(batch)); 125 const uint32_t pa = addr_to_phys(uhci_batch->qh); 128 126 assert((pa & LINK_POINTER_ADDRESS_MASK) == pa); 129 127 … … 132 130 133 131 /* keep link */ 134 batch_qh(batch)->next = last_qh->next;135 qh_set_next_qh(last_qh, batch_qh(batch));132 uhci_batch->qh->next = last_qh->next; 133 qh_set_next_qh(last_qh, uhci_batch->qh); 136 134 137 135 /* Make sure the pointer is updated */ … … 139 137 140 138 /* Add to the driver's list */ 141 list_append(& batch->link, &instance->batch_list);139 list_append(&uhci_batch->link, &instance->batch_list); 142 140 143 141 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " scheduled in queue %s.\n", 144 batch, USB_TRANSFER_BATCH_ARGS(*batch), instance->name); 142 uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch), 143 instance->name); 145 144 fibril_mutex_unlock(&instance->guard); 146 145 } … … 157 156 158 157 fibril_mutex_lock(&instance->guard); 159 link_t *current = instance->batch_list.head.next;160 while (current != &instance->batch_list.head) {158 link_t *current = list_first(&instance->batch_list); 159 while (current && current != &instance->batch_list.head) { 161 160 link_t * const next = current->next; 162 u sb_transfer_batch_t *batch =163 u sb_transfer_batch_from_link(current);164 165 if ( batch_is_complete(batch)) {161 uhci_transfer_batch_t *batch = 162 uhci_transfer_batch_from_link(current); 163 164 if (uhci_transfer_batch_is_complete(batch)) { 166 165 /* Save for processing */ 167 166 transfer_list_remove_batch(instance, batch); … … 182 181 while (!list_empty(&instance->batch_list)) { 183 182 link_t * const current = list_first(&instance->batch_list); 184 u sb_transfer_batch_t *batch =185 u sb_transfer_batch_from_link(current);183 uhci_transfer_batch_t *batch = 184 uhci_transfer_batch_from_link(current); 186 185 transfer_list_remove_batch(instance, batch); 187 u sb_transfer_batch_finish_error(batch, EINTR);186 uhci_transfer_batch_abort(batch); 188 187 } 189 188 fibril_mutex_unlock(&instance->guard); … … 198 197 */ 199 198 void transfer_list_remove_batch( 200 transfer_list_t *instance, u sb_transfer_batch_t *batch)199 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch) 201 200 { 202 201 assert(instance); 203 202 assert(instance->queue_head); 204 assert( batch);205 assert( batch_qh(batch));203 assert(uhci_batch); 204 assert(uhci_batch->qh); 206 205 assert(fibril_mutex_is_locked(&instance->guard)); 207 206 208 usb_log_debug2( 209 "Queue %s: removing batch(%p).\n", instance->name, batch); 210 211 const char *qpos = NULL; 212 qh_t *prev_qh = NULL; 207 usb_log_debug2("Queue %s: removing batch(%p).\n", 208 instance->name, uhci_batch->usb_batch); 209 210 /* Assume I'm the first */ 211 const char *qpos = "FIRST"; 212 qh_t *prev_qh = instance->queue_head; 213 213 /* Remove from the hardware queue */ 214 if (list_first(&instance->batch_list) == &batch->link) { 215 /* I'm the first one here */ 216 prev_qh = instance->queue_head; 217 qpos = "FIRST"; 218 } else { 219 /* The thing before me is a batch too */ 220 usb_transfer_batch_t *prev = 221 usb_transfer_batch_from_link(batch->link.prev); 222 prev_qh = batch_qh(prev); 214 if (list_first(&instance->batch_list) != &uhci_batch->link) { 215 /* There is a batch in front of me */ 216 prev_qh = 217 uhci_transfer_batch_from_link(uhci_batch->link.prev)->qh; 223 218 qpos = "NOT FIRST"; 224 219 } 225 220 assert((prev_qh->next & LINK_POINTER_ADDRESS_MASK) 226 == addr_to_phys( batch_qh(batch)));227 prev_qh->next = batch_qh(batch)->next;221 == addr_to_phys(uhci_batch->qh)); 222 prev_qh->next = uhci_batch->qh->next; 228 223 229 224 /* Make sure the pointer is updated */ … … 231 226 232 227 /* Remove from the batch list */ 233 list_remove(& batch->link);228 list_remove(&uhci_batch->link); 234 229 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " removed (%s) " 235 230 "from %s, next: %x.\n", 236 batch, USB_TRANSFER_BATCH_ARGS(*batch),237 qpos, instance->name, batch_qh(batch)->next);231 uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch), 232 qpos, instance->name, uhci_batch->qh->next); 238 233 } 239 234 /**
Note:
See TracChangeset
for help on using the changeset viewer.