Changeset d8b275d in mainline for uspace/drv/ohci/endpoint_list.c
- Timestamp:
- 2011-04-14T08:24:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5e07e2b5
- Parents:
- 3f2af64 (diff), 34e8bab (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/ohci/endpoint_list.c
r3f2af64 rd8b275d 35 35 #include <usb/debug.h> 36 36 37 #include "transfer_list.h" 38 39 static void transfer_list_remove_batch( 40 transfer_list_t *instance, usb_transfer_batch_t *batch); 41 /*----------------------------------------------------------------------------*/ 37 #include "endpoint_list.h" 38 42 39 /** Initialize transfer list structures. 43 40 * … … 48 45 * Allocates memory for internal qh_t structure. 49 46 */ 50 int transfer_list_init(transfer_list_t *instance, const char *name)47 int endpoint_list_init(endpoint_list_t *instance, const char *name) 51 48 { 52 49 assert(instance); … … 62 59 63 60 ed_init(instance->list_head, NULL); 64 list_initialize(&instance-> batch_list);61 list_initialize(&instance->endpoint_list); 65 62 fibril_mutex_initialize(&instance->guard); 66 63 return EOK; … … 75 72 * Does not check whether this replaces an existing list . 76 73 */ 77 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next)74 void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next) 78 75 { 79 76 assert(instance); 80 77 assert(next); 81 /* Set both queue_head.next to point to the follower */82 78 ed_append_ed(instance->list_head, next->list_head); 83 79 } 84 80 /*----------------------------------------------------------------------------*/ 85 /** Submit transfer batchto the list and queue.86 * 87 * @param[in] instance List to use. 88 * @param[in] batch Transfer batchto submit.89 * @return Error code 90 * 91 * The batchis added to the end of the list and queue.92 */ 93 void transfer_list_add_batch(94 transfer_list_t *instance, usb_transfer_batch_t *batch) 95 { 96 assert( instance);97 assert(batch);98 usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch);81 /** Submit transfer endpoint to the list and queue. 82 * 83 * @param[in] instance List to use. 84 * @param[in] endpoint Transfer endpoint to submit. 85 * @return Error code 86 * 87 * The endpoint is added to the end of the list and queue. 88 */ 89 void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep) 90 { 91 assert(instance); 92 assert(hcd_ep); 93 usb_log_debug2("Queue %s: Adding endpoint(%p).\n", 94 instance->name, hcd_ep); 99 95 100 96 fibril_mutex_lock(&instance->guard); … … 102 98 ed_t *last_ed = NULL; 103 99 /* Add to the hardware queue. */ 104 if (list_empty(&instance-> batch_list)) {100 if (list_empty(&instance->endpoint_list)) { 105 101 /* There is nothing scheduled */ 106 102 last_ed = instance->list_head; 107 103 } else { 108 104 /* There is something scheduled */ 109 usb_transfer_batch_t *last = list_get_instance(110 instance-> batch_list.prev, usb_transfer_batch_t, link);111 last_ed = batch_ed(last);105 hcd_endpoint_t *last = list_get_instance( 106 instance->endpoint_list.prev, hcd_endpoint_t, link); 107 last_ed = last->ed; 112 108 } 113 109 /* keep link */ 114 batch_ed(batch)->next = last_ed->next;115 ed_append_ed(last_ed, batch_ed(batch));110 hcd_ep->ed->next = last_ed->next; 111 ed_append_ed(last_ed, hcd_ep->ed); 116 112 117 113 asm volatile ("": : :"memory"); 118 114 119 115 /* Add to the driver list */ 120 list_append(& batch->link, &instance->batch_list);121 122 usb_transfer_batch_t *first = list_get_instance(123 instance-> batch_list.next, usb_transfer_batch_t, link);124 usb_log_debug(" Batch(%p) added to list %s, first is %p(%p).\n",125 batch, instance->name, first, batch_ed(first));116 list_append(&hcd_ep->link, &instance->endpoint_list); 117 118 hcd_endpoint_t *first = list_get_instance( 119 instance->endpoint_list.next, hcd_endpoint_t, link); 120 usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n", 121 hcd_ep, instance->name, first, first->ed); 126 122 if (last_ed == instance->list_head) { 127 usb_log_debug2("%s head ED: %x:%x:%x:%x.\n", instance->name, 128 last_ed->status, last_ed->td_tail, last_ed->td_head, 129 last_ed->next); 130 } 131 fibril_mutex_unlock(&instance->guard); 132 } 133 /*----------------------------------------------------------------------------*/ 134 /** Create list for finished batches. 123 usb_log_debug2("%s head ED(%p-%p): %x:%x:%x:%x.\n", 124 instance->name, last_ed, instance->list_head_pa, 125 last_ed->status, last_ed->td_tail, last_ed->td_head, 126 last_ed->next); 127 } 128 fibril_mutex_unlock(&instance->guard); 129 } 130 /*----------------------------------------------------------------------------*/ 131 #if 0 132 /** Create list for finished endpoints. 135 133 * 136 134 * @param[in] instance List to use. 137 135 * @param[in] done list to fill 138 136 */ 139 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done)137 void endpoint_list_remove_finished(endpoint_list_t *instance, link_t *done) 140 138 { 141 139 assert(instance); … … 143 141 144 142 fibril_mutex_lock(&instance->guard); 145 link_t *current = instance->batch_list.next; 146 while (current != &instance->batch_list) { 143 usb_log_debug2("Checking list %s for completed endpointes(%d).\n", 144 instance->name, list_count(&instance->endpoint_list)); 145 link_t *current = instance->endpoint_list.next; 146 while (current != &instance->endpoint_list) { 147 147 link_t *next = current->next; 148 usb_transfer_batch_t *batch=149 list_get_instance(current, usb_transfer_batch_t, link);150 151 if ( batch_is_complete(batch)) {148 hcd_endpoint_t *endpoint = 149 list_get_instance(current, hcd_endpoint_t, link); 150 151 if (endpoint_is_complete(endpoint)) { 152 152 /* Save for post-processing */ 153 transfer_list_remove_batch(instance, batch);153 endpoint_list_remove_endpoint(instance, endpoint); 154 154 list_append(current, done); 155 155 } … … 159 159 } 160 160 /*----------------------------------------------------------------------------*/ 161 /** Walk the list and abort all batches. 162 * 163 * @param[in] instance List to use. 164 */ 165 void transfer_list_abort_all(transfer_list_t *instance) 166 { 167 fibril_mutex_lock(&instance->guard); 168 while (!list_empty(&instance->batch_list)) { 169 link_t *current = instance->batch_list.next; 170 usb_transfer_batch_t *batch = 171 list_get_instance(current, usb_transfer_batch_t, link); 172 transfer_list_remove_batch(instance, batch); 173 usb_transfer_batch_finish_error(batch, EIO); 174 } 175 fibril_mutex_unlock(&instance->guard); 176 } 177 /*----------------------------------------------------------------------------*/ 178 /** Remove a transfer batch from the list and queue. 179 * 180 * @param[in] instance List to use. 181 * @param[in] batch Transfer batch to remove. 161 /** Walk the list and abort all endpointes. 162 * 163 * @param[in] instance List to use. 164 */ 165 void endpoint_list_abort_all(endpoint_list_t *instance) 166 { 167 fibril_mutex_lock(&instance->guard); 168 while (!list_empty(&instance->endpoint_list)) { 169 link_t *current = instance->endpoint_list.next; 170 hcd_endpoint_t *endpoint = 171 list_get_instance(current, hcd_endpoint_t, link); 172 endpoint_list_remove_endpoint(instance, endpoint); 173 hcd_endpoint_finish_error(endpoint, EIO); 174 } 175 fibril_mutex_unlock(&instance->guard); 176 } 177 #endif 178 /*----------------------------------------------------------------------------*/ 179 /** Remove a transfer endpoint from the list and queue. 180 * 181 * @param[in] instance List to use. 182 * @param[in] endpoint Transfer endpoint to remove. 182 183 * @return Error code 183 184 * 184 185 * Does not lock the transfer list, caller is responsible for that. 185 186 */ 186 void transfer_list_remove_batch( 187 transfer_list_t *instance, usb_transfer_batch_t *batch) 187 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep) 188 188 { 189 189 assert(instance); 190 190 assert(instance->list_head); 191 assert(batch); 192 assert(batch_ed(batch)); 193 assert(fibril_mutex_is_locked(&instance->guard)); 191 assert(hcd_ep); 192 assert(hcd_ep->ed); 193 194 fibril_mutex_lock(&instance->guard); 194 195 195 196 usb_log_debug2( 196 "Queue %s: removing batch(%p).\n", instance->name, batch);197 "Queue %s: removing endpoint(%p).\n", instance->name, hcd_ep); 197 198 198 199 const char *qpos = NULL; 200 ed_t *prev_ed; 199 201 /* Remove from the hardware queue */ 200 if (instance-> batch_list.next == &batch->link) {202 if (instance->endpoint_list.next == &hcd_ep->link) { 201 203 /* I'm the first one here */ 202 assert((instance->list_head->next & ED_NEXT_PTR_MASK) 203 == addr_to_phys(batch_ed(batch))); 204 instance->list_head->next = batch_ed(batch)->next; 204 prev_ed = instance->list_head; 205 205 qpos = "FIRST"; 206 206 } else { 207 usb_transfer_batch_t *prev = 208 list_get_instance( 209 batch->link.prev, usb_transfer_batch_t, link); 210 assert((batch_ed(prev)->next & ED_NEXT_PTR_MASK) 211 == addr_to_phys(batch_ed(batch))); 212 batch_ed(prev)->next = batch_ed(batch)->next; 207 hcd_endpoint_t *prev = 208 list_get_instance(hcd_ep->link.prev, hcd_endpoint_t, link); 209 prev_ed = prev->ed; 213 210 qpos = "NOT FIRST"; 214 211 } 212 assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(hcd_ep->ed)); 213 prev_ed->next = hcd_ep->ed->next; 214 215 215 asm volatile ("": : :"memory"); 216 usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n", 217 batch, qpos, instance->name, batch_ed(batch)->next); 218 219 /* Remove from the batch list */ 220 list_remove(&batch->link); 216 usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n", 217 hcd_ep, qpos, instance->name, hcd_ep->ed->next); 218 219 /* Remove from the endpoint list */ 220 list_remove(&hcd_ep->link); 221 fibril_mutex_unlock(&instance->guard); 221 222 } 222 223 /**
Note:
See TracChangeset
for help on using the changeset viewer.