Changeset 26e7d6d in mainline for uspace/drv/bus/usb/uhci/transfer_list.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/transfer_list.c
r3842a955 r26e7d6d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbuhcihc 29 30 * @{ … … 32 33 * @brief UHCI driver transfer list implementation 33 34 */ 35 34 36 #include <errno.h> 35 37 #include <usb/debug.h> 36 #include <arch/barrier.h> 37 38 #include <libarch/barrier.h> 38 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); 142 143 usb_log_debug("Batch %p " USB_TRANSFER_BATCH_FMT " scheduled in queue %s.\n", 144 batch, USB_TRANSFER_BATCH_ARGS(*batch), instance->name); 139 list_append(&uhci_batch->link, &instance->batch_list); 140 141 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " scheduled in queue %s.\n", 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 usb_transfer_batch_finish_error(batch, EINTR); 186 batch->usb_batch->error = EINTR; 187 uhci_transfer_batch_call_dispose(batch); 188 188 } 189 189 fibril_mutex_unlock(&instance->guard); … … 198 198 */ 199 199 void transfer_list_remove_batch( 200 transfer_list_t *instance, u sb_transfer_batch_t *batch)200 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch) 201 201 { 202 202 assert(instance); 203 203 assert(instance->queue_head); 204 assert( batch);205 assert( batch_qh(batch));204 assert(uhci_batch); 205 assert(uhci_batch->qh); 206 206 assert(fibril_mutex_is_locked(&instance->guard)); 207 207 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; 208 usb_log_debug2("Queue %s: removing batch(%p).\n", 209 instance->name, uhci_batch->usb_batch); 210 211 /* Assume I'm the first */ 212 const char *qpos = "FIRST"; 213 qh_t *prev_qh = instance->queue_head; 213 214 /* 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); 215 if (list_first(&instance->batch_list) != &uhci_batch->link) { 216 /* There is a batch in front of me */ 217 prev_qh = 218 uhci_transfer_batch_from_link(uhci_batch->link.prev)->qh; 223 219 qpos = "NOT FIRST"; 224 220 } 225 221 assert((prev_qh->next & LINK_POINTER_ADDRESS_MASK) 226 == addr_to_phys( batch_qh(batch)));227 prev_qh->next = batch_qh(batch)->next;222 == addr_to_phys(uhci_batch->qh)); 223 prev_qh->next = uhci_batch->qh->next; 228 224 229 225 /* Make sure the pointer is updated */ … … 231 227 232 228 /* Remove from the batch list */ 233 list_remove(& batch->link);229 list_remove(&uhci_batch->link); 234 230 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " removed (%s) " 235 231 "from %s, next: %x.\n", 236 batch, USB_TRANSFER_BATCH_ARGS(*batch),237 qpos, instance->name, batch_qh(batch)->next);232 uhci_batch, USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch), 233 qpos, instance->name, uhci_batch->qh->next); 238 234 } 239 235 /**
Note:
See TracChangeset
for help on using the changeset viewer.