Changeset e20eaed in mainline
- Timestamp:
- 2011-08-25T13:53:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 620c710
- Parents:
- 23b0fe8
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/Makefile
r23b0fe8 re20eaed 47 47 endpoint_list.c \ 48 48 hc.c \ 49 hcd_endpoint.c \50 49 iface.c \ 51 50 main.c \ 52 51 ohci.c \ 52 ohci_endpoint.c \ 53 53 pci.c \ 54 54 root_hub.c \ -
uspace/drv/bus/usb/ohci/batch.c
r23b0fe8 re20eaed 39 39 40 40 #include "batch.h" 41 #include " hcd_endpoint.h"41 #include "ohci_endpoint.h" 42 42 #include "utils/malloc32.h" 43 43 #include "hw_struct/endpoint_descriptor.h" … … 122 122 } else (void)0 123 123 124 const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(batch->ep);125 assert( hcd_ep);124 const ohci_endpoint_t *ohci_ep = ohci_endpoint_get(batch->ep); 125 assert(ohci_ep); 126 126 127 127 ohci_transfer_batch_t *data = calloc(sizeof(ohci_transfer_batch_t), 1); … … 135 135 } 136 136 137 /* We need an extra place for TD that is currently assigned to hcd_ep*/137 /* We need an extra place for TD that is assigned to ohci_ep */ 138 138 data->tds = calloc(sizeof(td_t*), data->td_count + 1); 139 139 CHECK_NULL_DISPOSE_RETURN(data->tds, … … 141 141 142 142 /* Add TD left over by the previous transfer */ 143 data->tds[0] = hcd_ep->td;143 data->tds[0] = ohci_ep->td; 144 144 data->leave_td = 0; 145 145 unsigned i = 1; … … 150 150 } 151 151 152 data->ed = hcd_ep->ed;152 data->ed = ohci_ep->ed; 153 153 batch->private_data = data; 154 154 batch->private_data_dtor = ohci_batch_dispose; … … 213 213 ohci_batch_dispose); 214 214 215 const hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);216 assert( hcd_ep);215 const ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 216 assert(ohci_ep); 217 217 218 218 ohci_transfer_batch_t *data = calloc(sizeof(ohci_transfer_batch_t), 1); … … 233 233 234 234 /* Add TD left over by the previous transfer */ 235 data->tds[0] = hcd_ep->td;235 data->tds[0] = ohci_ep->td; 236 236 data->leave_td = 0; 237 237 unsigned i = 1; … … 242 242 } 243 243 244 data->ed = hcd_ep->ed;244 data->ed = ohci_ep->ed; 245 245 246 246 /* NOTE: OHCI is capable of handling buffer that crosses page boundaries … … 303 303 data->leave_td = i; 304 304 assert(data->leave_td <= data->td_count); 305 hcd_endpoint_t *hcd_ep = hcd_endpoint_get(instance->ep); 306 assert(hcd_ep); 307 hcd_ep->td = data->tds[i]; 305 306 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(instance->ep); 307 assert(ohci_ep); 308 ohci_ep->td = data->tds[i]; 308 309 assert(i > 0); 309 310 for (--i;i < data->td_count; ++i) … … 312 313 /* Clear possible ED HALT */ 313 314 data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG; 314 const uint32_t pa = addr_to_phys( hcd_ep->td);315 const uint32_t pa = addr_to_phys(ohci_ep->td); 315 316 assert(pa == (data->ed->td_head & ED_TDHEAD_PTR_MASK)); 316 317 assert(pa == (data->ed->td_tail & ED_TDTAIL_PTR_MASK)); -
uspace/drv/bus/usb/ohci/endpoint_list.c
r23b0fe8 re20eaed 87 87 * The endpoint is added to the end of the list and queue. 88 88 */ 89 void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)89 void endpoint_list_add_ep(endpoint_list_t *instance, ohci_endpoint_t *ep) 90 90 { 91 91 assert(instance); 92 assert(hcd_ep); 93 usb_log_debug2("Queue %s: Adding endpoint(%p).\n", 94 instance->name, hcd_ep); 92 assert(ep); 93 usb_log_debug2("Queue %s: Adding endpoint(%p).\n", instance->name, ep); 95 94 96 95 fibril_mutex_lock(&instance->guard); … … 103 102 } else { 104 103 /* There are active EDs, get the last one */ 105 hcd_endpoint_t *last = list_get_instance(106 list_last(&instance->endpoint_list), hcd_endpoint_t, link);104 ohci_endpoint_t *last = list_get_instance( 105 list_last(&instance->endpoint_list), ohci_endpoint_t, link); 107 106 last_ed = last->ed; 108 107 } 109 108 /* Keep link */ 110 hcd_ep->ed->next = last_ed->next;109 ep->ed->next = last_ed->next; 111 110 /* Make sure ED is written to the memory */ 112 111 write_barrier(); 113 112 114 113 /* Add ed to the hw queue */ 115 ed_append_ed(last_ed, hcd_ep->ed);114 ed_append_ed(last_ed, ep->ed); 116 115 /* Make sure ED is updated */ 117 116 write_barrier(); 118 117 119 118 /* Add to the sw list */ 120 list_append(& hcd_ep->link, &instance->endpoint_list);119 list_append(&ep->link, &instance->endpoint_list); 121 120 122 hcd_endpoint_t *first = list_get_instance(123 list_first(&instance->endpoint_list), hcd_endpoint_t, link);121 ohci_endpoint_t *first = list_get_instance( 122 list_first(&instance->endpoint_list), ohci_endpoint_t, link); 124 123 usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n", 125 hcd_ep, instance->name, first, first->ed);124 ep, instance->name, first, first->ed); 126 125 if (last_ed == instance->list_head) { 127 126 usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.\n", … … 138 137 * @param[in] endpoint Endpoint to remove. 139 138 */ 140 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep)139 void endpoint_list_remove_ep(endpoint_list_t *instance, ohci_endpoint_t *ep) 141 140 { 142 141 assert(instance); 143 142 assert(instance->list_head); 144 assert( hcd_ep);145 assert( hcd_ep->ed);143 assert(ep); 144 assert(ep->ed); 146 145 147 146 fibril_mutex_lock(&instance->guard); 148 147 149 usb_log_debug2( 150 "Queue %s: removing endpoint(%p).\n", instance->name, hcd_ep); 148 usb_log_debug2("Queue %s: removing endpoint(%p).\n", instance->name, ep); 151 149 152 150 const char *qpos = NULL; 153 151 ed_t *prev_ed; 154 152 /* Remove from the hardware queue */ 155 if (list_first(&instance->endpoint_list) == & hcd_ep->link) {153 if (list_first(&instance->endpoint_list) == &ep->link) { 156 154 /* I'm the first one here */ 157 155 prev_ed = instance->list_head; 158 156 qpos = "FIRST"; 159 157 } else { 160 hcd_endpoint_t *prev =161 list_get_instance( hcd_ep->link.prev, hcd_endpoint_t, link);158 ohci_endpoint_t *prev = 159 list_get_instance(ep->link.prev, ohci_endpoint_t, link); 162 160 prev_ed = prev->ed; 163 161 qpos = "NOT FIRST"; 164 162 } 165 assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys( hcd_ep->ed));166 prev_ed->next = hcd_ep->ed->next;163 assert((prev_ed->next & ED_NEXT_PTR_MASK) == addr_to_phys(ep->ed)); 164 prev_ed->next = ep->ed->next; 167 165 /* Make sure ED is updated */ 168 166 write_barrier(); 169 167 170 168 usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.\n", 171 hcd_ep, qpos, instance->name, hcd_ep->ed->next);169 ep, qpos, instance->name, ep->ed->next); 172 170 173 171 /* Remove from the endpoint list */ 174 list_remove(& hcd_ep->link);172 list_remove(&ep->link); 175 173 fibril_mutex_unlock(&instance->guard); 176 174 } -
uspace/drv/bus/usb/ohci/endpoint_list.h
r23b0fe8 re20eaed 37 37 #include <fibril_synch.h> 38 38 39 #include " hcd_endpoint.h"39 #include "ohci_endpoint.h" 40 40 #include "hw_struct/endpoint_descriptor.h" 41 41 #include "utils/malloc32.h" … … 69 69 int endpoint_list_init(endpoint_list_t *instance, const char *name); 70 70 void endpoint_list_set_next(endpoint_list_t *instance, endpoint_list_t *next); 71 void endpoint_list_add_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep);72 void endpoint_list_remove_ep(endpoint_list_t *instance, hcd_endpoint_t *hcd_ep);71 void endpoint_list_add_ep(endpoint_list_t *instance, ohci_endpoint_t *ep); 72 void endpoint_list_remove_ep(endpoint_list_t *instance, ohci_endpoint_t *ep); 73 73 #endif 74 74 /** -
uspace/drv/bus/usb/ohci/hc.c
r23b0fe8 re20eaed 42 42 43 43 #include "hc.h" 44 #include " hcd_endpoint.h"44 #include "ohci_endpoint.h" 45 45 46 46 #define OHCI_USED_INTERRUPTS \ … … 203 203 instance->generic.private_data = instance; 204 204 instance->generic.schedule = schedule; 205 instance->generic.ep_add_hook = NULL;205 instance->generic.ep_add_hook = ohci_endpoint_assign; 206 206 207 207 ret = hc_init_memory(instance); … … 249 249 return ENOMEM; 250 250 251 int ret = hcd_endpoint_assign(ep);251 int ret = ohci_endpoint_assign(&instance->generic, ep); 252 252 if (ret != EOK) { 253 253 endpoint_destroy(ep); … … 261 261 } 262 262 263 /* Enqueue hcd_ep */263 /* Enqueue ep */ 264 264 switch (ep->transfer_type) { 265 265 case USB_TRANSFER_CONTROL: 266 266 instance->registers->control &= ~C_CLE; 267 267 endpoint_list_add_ep( 268 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep));268 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 269 269 instance->registers->control_current = 0; 270 270 instance->registers->control |= C_CLE; … … 273 273 instance->registers->control &= ~C_BLE; 274 274 endpoint_list_add_ep( 275 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep));275 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 276 276 instance->registers->control |= C_BLE; 277 277 break; … … 280 280 instance->registers->control &= (~C_PLE & ~C_IE); 281 281 endpoint_list_add_ep( 282 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep));282 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 283 283 instance->registers->control |= C_PLE | C_IE; 284 284 break; … … 309 309 } 310 310 311 hcd_endpoint_t *hcd_ep = hcd_endpoint_get(ep);312 if ( hcd_ep) {313 /* Dequeue hcd_ep */311 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 312 if (ohci_ep) { 313 /* Dequeue ep */ 314 314 switch (ep->transfer_type) { 315 315 case USB_TRANSFER_CONTROL: 316 316 instance->registers->control &= ~C_CLE; 317 317 endpoint_list_remove_ep( 318 &instance->lists[ep->transfer_type], hcd_ep);318 &instance->lists[ep->transfer_type], ohci_ep); 319 319 instance->registers->control_current = 0; 320 320 instance->registers->control |= C_CLE; … … 323 323 instance->registers->control &= ~C_BLE; 324 324 endpoint_list_remove_ep( 325 &instance->lists[ep->transfer_type], hcd_ep);325 &instance->lists[ep->transfer_type], ohci_ep); 326 326 instance->registers->control |= C_BLE; 327 327 break; … … 330 330 instance->registers->control &= (~C_PLE & ~C_IE); 331 331 endpoint_list_remove_ep( 332 &instance->lists[ep->transfer_type], hcd_ep);332 &instance->lists[ep->transfer_type], ohci_ep); 333 333 instance->registers->control |= C_PLE | C_IE; 334 334 break; -
uspace/drv/bus/usb/ohci/ohci_endpoint.c
r23b0fe8 re20eaed 33 33 */ 34 34 #include "utils/malloc32.h" 35 #include " hcd_endpoint.h"35 #include "ohci_endpoint.h" 36 36 37 37 /** Callback to set toggle on ED. … … 40 40 * @param[in] toggle new value of toggle bit 41 41 */ 42 static void hcd_ep_toggle_set(void *hcd_ep, int toggle)42 static void ohci_ep_toggle_set(void *ohci_ep, int toggle) 43 43 { 44 hcd_endpoint_t *instance = hcd_ep;44 ohci_endpoint_t *instance = ohci_ep; 45 45 assert(instance); 46 46 assert(instance->ed); … … 53 53 * @return Current value of toggle bit. 54 54 */ 55 static int hcd_ep_toggle_get(void *hcd_ep)55 static int ohci_ep_toggle_get(void *ohci_ep) 56 56 { 57 hcd_endpoint_t *instance = hcd_ep;57 ohci_endpoint_t *instance = ohci_ep; 58 58 assert(instance); 59 59 assert(instance->ed); … … 65 65 * @param[in] hcd_ep endpoint structure 66 66 */ 67 static void hcd_ep_destroy(void *hcd_ep)67 static void ohci_ep_destroy(void *ohci_ep) 68 68 { 69 if ( hcd_ep) {70 hcd_endpoint_t *instance = hcd_ep;69 if (ohci_ep) { 70 ohci_endpoint_t *instance = ohci_ep; 71 71 free32(instance->ed); 72 72 free32(instance->td); … … 80 80 * @return pointer to a new hcd endpoint structure, NULL on failure. 81 81 */ 82 int hcd_endpoint_assign(endpoint_t *ep)82 int ohci_endpoint_assign(hcd_t *hcd, endpoint_t *ep) 83 83 { 84 84 assert(ep); 85 hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t));86 if ( hcd_ep == NULL)85 ohci_endpoint_t *ohci_ep = malloc(sizeof(ohci_endpoint_t)); 86 if (ohci_ep == NULL) 87 87 return ENOMEM; 88 88 89 hcd_ep->ed = malloc32(sizeof(ed_t));90 if ( hcd_ep->ed == NULL) {91 free( hcd_ep);89 ohci_ep->ed = malloc32(sizeof(ed_t)); 90 if (ohci_ep->ed == NULL) { 91 free(ohci_ep); 92 92 return ENOMEM; 93 93 } 94 94 95 hcd_ep->td = malloc32(sizeof(td_t));96 if ( hcd_ep->td == NULL) {97 free32( hcd_ep->ed);98 free( hcd_ep);95 ohci_ep->td = malloc32(sizeof(td_t)); 96 if (ohci_ep->td == NULL) { 97 free32(ohci_ep->ed); 98 free(ohci_ep); 99 99 return ENOMEM; 100 100 } 101 101 102 ed_init( hcd_ep->ed, ep);103 ed_set_td( hcd_ep->ed, hcd_ep->td);102 ed_init(ohci_ep->ed, ep); 103 ed_set_td(ohci_ep->ed, ohci_ep->td); 104 104 endpoint_set_hc_data( 105 ep, hcd_ep, hcd_ep_destroy, hcd_ep_toggle_get, hcd_ep_toggle_set);105 ep, ohci_ep, ohci_ep_destroy, ohci_ep_toggle_get, ohci_ep_toggle_set); 106 106 107 107 return EOK; -
uspace/drv/bus/usb/ohci/ohci_endpoint.h
r23b0fe8 re20eaed 38 38 #include <adt/list.h> 39 39 #include <usb/host/endpoint.h> 40 #include <usb/host/hcd.h> 40 41 41 42 #include "hw_struct/endpoint_descriptor.h" … … 43 44 44 45 /** Connector structure linking ED to to prepared TD. */ 45 typedef struct hcd_endpoint {46 typedef struct ohci_endpoint { 46 47 /** OHCI endpoint descriptor */ 47 48 ed_t *ed; … … 50 51 /** Linked list used by driver software */ 51 52 link_t link; 52 } hcd_endpoint_t; 53 /** Device using this ep */ 54 hcd_t *hcd; 55 } ohci_endpoint_t; 53 56 54 int hcd_endpoint_assign(endpoint_t *ep);57 int ohci_endpoint_assign(hcd_t *hcd, endpoint_t *ep); 55 58 56 /** Get and convert assigned hcd_endpoint_t structure59 /** Get and convert assigned ohci_endpoint_t structure 57 60 * @param[in] ep USBD endpoint structure. 58 61 * @return Pointer to assigned hcd endpoint structure 59 62 */ 60 static inline hcd_endpoint_t * hcd_endpoint_get(endpoint_t *ep)63 static inline ohci_endpoint_t * ohci_endpoint_get(endpoint_t *ep) 61 64 { 62 65 assert(ep);
Note:
See TracChangeset
for help on using the changeset viewer.