Changeset a39cfb8 in mainline for uspace/drv/ohci/endpoint_list.c
- Timestamp:
- 2011-04-14T07:54:33Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e05d6c3
- Parents:
- 3f3afb9 (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
r3f3afb9 ra39cfb8 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); … … 82 79 } 83 80 /*----------------------------------------------------------------------------*/ 84 /** Submit transfer batchto the list and queue.85 * 86 * @param[in] instance List to use. 87 * @param[in] batch Transfer batchto submit.88 * @return Error code 89 * 90 * The batchis added to the end of the list and queue.91 */ 92 void transfer_list_add_batch(93 transfer_list_t *instance, usb_transfer_batch_t *batch) 94 { 95 assert( instance);96 assert(batch);97 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); 98 95 99 96 fibril_mutex_lock(&instance->guard); … … 101 98 ed_t *last_ed = NULL; 102 99 /* Add to the hardware queue. */ 103 if (list_empty(&instance-> batch_list)) {100 if (list_empty(&instance->endpoint_list)) { 104 101 /* There is nothing scheduled */ 105 102 last_ed = instance->list_head; 106 103 } else { 107 104 /* There is something scheduled */ 108 usb_transfer_batch_t *last = list_get_instance(109 instance-> batch_list.prev, usb_transfer_batch_t, link);110 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; 111 108 } 112 109 /* keep link */ 113 batch_ed(batch)->next = last_ed->next;114 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); 115 112 116 113 asm volatile ("": : :"memory"); 117 114 118 115 /* Add to the driver list */ 119 list_append(& batch->link, &instance->batch_list);120 121 usb_transfer_batch_t *first = list_get_instance(122 instance-> batch_list.next, usb_transfer_batch_t, link);123 usb_log_debug(" Batch(%p) added to list %s, first is %p(%p).\n",124 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); 125 122 if (last_ed == instance->list_head) { 126 123 usb_log_debug2("%s head ED(%p-%p): %x:%x:%x:%x.\n", … … 132 129 } 133 130 /*----------------------------------------------------------------------------*/ 134 /** Create list for finished batches. 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 usb_log_debug2("Checking list %s for completed batches(%d).\n",146 instance->name, list_count(&instance-> batch_list));147 link_t *current = instance-> batch_list.next;148 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) { 149 147 link_t *next = current->next; 150 usb_transfer_batch_t *batch=151 list_get_instance(current, usb_transfer_batch_t, link);152 153 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)) { 154 152 /* Save for post-processing */ 155 transfer_list_remove_batch(instance, batch);153 endpoint_list_remove_endpoint(instance, endpoint); 156 154 list_append(current, done); 157 155 } … … 161 159 } 162 160 /*----------------------------------------------------------------------------*/ 163 /** Walk the list and abort all batches. 164 * 165 * @param[in] instance List to use. 166 */ 167 void transfer_list_abort_all(transfer_list_t *instance) 168 { 169 fibril_mutex_lock(&instance->guard); 170 while (!list_empty(&instance->batch_list)) { 171 link_t *current = instance->batch_list.next; 172 usb_transfer_batch_t *batch = 173 list_get_instance(current, usb_transfer_batch_t, link); 174 transfer_list_remove_batch(instance, batch); 175 usb_transfer_batch_finish_error(batch, EIO); 176 } 177 fibril_mutex_unlock(&instance->guard); 178 } 179 /*----------------------------------------------------------------------------*/ 180 /** Remove a transfer batch from the list and queue. 181 * 182 * @param[in] instance List to use. 183 * @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. 184 183 * @return Error code 185 184 * 186 185 * Does not lock the transfer list, caller is responsible for that. 187 186 */ 188 void transfer_list_remove_batch( 189 transfer_list_t *instance, usb_transfer_batch_t *batch) 187 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep) 190 188 { 191 189 assert(instance); 192 190 assert(instance->list_head); 193 assert(batch); 194 assert(batch_ed(batch)); 195 assert(fibril_mutex_is_locked(&instance->guard)); 191 assert(hcd_ep); 192 assert(hcd_ep->ed); 193 194 fibril_mutex_lock(&instance->guard); 196 195 197 196 usb_log_debug2( 198 "Queue %s: removing batch(%p).\n", instance->name, batch);197 "Queue %s: removing endpoint(%p).\n", instance->name, hcd_ep); 199 198 200 199 const char *qpos = NULL; 200 ed_t *prev_ed; 201 201 /* Remove from the hardware queue */ 202 if (instance-> batch_list.next == &batch->link) {202 if (instance->endpoint_list.next == &hcd_ep->link) { 203 203 /* I'm the first one here */ 204 assert((instance->list_head->next & ED_NEXT_PTR_MASK) 205 == addr_to_phys(batch_ed(batch))); 206 instance->list_head->next = batch_ed(batch)->next; 204 prev_ed = instance->list_head; 207 205 qpos = "FIRST"; 208 206 } else { 209 usb_transfer_batch_t *prev = 210 list_get_instance( 211 batch->link.prev, usb_transfer_batch_t, link); 212 assert((batch_ed(prev)->next & ED_NEXT_PTR_MASK) 213 == addr_to_phys(batch_ed(batch))); 214 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; 215 210 qpos = "NOT FIRST"; 216 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 217 215 asm volatile ("": : :"memory"); 218 usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n", 219 batch, qpos, instance->name, batch_ed(batch)->next); 220 221 /* Remove from the batch list */ 222 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); 223 222 } 224 223 /**
Note:
See TracChangeset
for help on using the changeset viewer.