Changeset a963a68 in mainline
- Timestamp:
- 2011-03-15T14:43:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eb2a48a
- Parents:
- 9370884
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/batch.c
r9370884 ra963a68 153 153 } 154 154 /*----------------------------------------------------------------------------*/ 155 /** Mark batch as failed and continue with next step. 156 * 157 * @param[in] instance Batch structure to use. 158 * 159 */ 160 void batch_abort(batch_t *instance) 161 { 162 assert(instance); 163 instance->error = EIO; 164 instance->next_step(instance); 165 } 166 /*----------------------------------------------------------------------------*/ 155 167 /** Check batch TDs for activity. 156 168 * … … 251 263 assert(instance); 252 264 /* We are data out, we are supposed to provide data */ 253 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 265 memcpy(instance->transport_buffer, instance->buffer, 266 instance->buffer_size); 254 267 batch_data(instance, USB_PID_OUT); 255 268 instance->next_step = batch_call_out_and_dispose; … … 281 294 assert(instance); 282 295 /* We are data out, we are supposed to provide data */ 283 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 296 memcpy(instance->transport_buffer, instance->buffer, 297 instance->buffer_size); 284 298 batch_data(instance, USB_PID_OUT); 285 299 instance->next_step = batch_call_out_and_dispose; -
uspace/drv/uhci-hcd/batch.h
r9370884 ra963a68 69 69 } batch_t; 70 70 71 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, 72 usb_transfer_type_t transfer_type, size_t max_packet_size, 73 usb_speed_t speed, char *buffer, size_t size, 74 char *setup_buffer, size_t setup_size, 71 batch_t * batch_get( 72 ddf_fun_t *fun, 73 usb_target_t target, 74 usb_transfer_type_t transfer_type, 75 size_t max_packet_size, 76 usb_speed_t speed, 77 char *buffer, 78 size_t size, 79 char *setup_buffer, 80 size_t setup_size, 75 81 usbhc_iface_transfer_in_callback_t func_in, 76 usbhc_iface_transfer_out_callback_t func_out, void *arg, 82 usbhc_iface_transfer_out_callback_t func_out, 83 void *arg, 77 84 device_keeper_t *manager 78 85 ); 79 86 80 87 void batch_dispose(batch_t *instance); 88 89 void batch_abort(batch_t *instance); 81 90 82 91 bool batch_is_complete(batch_t *instance); -
uspace/drv/uhci-hcd/transfer_list.c
r9370884 ra963a68 129 129 } 130 130 /*----------------------------------------------------------------------------*/ 131 /** Check list for finished batches. 132 * 133 * @param[in] instance List to use. 134 * @return Error code 135 * 136 * Creates a local list of finished batches and calls next_step on each and 137 * every one. This is safer because next_step may theoretically access 138 * this transfer list leading to the deadlock if its done inline. 139 */ 140 void transfer_list_remove_finished(transfer_list_t *instance) 141 { 142 assert(instance); 143 144 LIST_INITIALIZE(done); 145 146 fibril_mutex_lock(&instance->guard); 147 link_t *current = instance->batch_list.next; 148 while (current != &instance->batch_list) { 149 link_t *next = current->next; 150 batch_t *batch = list_get_instance(current, batch_t, link); 151 152 if (batch_is_complete(batch)) { 153 /* Save for post-processing */ 154 transfer_list_remove_batch(instance, batch); 155 list_append(current, &done); 156 } 157 current = next; 158 } 159 fibril_mutex_unlock(&instance->guard); 160 161 while (!list_empty(&done)) { 162 link_t *item = done.next; 163 list_remove(item); 164 batch_t *batch = list_get_instance(item, batch_t, link); 165 batch->next_step(batch); 166 } 167 } 168 /*----------------------------------------------------------------------------*/ 169 /** Walk the list and abort all batches. 170 * 171 * @param[in] instance List to use. 172 */ 173 void transfer_list_abort_all(transfer_list_t *instance) 174 { 175 fibril_mutex_lock(&instance->guard); 176 while (list_empty(&instance->batch_list)) { 177 link_t *current = instance->batch_list.next; 178 batch_t *batch = list_get_instance(current, batch_t, link); 179 transfer_list_remove_batch(instance, batch); 180 batch_abort(batch); 181 } 182 fibril_mutex_unlock(&instance->guard); 183 } 184 /*----------------------------------------------------------------------------*/ 131 185 /** Remove a transfer batch from the list and queue. 132 186 * … … 163 217 batch, pos, instance->name, batch->qh->next); 164 218 } 165 /*----------------------------------------------------------------------------*/166 /** Check list for finished batches.167 *168 * @param[in] instance List to use.169 * @return Error code170 *171 * Creates a local list of finished batches and calls next_step on each and172 * every one. This is safer because next_step may theoretically access173 * this transfer list leading to the deadlock if its done inline.174 */175 void transfer_list_remove_finished(transfer_list_t *instance)176 {177 assert(instance);178 179 LIST_INITIALIZE(done);180 181 fibril_mutex_lock(&instance->guard);182 link_t *current = instance->batch_list.next;183 while (current != &instance->batch_list) {184 link_t *next = current->next;185 batch_t *batch = list_get_instance(current, batch_t, link);186 187 if (batch_is_complete(batch)) {188 /* Save for post-processing */189 transfer_list_remove_batch(instance, batch);190 list_append(current, &done);191 }192 current = next;193 }194 fibril_mutex_unlock(&instance->guard);195 196 while (!list_empty(&done)) {197 link_t *item = done.next;198 list_remove(item);199 batch_t *batch = list_get_instance(item, batch_t, link);200 batch->next_step(batch);201 }202 }203 219 /** 204 220 * @} -
uspace/drv/uhci-hcd/transfer_list.h
r9370884 ra963a68 66 66 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next); 67 67 68 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch); 69 68 70 void transfer_list_remove_finished(transfer_list_t *instance); 69 71 70 void transfer_list_a dd_batch(transfer_list_t *instance, batch_t *batch);72 void transfer_list_abort_all(transfer_list_t *instance); 71 73 #endif 72 74 /** -
uspace/drv/uhci-hcd/uhci_hc.c
r9370884 ra963a68 347 347 { 348 348 assert(instance); 349 /* TODO: Check interrupt cause here*/349 /* TODO: Resume interrupts are not supported */ 350 350 /* Lower 2 bits are transaction error and transaction complete */ 351 351 if (status & 0x3) { … … 354 354 transfer_list_remove_finished(&instance->transfers_control_full); 355 355 transfer_list_remove_finished(&instance->transfers_bulk_full); 356 } 357 /* bits 4 and 5 indicate hc error */ 358 if (status & 0x18) { 359 transfer_list_abort_all(&instance->transfers_interrupt); 360 transfer_list_abort_all(&instance->transfers_control_slow); 361 transfer_list_abort_all(&instance->transfers_control_full); 362 transfer_list_abort_all(&instance->transfers_bulk_full); 363 /* reinitialize hw, this triggers virtual disconnect*/ 364 uhci_hc_init_hw(instance); 356 365 } 357 366 }
Note:
See TracChangeset
for help on using the changeset viewer.