Changeset c6cb76d in mainline for uspace/drv/uhci-hcd/iface.c
- Timestamp:
- 2011-04-08T20:19:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 297341b
- Parents:
- 7dfc06fa (diff), 61727bf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/iface.c
r7dfc06fa rc6cb76d 40 40 #include "iface.h" 41 41 #include "hc.h" 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 42 89 43 90 /** Reserve default address interface function … … 214 261 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 215 262 { 216 assert(fun); 217 hc_t *hc = fun_to_hc(fun); 218 assert(hc); 219 220 usb_log_debug("Interrupt OUT %d:%d %zu.\n", 221 target.address, target.endpoint, size); 222 223 size_t res_bw; 224 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 225 target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw); 226 if (ep == NULL) { 227 usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n", 228 target.address, target.endpoint); 229 return ENOENT; 230 } 231 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 232 size, ep->max_packet_size); 233 if (res_bw < bw) 234 { 235 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 236 "but only %zu is reserved.\n", 237 target.address, target.endpoint, bw, res_bw); 238 return ENOENT; 239 } 240 assert(ep->speed == 241 usb_device_keeper_get_speed(&hc->manager, target.address)); 242 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 243 244 usb_transfer_batch_t *batch = 245 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 246 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 247 if (!batch) 248 return ENOMEM; 263 usb_transfer_batch_t *batch = NULL; 264 hc_t *hc = NULL; 265 int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size, 266 NULL, 0, NULL, callback, arg, "Interrupt OUT", &hc, &batch); 267 if (ret != EOK) 268 return ret; 249 269 batch_interrupt_out(batch); 250 const intret = hc_schedule(hc, batch);270 ret = hc_schedule(hc, batch); 251 271 if (ret != EOK) { 252 272 batch_dispose(batch); … … 269 289 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 270 290 { 271 assert(fun); 272 hc_t *hc = fun_to_hc(fun); 273 assert(hc); 274 275 usb_log_debug("Interrupt IN %d:%d %zu.\n", 276 target.address, target.endpoint, size); 277 278 size_t res_bw; 279 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 280 target.address, target.endpoint, USB_DIRECTION_IN, &res_bw); 281 if (ep == NULL) { 282 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n", 283 target.address, target.endpoint); 284 return ENOENT; 285 } 286 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 287 size, ep->max_packet_size); 288 if (res_bw < bw) 289 { 290 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 291 "but only %zu bw is reserved.\n", 292 target.address, target.endpoint, bw, res_bw); 293 return ENOENT; 294 } 295 296 assert(ep->speed == 297 usb_device_keeper_get_speed(&hc->manager, target.address)); 298 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 299 300 usb_transfer_batch_t *batch = 301 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 302 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 303 if (!batch) 304 return ENOMEM; 291 usb_transfer_batch_t *batch = NULL; 292 hc_t *hc = NULL; 293 int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size, 294 NULL, 0, callback, NULL, arg, "Interrupt IN", &hc, &batch); 295 if (ret != EOK) 296 return ret; 305 297 batch_interrupt_in(batch); 306 const intret = hc_schedule(hc, batch);298 ret = hc_schedule(hc, batch); 307 299 if (ret != EOK) { 308 300 batch_dispose(batch); … … 325 317 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 326 318 { 327 assert(fun); 328 hc_t *hc = fun_to_hc(fun); 329 assert(hc); 330 331 usb_log_debug("Bulk OUT %d:%d %zu.\n", 332 target.address, target.endpoint, size); 333 334 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 335 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 336 if (ep == NULL) { 337 usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n", 338 target.address, target.endpoint); 339 return ENOENT; 340 } 341 assert(ep->speed == 342 usb_device_keeper_get_speed(&hc->manager, target.address)); 343 assert(ep->transfer_type == USB_TRANSFER_BULK); 344 345 usb_transfer_batch_t *batch = 346 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 347 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 348 if (!batch) 349 return ENOMEM; 319 usb_transfer_batch_t *batch = NULL; 320 hc_t *hc = NULL; 321 int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size, 322 NULL, 0, NULL, callback, arg, "Bulk OUT", &hc, &batch); 323 if (ret != EOK) 324 return ret; 350 325 batch_bulk_out(batch); 351 const intret = hc_schedule(hc, batch);326 ret = hc_schedule(hc, batch); 352 327 if (ret != EOK) { 353 328 batch_dispose(batch); … … 370 345 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 371 346 { 372 assert(fun); 373 hc_t *hc = fun_to_hc(fun); 374 assert(hc); 375 usb_log_debug("Bulk IN %d:%d %zu.\n", 376 target.address, target.endpoint, size); 377 378 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 379 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 380 if (ep == NULL) { 381 usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n", 382 target.address, target.endpoint); 383 return ENOENT; 384 } 385 assert(ep->speed == 386 usb_device_keeper_get_speed(&hc->manager, target.address)); 387 assert(ep->transfer_type == USB_TRANSFER_BULK); 388 389 usb_transfer_batch_t *batch = 390 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 391 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 392 if (!batch) 393 return ENOMEM; 347 usb_transfer_batch_t *batch = NULL; 348 hc_t *hc = NULL; 349 int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size, 350 NULL, 0, callback, NULL, arg, "Bulk IN", &hc, &batch); 351 if (ret != EOK) 352 return ret; 394 353 batch_bulk_in(batch); 395 const intret = hc_schedule(hc, batch);354 ret = hc_schedule(hc, batch); 396 355 if (ret != EOK) { 397 356 batch_dispose(batch); … … 417 376 usbhc_iface_transfer_out_callback_t callback, void *arg) 418 377 { 419 assert(fun); 420 hc_t *hc = fun_to_hc(fun); 421 assert(hc); 422 usb_speed_t speed = 423 usb_device_keeper_get_speed(&hc->manager, target.address); 424 usb_log_debug("Control WRITE (%d) %d:%d %zu.\n", 425 speed, target.address, target.endpoint, size); 426 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 427 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 428 if (ep == NULL) { 429 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 430 target.address, target.endpoint); 431 } 432 433 if (setup_size != 8) 434 return EINVAL; 435 436 usb_transfer_batch_t *batch = 437 batch_get(fun, target, USB_TRANSFER_CONTROL, ep->max_packet_size, speed, 438 data, size, setup_data, setup_size, NULL, callback, arg, ep); 439 if (!batch) 440 return ENOMEM; 378 usb_transfer_batch_t *batch = NULL; 379 hc_t *hc = NULL; 380 int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size, 381 setup_data, setup_size, NULL, callback, arg, "Control WRITE", 382 &hc, &batch); 383 if (ret != EOK) 384 return ret; 441 385 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 442 386 batch_control_write(batch); 443 const intret = hc_schedule(hc, batch);387 ret = hc_schedule(hc, batch); 444 388 if (ret != EOK) { 445 389 batch_dispose(batch); … … 465 409 usbhc_iface_transfer_in_callback_t callback, void *arg) 466 410 { 467 assert(fun); 468 hc_t *hc = fun_to_hc(fun); 469 assert(hc); 470 usb_speed_t speed = 471 usb_device_keeper_get_speed(&hc->manager, target.address); 472 473 usb_log_debug("Control READ(%d) %d:%d %zu.\n", 474 speed, target.address, target.endpoint, size); 475 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 476 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL); 477 if (ep == NULL) { 478 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n", 479 target.address, target.endpoint); 480 } 481 usb_transfer_batch_t *batch = 482 batch_get(fun, target, USB_TRANSFER_CONTROL, ep->max_packet_size, speed, 483 data, size, setup_data, setup_size, callback, NULL, arg, ep); 484 if (!batch) 485 return ENOMEM; 411 usb_transfer_batch_t *batch = NULL; 412 hc_t *hc = NULL; 413 int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size, 414 setup_data, setup_size, callback, NULL, arg, "Control READ", 415 &hc, &batch); 416 if (ret != EOK) 417 return ret; 486 418 batch_control_read(batch); 487 const intret = hc_schedule(hc, batch);419 ret = hc_schedule(hc, batch); 488 420 if (ret != EOK) { 489 421 batch_dispose(batch);
Note:
See TracChangeset
for help on using the changeset viewer.