Changeset 6832245 in mainline for uspace/drv/bus/usb/ehci/ehci_bus.c
- Timestamp:
- 2017-12-14T23:01:57Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 837d53d
- Parents:
- bd05140
- git-author:
- Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:54)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci_bus.c
rbd05140 r6832245 79 79 /** Creates new hcd endpoint representation. 80 80 */ 81 static endpoint_t *ehci_endpoint_create( bus_t *bus)81 static endpoint_t *ehci_endpoint_create(device_t *dev, const usb_endpoint_desc_t *desc) 82 82 { 83 assert( bus);83 assert(dev); 84 84 85 85 ehci_endpoint_t *ehci_ep = malloc(sizeof(ehci_endpoint_t)); … … 87 87 return NULL; 88 88 89 endpoint_init(&ehci_ep->base, bus); 89 endpoint_init(&ehci_ep->base, dev, desc); 90 91 // TODO: extract USB2 information from desc 90 92 91 93 ehci_ep->qh = malloc32(sizeof(qh_t)); … … 114 116 115 117 116 static int ehci_register_ep( bus_t *bus_base, device_t *dev, endpoint_t *ep, const usb_endpoint_desc_t *desc)118 static int ehci_register_ep(endpoint_t *ep) 117 119 { 120 bus_t *bus_base = endpoint_get_bus(ep); 118 121 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 119 122 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep); 123 assert(fibril_mutex_is_locked(&bus_base->guard)); 120 124 121 // TODO utilize desc->usb2 122 123 const int err = bus->parent_ops.register_endpoint(bus_base, dev, ep, desc); 125 const int err = usb2_bus_ops.endpoint_register(ep); 124 126 if (err) 125 127 return err; … … 131 133 } 132 134 133 static int ehci_unregister_ep( bus_t *bus_base,endpoint_t *ep)135 static int ehci_unregister_ep(endpoint_t *ep) 134 136 { 137 bus_t *bus_base = endpoint_get_bus(ep); 135 138 ehci_bus_t *bus = (ehci_bus_t *) bus_base; 136 139 assert(bus); 137 140 assert(ep); 138 141 139 const int err = bus->parent_ops.unregister_endpoint(bus_base,ep);142 const int err = usb2_bus_ops.endpoint_unregister(ep); 140 143 if (err) 141 144 return err; … … 145 148 } 146 149 147 static usb_transfer_batch_t *ehci_ bus_create_batch(bus_t *bus,endpoint_t *ep)150 static usb_transfer_batch_t *ehci_create_batch(endpoint_t *ep) 148 151 { 149 152 ehci_transfer_batch_t *batch = ehci_transfer_batch_create(ep); … … 151 154 } 152 155 153 static void ehci_ bus_destroy_batch(usb_transfer_batch_t *batch)156 static void ehci_destroy_batch(usb_transfer_batch_t *batch) 154 157 { 155 158 ehci_transfer_batch_destroy(ehci_transfer_batch_get(batch)); 156 159 } 157 160 158 int ehci_bus_init(ehci_bus_t *bus, hc_t *hc) 161 static const bus_ops_t ehci_bus_ops = { 162 .parent = &usb2_bus_ops, 163 164 .endpoint_destroy = ehci_endpoint_destroy, 165 .endpoint_create = ehci_endpoint_create, 166 .endpoint_register = ehci_register_ep, 167 .endpoint_unregister = ehci_unregister_ep, 168 .endpoint_set_toggle = ehci_ep_toggle_set, 169 .endpoint_get_toggle = ehci_ep_toggle_get, 170 .endpoint_count_bw = bandwidth_count_usb11, 171 .batch_create = ehci_create_batch, 172 .batch_destroy = ehci_destroy_batch, 173 }; 174 175 int ehci_bus_init(ehci_bus_t *bus, hcd_t *hcd, hc_t *hc) 159 176 { 160 177 assert(hc); 161 178 assert(bus); 162 179 163 // FIXME: Implement the USB2 bw counting.164 usb2_bus_init(&bus->base, BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);180 usb2_bus_t *usb2_bus = (usb2_bus_t *) bus; 181 bus_t *bus_base = (bus_t *) bus; 165 182 166 bus_ops_t *ops = &bus->base.base.ops; 167 bus->parent_ops = *ops; 168 ops->create_endpoint = ehci_endpoint_create; 169 ops->destroy_endpoint = ehci_endpoint_destroy; 170 ops->endpoint_set_toggle = ehci_ep_toggle_set; 171 ops->endpoint_get_toggle = ehci_ep_toggle_get; 172 173 ops->register_endpoint = ehci_register_ep; 174 ops->unregister_endpoint = ehci_unregister_ep; 175 176 ops->create_batch = ehci_bus_create_batch; 177 ops->destroy_batch = ehci_bus_destroy_batch; 183 usb2_bus_init(usb2_bus, hcd, BANDWIDTH_AVAILABLE_USB11); 184 bus_base->ops = &ehci_bus_ops; 178 185 179 186 bus->hc = hc;
Note:
See TracChangeset
for help on using the changeset viewer.