Changeset 620c710 in mainline
- Timestamp:
- 2011-08-25T14:21:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 961c29e8
- Parents:
- e20eaed
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
re20eaed r620c710 61 61 static int hc_init_memory(hc_t *instance); 62 62 static int interrupt_emulator(hc_t *instance); 63 63 /*----------------------------------------------------------------------------*/ 64 static int schedule(hcd_t *hcd, usb_transfer_batch_t *batch) 65 { 66 assert(hcd); 67 return hc_schedule(hcd->private_data, batch); 68 } 64 69 /*----------------------------------------------------------------------------*/ 65 70 /** Get number of commands used in IRQ code. … … 163 168 } 164 169 /*----------------------------------------------------------------------------*/ 165 static int schedule(hcd_t *hcd, usb_transfer_batch_t *batch)166 {167 assert(hcd);168 return hc_schedule(hcd->private_data, batch);169 }170 /*----------------------------------------------------------------------------*/171 170 /** Initialize OHCI hc driver structure 172 171 * … … 203 202 instance->generic.private_data = instance; 204 203 instance->generic.schedule = schedule; 205 instance->generic.ep_add_hook = ohci_endpoint_ assign;204 instance->generic.ep_add_hook = ohci_endpoint_init; 206 205 207 206 ret = hc_init_memory(instance); … … 224 223 225 224 return EOK; 225 } 226 /*----------------------------------------------------------------------------*/ 227 void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep) 228 { 229 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 230 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 231 /* Enqueue ep */ 232 switch (ep->transfer_type) { 233 case USB_TRANSFER_CONTROL: 234 instance->registers->control &= ~C_CLE; 235 endpoint_list_add_ep(list, ohci_ep); 236 instance->registers->control_current = 0; 237 instance->registers->control |= C_CLE; 238 break; 239 case USB_TRANSFER_BULK: 240 instance->registers->control &= ~C_BLE; 241 endpoint_list_add_ep( 242 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 243 instance->registers->control |= C_BLE; 244 break; 245 case USB_TRANSFER_ISOCHRONOUS: 246 case USB_TRANSFER_INTERRUPT: 247 instance->registers->control &= (~C_PLE & ~C_IE); 248 endpoint_list_add_ep( 249 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 250 instance->registers->control |= C_PLE | C_IE; 251 break; 252 } 253 } 254 /*----------------------------------------------------------------------------*/ 255 void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep) 256 { 257 /* Dequeue ep */ 258 endpoint_list_t *list = &instance->lists[ep->transfer_type]; 259 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 260 switch (ep->transfer_type) { 261 case USB_TRANSFER_CONTROL: 262 instance->registers->control &= ~C_CLE; 263 endpoint_list_remove_ep(list, ohci_ep); 264 instance->registers->control_current = 0; 265 instance->registers->control |= C_CLE; 266 break; 267 case USB_TRANSFER_BULK: 268 instance->registers->control &= ~C_BLE; 269 endpoint_list_remove_ep(list, ohci_ep); 270 instance->registers->control |= C_BLE; 271 break; 272 case USB_TRANSFER_ISOCHRONOUS: 273 case USB_TRANSFER_INTERRUPT: 274 instance->registers->control &= (~C_PLE & ~C_IE); 275 endpoint_list_remove_ep(list, ohci_ep); 276 instance->registers->control |= C_PLE | C_IE; 277 break; 278 default: 279 break; 280 } 226 281 } 227 282 /*----------------------------------------------------------------------------*/ … … 249 304 return ENOMEM; 250 305 251 int ret = ohci_endpoint_ assign(&instance->generic, ep);306 int ret = ohci_endpoint_init(&instance->generic, ep); 252 307 if (ret != EOK) { 253 308 endpoint_destroy(ep); … … 260 315 return ret; 261 316 } 262 263 /* Enqueue ep */ 264 switch (ep->transfer_type) { 265 case USB_TRANSFER_CONTROL: 266 instance->registers->control &= ~C_CLE; 267 endpoint_list_add_ep( 268 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 269 instance->registers->control_current = 0; 270 instance->registers->control |= C_CLE; 271 break; 272 case USB_TRANSFER_BULK: 273 instance->registers->control &= ~C_BLE; 274 endpoint_list_add_ep( 275 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 276 instance->registers->control |= C_BLE; 277 break; 278 case USB_TRANSFER_ISOCHRONOUS: 279 case USB_TRANSFER_INTERRUPT: 280 instance->registers->control &= (~C_PLE & ~C_IE); 281 endpoint_list_add_ep( 282 &instance->lists[ep->transfer_type], ohci_endpoint_get(ep)); 283 instance->registers->control |= C_PLE | C_IE; 284 break; 285 } 317 hc_enqueue_endpoint(instance, ep); 286 318 287 319 return EOK; … … 311 343 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 312 344 if (ohci_ep) { 313 /* Dequeue ep */ 314 switch (ep->transfer_type) { 315 case USB_TRANSFER_CONTROL: 316 instance->registers->control &= ~C_CLE; 317 endpoint_list_remove_ep( 318 &instance->lists[ep->transfer_type], ohci_ep); 319 instance->registers->control_current = 0; 320 instance->registers->control |= C_CLE; 321 break; 322 case USB_TRANSFER_BULK: 323 instance->registers->control &= ~C_BLE; 324 endpoint_list_remove_ep( 325 &instance->lists[ep->transfer_type], ohci_ep); 326 instance->registers->control |= C_BLE; 327 break; 328 case USB_TRANSFER_ISOCHRONOUS: 329 case USB_TRANSFER_INTERRUPT: 330 instance->registers->control &= (~C_PLE & ~C_IE); 331 endpoint_list_remove_ep( 332 &instance->lists[ep->transfer_type], ohci_ep); 333 instance->registers->control |= C_PLE | C_IE; 334 break; 335 default: 336 break; 337 } 345 hc_dequeue_endpoint(instance, ep); 338 346 } else { 339 347 usb_log_warning("Endpoint without hcd equivalent structure.\n"); -
uspace/drv/bus/usb/ohci/hc.h
re20eaed r620c710 84 84 int hc_get_irq_commands( 85 85 irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size); 86 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 86 87 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts); 87 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);88 88 89 89 /** Safely dispose host controller internal structures … … 93 93 static inline void hc_fini(hc_t *instance) 94 94 { /* TODO: implement*/ }; 95 96 void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep); 97 void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep); 95 98 96 99 int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep, -
uspace/drv/bus/usb/ohci/ohci.c
re20eaed r620c710 89 89 { 90 90 assert(fun); 91 usb_device_keeper_t *manager = &dev_to_ohci(fun->dev)->hc. manager;91 usb_device_keeper_t *manager = &dev_to_ohci(fun->dev)->hc.generic.dev_manager; 92 92 93 93 usb_address_t addr = usb_device_keeper_find(manager, handle); … … 129 129 /** Standard USB HC options (HC interface) */ 130 130 static ddf_dev_ops_t hc_ops = { 131 .interfaces[USBHC_DEV_IFACE] = &hc _iface, /* see iface.h/c */131 .interfaces[USBHC_DEV_IFACE] = &hcd_iface, 132 132 }; 133 133 /*----------------------------------------------------------------------------*/ -
uspace/drv/bus/usb/ohci/ohci_endpoint.c
re20eaed r620c710 34 34 #include "utils/malloc32.h" 35 35 #include "ohci_endpoint.h" 36 #include "hc.h" 36 37 37 38 /** Callback to set toggle on ED. … … 65 66 * @param[in] hcd_ep endpoint structure 66 67 */ 67 static void ohci_e p_destroy(void *ohci_ep)68 static void ohci_endpoint_fini(endpoint_t *ep) 68 69 { 69 if (ohci_ep) { 70 ohci_endpoint_t *instance = ohci_ep; 70 ohci_endpoint_t *instance = ep->hc_data.data; 71 hc_dequeue_endpoint(instance->hcd->private_data, ep); 72 if (instance) { 71 73 free32(instance->ed); 72 74 free32(instance->td); … … 80 82 * @return pointer to a new hcd endpoint structure, NULL on failure. 81 83 */ 82 int ohci_endpoint_ assign(hcd_t *hcd, endpoint_t *ep)84 int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep) 83 85 { 84 86 assert(ep); … … 103 105 ed_set_td(ohci_ep->ed, ohci_ep->td); 104 106 endpoint_set_hc_data( 105 ep, ohci_ep, ohci_ep_destroy, ohci_ep_toggle_get, ohci_ep_toggle_set); 106 107 ep, ohci_ep, ohci_endpoint_fini, ohci_ep_toggle_get, ohci_ep_toggle_set); 108 ohci_ep->hcd = hcd; 109 hc_enqueue_endpoint(hcd->private_data, ep); 107 110 return EOK; 108 111 } -
uspace/drv/bus/usb/ohci/ohci_endpoint.h
re20eaed r620c710 55 55 } ohci_endpoint_t; 56 56 57 int ohci_endpoint_ assign(hcd_t *hcd, endpoint_t *ep);57 int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep); 58 58 59 59 /** Get and convert assigned ohci_endpoint_t structure -
uspace/lib/usbhost/include/usb/host/endpoint.h
re20eaed r620c710 54 54 fibril_condvar_t avail; 55 55 volatile bool active; 56 void (*destroy_hook)(struct endpoint *); 56 57 struct { 57 58 void *data; 58 void (*data_dtor)(void*);59 59 int (*toggle_get)(void *); 60 60 void (*toggle_set)(void *, int); … … 69 69 70 70 void endpoint_set_hc_data(endpoint_t *instance, 71 void *data, void (*d ata_dtor)(void*),71 void *data, void (*destroy_hook)(endpoint_t *), 72 72 int (*toggle_get)(void *), void (*toggle_set)(void *, int)); 73 73 -
uspace/lib/usbhost/src/endpoint.c
re20eaed r620c710 53 53 instance->toggle = 0; 54 54 instance->active = false; 55 instance->destroy_hook = NULL; 55 56 instance->hc_data.data = NULL; 56 instance->hc_data.data_dtor = NULL;57 57 instance->hc_data.toggle_get = NULL; 58 58 instance->hc_data.toggle_set = NULL; … … 69 69 assert(!instance->active); 70 70 if (instance->hc_data.data) { 71 assert(instance-> hc_data.data_dtor);72 instance-> hc_data.data_dtor(instance->hc_data.data);71 assert(instance->destroy_hook); 72 instance->destroy_hook(instance); 73 73 } 74 74 free(instance); … … 76 76 /*----------------------------------------------------------------------------*/ 77 77 void endpoint_set_hc_data(endpoint_t *instance, 78 void *data, void (*d ata_dtor)(void*),78 void *data, void (*destroy_hook)(endpoint_t *), 79 79 int (*toggle_get)(void *), void (*toggle_set)(void *, int)) 80 80 { 81 81 assert(instance); 82 instance->destroy_hook = destroy_hook; 82 83 instance->hc_data.data = data; 83 instance->hc_data.data_dtor = data_dtor;84 84 instance->hc_data.toggle_get = toggle_get; 85 85 instance->hc_data.toggle_set = toggle_set;
Note:
See TracChangeset
for help on using the changeset viewer.