Changeset 6ce42e85 in mainline
- Timestamp:
- 2011-04-06T18:13:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 391d55b
- Parents:
- 90b9ab5
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/Makefile
r90b9ab5 r6ce42e85 37 37 transfer_list.c \ 38 38 uhci.c \ 39 endpoint.c \ 39 40 hc.c \ 40 41 root_hub.c \ -
uspace/drv/uhci-hcd/hc.c
r90b9ab5 r6ce42e85 239 239 usb_log_debug("Initialized device manager.\n"); 240 240 241 ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11, 242 bandwidth_count_usb11); 241 ret = 242 usb_endpoint_manager_init(&instance->ep_manager, 243 BANDWIDTH_AVAILABLE_USB11); 243 244 assert(ret == EOK); 244 245 … … 335 336 } 336 337 /* Check available bandwidth */ 338 /* 337 339 if (batch->transfer_type == USB_TRANSFER_INTERRUPT || 338 340 batch->transfer_type == USB_TRANSFER_ISOCHRONOUS) { 339 size_t bw = bandwidth_count_usb11(batch->speed,341 const size_t bw = bandwidth_count_usb11(batch->speed, 340 342 batch->transfer_type, batch->buffer_size, 341 343 batch->max_packet_size); 344 342 345 int ret = 343 346 bandwidth_use(&instance->bandwidth, batch->target.address, … … 349 352 } 350 353 } 354 */ 351 355 352 356 transfer_list_t *list = … … 402 406 case USB_TRANSFER_INTERRUPT: 403 407 case USB_TRANSFER_ISOCHRONOUS: { 408 /* 404 409 int ret = bandwidth_free(&instance->bandwidth, 405 410 batch->target.address, … … 410 415 "reserved bw: %s.\n", ret, 411 416 str_error(ret)); 417 */ 412 418 } 413 419 default: -
uspace/drv/uhci-hcd/hc.h
r90b9ab5 r6ce42e85 43 43 #include <usbhc_iface.h> 44 44 #include <usb/host/device_keeper.h> 45 #include <usb/host/ bandwidth.h>45 #include <usb/host/usb_endpoint_manager.h> 46 46 47 47 #include "batch.h" … … 85 85 typedef struct hc { 86 86 usb_device_keeper_t manager; 87 bandwidth_t bandwidth;87 usb_endpoint_manager_t ep_manager; 88 88 89 89 regs_t *registers; -
uspace/drv/uhci-hcd/iface.c
r90b9ab5 r6ce42e85 37 37 #include <usb/debug.h> 38 38 39 #include "endpoint.h" 39 40 #include "iface.h" 40 41 #include "hc.h" … … 137 138 const usb_speed_t speed = 138 139 usb_device_keeper_get_speed(&hc->manager, address); 139 size_t size = max_packet_size; 140 const size_t size = max_packet_size; 141 142 endpoint_t *ep = malloc(sizeof(endpoint_t)); 143 if (ep == NULL) 144 return ENOMEM; 145 endpoint_init(ep, transfer_type, speed, max_packet_size); 140 146 141 147 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n", 142 148 address, endpoint, usb_str_transfer_type(transfer_type), 143 149 usb_str_speed(speed), direction, size, max_packet_size, interval); 144 return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction, 145 speed, transfer_type, max_packet_size, size, interval); 150 151 const size_t bw = bandwidth_count_usb11(speed, transfer_type, size, 152 max_packet_size); 153 int ret = usb_endpoint_manager_register_ep(&hc->ep_manager, 154 address, endpoint, direction, ep, endpoint_destroy, bw); 155 if (ret != EOK) { 156 endpoint_destroy(ep); 157 } 158 159 return ret; 146 160 } 147 161 /*----------------------------------------------------------------------------*/ … … 154 168 usb_log_debug("Unregister endpoint %d:%d %d.\n", 155 169 address, endpoint, direction); 156 return bandwidth_release(&hc->bandwidth, address, endpoint, direction); 170 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address, 171 endpoint, direction); 157 172 } 158 173 /*----------------------------------------------------------------------------*/ … … 175 190 hc_t *hc = fun_to_hc(fun); 176 191 assert(hc); 177 usb_speed_t speed =178 usb_device_keeper_get_speed(&hc->manager, target.address);179 192 180 193 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 181 194 target.address, target.endpoint, size, max_packet_size); 182 195 183 usb_transfer_batch_t *batch = 184 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 185 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 196 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 197 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 198 if (ep == NULL) { 199 usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n", 200 target.address, target.endpoint); 201 return ENOENT; 202 } 203 assert(ep->speed == 204 usb_device_keeper_get_speed(&hc->manager, target.address)); 205 assert(ep->max_packet_size == max_packet_size); 206 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 207 208 usb_transfer_batch_t *batch = 209 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 210 ep->speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 186 211 if (!batch) 187 212 return ENOMEM; … … 212 237 hc_t *hc = fun_to_hc(fun); 213 238 assert(hc); 214 usb_speed_t speed = 215 usb_device_keeper_get_speed(&hc->manager, target.address); 239 216 240 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 217 241 target.address, target.endpoint, size, max_packet_size); 218 242 219 usb_transfer_batch_t *batch = 220 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 221 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 243 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 244 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 245 if (ep == NULL) { 246 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n", 247 target.address, target.endpoint); 248 return ENOENT; 249 } 250 assert(ep->speed == 251 usb_device_keeper_get_speed(&hc->manager, target.address)); 252 assert(ep->max_packet_size == max_packet_size); 253 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 254 255 usb_transfer_batch_t *batch = 256 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 257 ep->speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 222 258 if (!batch) 223 259 return ENOMEM; … … 248 284 hc_t *hc = fun_to_hc(fun); 249 285 assert(hc); 250 usb_speed_t speed =251 usb_device_keeper_get_speed(&hc->manager, target.address);252 286 253 287 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 254 288 target.address, target.endpoint, size, max_packet_size); 255 289 256 usb_transfer_batch_t *batch = 257 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 258 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 290 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 291 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 292 if (ep == NULL) { 293 usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n", 294 target.address, target.endpoint); 295 return ENOENT; 296 } 297 assert(ep->speed == 298 usb_device_keeper_get_speed(&hc->manager, target.address)); 299 assert(ep->max_packet_size == max_packet_size); 300 assert(ep->transfer_type == USB_TRANSFER_BULK); 301 302 303 usb_transfer_batch_t *batch = 304 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 305 ep->speed, data, size, NULL, 0, NULL, callback, arg, 306 &hc->manager); 259 307 if (!batch) 260 308 return ENOMEM; … … 285 333 hc_t *hc = fun_to_hc(fun); 286 334 assert(hc); 287 usb_speed_t speed =288 usb_device_keeper_get_speed(&hc->manager, target.address);289 335 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 290 336 target.address, target.endpoint, size, max_packet_size); 291 337 292 usb_transfer_batch_t *batch = 293 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 338 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 339 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 340 if (ep == NULL) { 341 usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n", 342 target.address, target.endpoint); 343 return ENOENT; 344 } 345 assert(ep->speed == 346 usb_device_keeper_get_speed(&hc->manager, target.address)); 347 assert(ep->max_packet_size == max_packet_size); 348 assert(ep->transfer_type == USB_TRANSFER_BULK); 349 350 usb_transfer_batch_t *batch = 351 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, ep->speed, 294 352 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 295 353 if (!batch) … … 328 386 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 329 387 speed, target.address, target.endpoint, size, max_packet_size); 388 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 389 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 390 if (ep == NULL) { 391 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 392 target.address, target.endpoint); 393 } 330 394 331 395 if (setup_size != 8) … … 373 437 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 374 438 speed, target.address, target.endpoint, size, max_packet_size); 439 endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager, 440 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 441 if (ep == NULL) { 442 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 443 target.address, target.endpoint); 444 } 375 445 usb_transfer_batch_t *batch = 376 446 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
Note:
See TracChangeset
for help on using the changeset viewer.