Changeset d369b3b in mainline for uspace/drv
- Timestamp:
- 2018-01-25T02:05:57Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 296d22fc
- Parents:
- b357377
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-25 01:52:13)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-25 02:05:57)
- Location:
- uspace/drv/bus/usb
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_bus.c
rb357377 rd369b3b 57 57 } 58 58 59 static int ehci_device_enumerate(device_t *dev) 60 { 61 ehci_bus_t *bus = (ehci_bus_t *) dev->bus; 62 return usb2_bus_device_enumerate(&bus->helper, dev); 63 } 59 64 60 65 /** Creates new hcd endpoint representation. … … 101 106 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 102 107 103 const int err = usb2_bus_ ops.endpoint_register(ep);108 const int err = usb2_bus_endpoint_register(&bus->helper, ep); 104 109 if (err) 105 110 return err; … … 119 124 assert(ep); 120 125 121 usb2_bus_ ops.endpoint_unregister(ep);126 usb2_bus_endpoint_unregister(&bus->helper, ep); 122 127 hc_dequeue_endpoint(hc, ep); 123 128 /* … … 154 159 155 160 static const bus_ops_t ehci_bus_ops = { 156 .parent = &usb2_bus_ops,157 158 161 .interrupt = ehci_hc_interrupt, 159 162 .status = ehci_hc_status, 163 164 .device_enumerate = ehci_device_enumerate, 160 165 161 166 .endpoint_destroy = ehci_endpoint_destroy, … … 174 179 assert(bus); 175 180 176 usb2_bus_t *usb2_bus = (usb2_bus_t *) bus;177 181 bus_t *bus_base = (bus_t *) bus; 182 bus_init(bus_base, sizeof(device_t)); 183 bus_base->ops = &ehci_bus_ops; 178 184 179 usb2_bus_init(usb2_bus, &bandwidth_accounting_usb2); 180 bus_base->ops = &ehci_bus_ops; 185 usb2_bus_helper_init(&bus->helper, &bandwidth_accounting_usb2); 181 186 182 187 bus->hc = hc; -
uspace/drv/bus/usb/ehci/ehci_bus.h
rb357377 rd369b3b 64 64 65 65 typedef struct { 66 usb2_bus_t base; 66 bus_t base; 67 usb2_bus_helper_t helper; 67 68 hc_t *hc; 68 69 } ehci_bus_t; -
uspace/drv/bus/usb/ohci/ohci_bus.c
rb357377 rd369b3b 57 57 } 58 58 59 static int ohci_device_enumerate(device_t *dev) 60 { 61 ohci_bus_t *bus = (ohci_bus_t *) dev->bus; 62 return usb2_bus_device_enumerate(&bus->helper, dev); 63 } 64 59 65 /** Creates new hcd endpoint representation. 60 66 */ … … 109 115 ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep); 110 116 111 const int err = usb2_bus_ ops.endpoint_register(ep);117 const int err = usb2_bus_endpoint_register(&bus->helper, ep); 112 118 if (err) 113 119 return err; … … 126 132 assert(ep); 127 133 128 usb2_bus_ ops.endpoint_unregister(ep);134 usb2_bus_endpoint_unregister(&bus->helper, ep); 129 135 hc_dequeue_endpoint(bus->hc, ep); 130 136 … … 162 168 163 169 static const bus_ops_t ohci_bus_ops = { 164 .parent = &usb2_bus_ops,165 166 170 .interrupt = ohci_hc_interrupt, 167 171 .status = ohci_hc_status, 172 173 .device_enumerate = ohci_device_enumerate, 168 174 169 175 .endpoint_destroy = ohci_endpoint_destroy, … … 183 189 assert(bus); 184 190 185 usb2_bus_t *usb2_bus = (usb2_bus_t *) bus;186 191 bus_t *bus_base = (bus_t *) bus; 187 188 usb2_bus_init(usb2_bus, &bandwidth_accounting_usb11); 192 bus_init(bus_base, sizeof(device_t)); 189 193 bus_base->ops = &ohci_bus_ops; 194 195 usb2_bus_helper_init(&bus->helper, &bandwidth_accounting_usb11); 190 196 191 197 bus->hc = hc; -
uspace/drv/bus/usb/ohci/ohci_bus.h
rb357377 rd369b3b 60 60 61 61 typedef struct { 62 usb2_bus_t base; 62 bus_t base; 63 usb2_bus_helper_t helper; 63 64 hc_t *hc; 64 65 } ohci_bus_t; -
uspace/drv/bus/usb/uhci/hc.c
rb357377 rd369b3b 329 329 hc_t * const hc = bus_to_hc(endpoint_get_bus(ep)); 330 330 331 const int err = usb2_bus_ ops.endpoint_register(ep);331 const int err = usb2_bus_endpoint_register(&hc->bus_helper, ep); 332 332 if (err) 333 333 return err; … … 350 350 { 351 351 hc_t * const hc = bus_to_hc(endpoint_get_bus(ep)); 352 usb2_bus_ ops.endpoint_unregister(ep);352 usb2_bus_endpoint_unregister(&hc->bus_helper, ep); 353 353 354 354 // Check for the roothub, as it does not schedule into lists … … 406 406 } 407 407 408 static int device_enumerate(device_t *dev) 409 { 410 hc_t * const hc = bus_to_hc(dev->bus); 411 return usb2_bus_device_enumerate(&hc->bus_helper, dev); 412 } 413 408 414 static int hc_status(bus_t *, uint32_t *); 409 415 static int hc_schedule(usb_transfer_batch_t *); 410 416 411 417 static const bus_ops_t uhci_bus_ops = { 412 .parent = &usb2_bus_ops,413 414 418 .interrupt = hc_interrupt, 415 419 .status = hc_status, 420 421 .device_enumerate = device_enumerate, 416 422 417 423 .endpoint_create = endpoint_create, … … 438 444 assert(instance); 439 445 440 usb2_bus_ init(&instance->bus, &bandwidth_accounting_usb11);441 442 bus_ t *bus = (bus_t *) &instance->bus;443 bus->ops = &uhci_bus_ops;444 445 hc_device_setup(&instance->base, bus);446 usb2_bus_helper_init(&instance->bus_helper, &bandwidth_accounting_usb11); 447 448 bus_init(&instance->bus, sizeof(device_t)); 449 instance->bus.ops = &uhci_bus_ops; 450 451 hc_device_setup(&instance->base, &instance->bus); 446 452 447 453 /* Init USB frame list page */ -
uspace/drv/bus/usb/uhci/hc.h
rb357377 rd369b3b 104 104 105 105 uhci_rh_t rh; 106 usb2_bus_t bus; 106 bus_t bus; 107 usb2_bus_helper_t bus_helper; 108 107 109 /** Addresses of I/O registers */ 108 110 uhci_regs_t *registers; -
uspace/drv/bus/usb/vhc/transfer.c
rb357377 rd369b3b 163 163 } 164 164 165 static int device_enumerate(device_t *device) 166 { 167 vhc_data_t *vhc = bus_to_vhc(device->bus); 168 return usb2_bus_device_enumerate(&vhc->bus_helper, device); 169 } 170 171 static int endpoint_register(endpoint_t *endpoint) 172 { 173 vhc_data_t *vhc = bus_to_vhc(endpoint->device->bus); 174 return usb2_bus_endpoint_register(&vhc->bus_helper, endpoint); 175 } 176 177 static void endpoint_unregister(endpoint_t *endpoint) 178 { 179 vhc_data_t *vhc = bus_to_vhc(endpoint->device->bus); 180 usb2_bus_endpoint_unregister(&vhc->bus_helper, endpoint); 181 182 // TODO: abort transfer? 183 } 184 165 185 static const bus_ops_t vhc_bus_ops = { 166 .parent = &usb2_bus_ops,167 168 186 .batch_create = batch_create, 169 187 .batch_schedule = vhc_schedule, 188 189 .device_enumerate = device_enumerate, 190 .endpoint_register = endpoint_register, 191 .endpoint_unregister = endpoint_unregister, 170 192 }; 171 193 … … 175 197 list_initialize(&instance->devices); 176 198 fibril_mutex_initialize(&instance->guard); 177 usb2_bus_init(&instance->bus, &bandwidth_accounting_usb11); 178 instance->bus.base.ops = &vhc_bus_ops; 199 bus_init(&instance->bus, sizeof(device_t)); 200 usb2_bus_helper_init(&instance->bus_helper, &bandwidth_accounting_usb11); 201 instance->bus.ops = &vhc_bus_ops; 179 202 return virthub_init(&instance->hub, "root hub"); 180 203 } -
uspace/drv/bus/usb/vhc/vhcd.h
rb357377 rd369b3b 60 60 hc_device_t base; 61 61 62 usb2_bus_t bus; 62 bus_t bus; 63 usb2_bus_helper_t bus_helper; 64 63 65 ddf_fun_t *virtual_fun; 64 66 list_t devices;
Note:
See TracChangeset
for help on using the changeset viewer.