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