Changeset 2e6bbcf in mainline
- Timestamp:
- 2011-04-07T21:59:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 52cc968
- Parents:
- feb10c88
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/iface.c
rfeb10c88 r2e6bbcf 41 41 #include "hc.h" 42 42 43 static inline int setup_batch( 44 ddf_fun_t *fun, usb_target_t target, usb_direction_t direction, 45 void *data, size_t size, void * setup_data, size_t setup_size, 46 usbhc_iface_transfer_in_callback_t in, 47 usbhc_iface_transfer_out_callback_t out, void *arg, const char* name, 48 hc_t **hc, usb_transfer_batch_t **batch) 49 { 50 assert(hc); 51 assert(batch); 52 assert(fun); 53 *hc = fun_to_hc(fun); 54 assert(*hc); 55 56 size_t res_bw; 57 endpoint_t *ep = usb_endpoint_manager_get_ep(&(*hc)->ep_manager, 58 target.address, target.endpoint, direction, &res_bw); 59 if (ep == NULL) { 60 usb_log_error("Endpoint(%d:%d) not registered for %s.\n", 61 target.address, target.endpoint, name); 62 return ENOENT; 63 } 64 65 const size_t bw = bandwidth_count_usb11( 66 ep->speed, ep->transfer_type, size, ep->max_packet_size); 67 if (res_bw < bw) { 68 usb_log_error("Endpoint(%d:%d) %s needs %zu bw " 69 "but only %zu is reserved.\n", 70 name, target.address, target.endpoint, bw, res_bw); 71 return ENOSPC; 72 } 73 usb_log_debug("%s %d:%d %zu(%zu).\n", 74 name, target.address, target.endpoint, size, ep->max_packet_size); 75 76 assert(ep->speed == 77 usb_device_keeper_get_speed(&(*hc)->manager, target.address)); 78 // assert(ep->max_packet_size == max_packet_size); 79 // assert(ep->transfer_type == USB_TRANSFER_CONTROL); 80 81 *batch = 82 batch_get(fun, ep, data, size, setup_data, setup_size, 83 in, out, arg); 84 if (!batch) 85 return ENOMEM; 86 return EOK; 87 } 88 89 43 90 /** Reserve default address interface function 44 91 * … … 215 262 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 216 263 { 264 usb_transfer_batch_t *batch = NULL; 265 hc_t *hc = NULL; 266 int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size, 267 NULL, 0, NULL, callback, arg, "Interrupt OUT", &hc, &batch); 268 if (ret != EOK) 269 return ret; 270 #if 0 217 271 assert(fun); 218 272 hc_t *hc = fun_to_hc(fun); … … 233 287 size, ep->max_packet_size); 234 288 if (res_bw < bw) { 235 usb_log_error("Endpoint(%d:%d) INT INneeds %zu bw "289 usb_log_error("Endpoint(%d:%d) INT OUT needs %zu bw " 236 290 "but only %zu is reserved.\n", 237 291 target.address, target.endpoint, bw, res_bw); 238 return ENOENT; 239 } 292 return ENOSPC; 293 } 294 240 295 assert(ep->speed == 241 296 usb_device_keeper_get_speed(&hc->manager, target.address)); … … 247 302 if (!batch) 248 303 return ENOMEM; 304 #endif 249 305 batch_interrupt_out(batch); 250 const intret = hc_schedule(hc, batch);306 ret = hc_schedule(hc, batch); 251 307 if (ret != EOK) { 252 308 batch_dispose(batch); … … 270 326 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 271 327 { 328 usb_transfer_batch_t *batch = NULL; 329 hc_t *hc = NULL; 330 int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size, 331 NULL, 0, callback, NULL, arg, "Interrupt IN", &hc, &batch); 332 if (ret != EOK) 333 return ret; 334 #if 0 272 335 assert(fun); 273 336 hc_t *hc = fun_to_hc(fun); … … 283 346 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n", 284 347 target.address, target.endpoint); 285 return ENO ENT;348 return ENOSPC; 286 349 } 287 350 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, … … 303 366 if (!batch) 304 367 return ENOMEM; 368 #endif 305 369 batch_interrupt_in(batch); 306 const intret = hc_schedule(hc, batch);370 ret = hc_schedule(hc, batch); 307 371 if (ret != EOK) { 308 372 batch_dispose(batch); … … 326 390 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 327 391 { 392 usb_transfer_batch_t *batch = NULL; 393 hc_t *hc = NULL; 394 int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size, 395 NULL, 0, NULL, callback, arg, "Bulk OUT", &hc, &batch); 396 if (ret != EOK) 397 return ret; 398 #if 0 328 399 assert(fun); 329 400 hc_t *hc = fun_to_hc(fun); … … 349 420 if (!batch) 350 421 return ENOMEM; 422 #endif 351 423 batch_bulk_out(batch); 352 const intret = hc_schedule(hc, batch);424 ret = hc_schedule(hc, batch); 353 425 if (ret != EOK) { 354 426 batch_dispose(batch); … … 372 444 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 373 445 { 374 assert(fun); 375 hc_t *hc = fun_to_hc(fun); 376 assert(hc); 446 usb_transfer_batch_t *batch = NULL; 447 hc_t *hc = NULL; 448 int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size, 449 NULL, 0, callback, NULL, arg, "Bulk IN", &hc, &batch); 450 if (ret != EOK) 451 return ret; 452 #if 0 453 assert(fun); 454 hc_t *hc = fun_to_hc(fun); 455 assert(hc); 456 377 457 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 378 458 target.address, target.endpoint, size, max_packet_size); … … 394 474 if (!batch) 395 475 return ENOMEM; 476 #endif 396 477 batch_bulk_in(batch); 397 const intret = hc_schedule(hc, batch);478 ret = hc_schedule(hc, batch); 398 479 if (ret != EOK) { 399 480 batch_dispose(batch); … … 420 501 usbhc_iface_transfer_out_callback_t callback, void *arg) 421 502 { 503 usb_transfer_batch_t *batch = NULL; 504 hc_t *hc = NULL; 505 int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size, 506 setup_data, setup_size, NULL, callback, arg, "Control WRITE", 507 &hc, &batch); 508 if (ret != EOK) 509 return ret; 510 #if 0 422 511 assert(fun); 423 512 hc_t *hc = fun_to_hc(fun); … … 447 536 if (!batch) 448 537 return ENOMEM; 538 #endif 449 539 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 450 540 batch_control_write(batch); 451 const intret = hc_schedule(hc, batch);541 ret = hc_schedule(hc, batch); 452 542 if (ret != EOK) { 453 543 batch_dispose(batch); … … 474 564 usbhc_iface_transfer_in_callback_t callback, void *arg) 475 565 { 566 usb_transfer_batch_t *batch = NULL; 567 hc_t *hc = NULL; 568 int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size, 569 setup_data, setup_size, callback, NULL, arg, "Control READ", 570 &hc, &batch); 571 if (ret != EOK) 572 return ret; 573 #if 0 476 574 assert(fun); 477 575 hc_t *hc = fun_to_hc(fun); … … 498 596 if (!batch) 499 597 return ENOMEM; 598 #endif 500 599 batch_control_read(batch); 501 const intret = hc_schedule(hc, batch);600 ret = hc_schedule(hc, batch); 502 601 if (ret != EOK) { 503 602 batch_dispose(batch);
Note:
See TracChangeset
for help on using the changeset viewer.