Changeset 62066b4 in mainline for uspace/lib/drv/generic/remote_usbhc.c
- Timestamp:
- 2011-02-20T21:47:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ace12560
- Parents:
- 6bb83c7 (diff), 423e8c81 (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/lib/drv/generic/remote_usbhc.c
r6bb83c7 r62066b4 46 46 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 47 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_control_write_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);49 static void remote_usbhc_control_write_data(device_t *, void *, ipc_callid_t, ipc_call_t *);50 static void remote_usbhc_control_write_status(device_t *, void *, ipc_callid_t, ipc_call_t *);51 static void remote_usbhc_control_read_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *);53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *);54 48 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 49 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 75 69 remote_usbhc_interrupt_in, 76 70 77 remote_usbhc_control_write_setup,78 remote_usbhc_control_write_data,79 remote_usbhc_control_write_status,80 81 remote_usbhc_control_read_setup,82 remote_usbhc_control_read_data,83 remote_usbhc_control_read_status,84 85 71 remote_usbhc_control_write, 86 72 remote_usbhc_control_read … … 166 152 } 167 153 168 bool full_speed = DEV_IPC_GET_ARG1(*call);154 usb_speed_t speed = DEV_IPC_GET_ARG1(*call); 169 155 170 int rc = usb_iface->reserve_default_address(device, full_speed);156 int rc = usb_iface->reserve_default_address(device, speed); 171 157 172 158 async_answer_0(callid, rc); … … 198 184 } 199 185 200 bool full_speed = DEV_IPC_GET_ARG1(*call);186 usb_speed_t speed = DEV_IPC_GET_ARG1(*call); 201 187 202 188 usb_address_t address; 203 int rc = usb_iface->request_address(device, full_speed, &address);189 int rc = usb_iface->request_address(device, speed, &address); 204 190 if (rc != EOK) { 205 191 async_answer_0(callid, rc); … … 297 283 } 298 284 299 size_t expected_len= DEV_IPC_GET_ARG3(*call);285 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 300 286 usb_target_t target = { 301 287 .address = DEV_IPC_GET_ARG1(*call), … … 305 291 size_t len = 0; 306 292 void *buffer = NULL; 307 if (expected_len > 0) { 308 int rc = async_data_write_accept(&buffer, false, 309 1, USB_MAX_PAYLOAD_SIZE, 310 0, &len); 311 312 if (rc != EOK) { 313 async_answer_0(callid, rc); 314 return; 315 } 293 294 int rc = async_data_write_accept(&buffer, false, 295 1, USB_MAX_PAYLOAD_SIZE, 296 0, &len); 297 298 if (rc != EOK) { 299 async_answer_0(callid, rc); 300 return; 316 301 } 317 302 … … 328 313 trans->size = len; 329 314 330 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE,315 rc = transfer_func(device, target, max_packet_size, 331 316 buffer, len, 332 317 callback_out, trans); … … 354 339 } 355 340 356 size_t len= DEV_IPC_GET_ARG3(*call);341 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 357 342 usb_target_t target = { 358 343 .address = DEV_IPC_GET_ARG1(*call), … … 360 345 }; 361 346 347 size_t len; 362 348 ipc_callid_t data_callid; 363 349 if (!async_data_read_receive(&data_callid, &len)) { … … 375 361 trans->size = len; 376 362 377 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN,363 int rc = transfer_func(device, target, max_packet_size, 378 364 trans->buffer, len, 379 365 callback_in, trans); … … 385 371 } 386 372 387 /** Process status part of control transfer.388 *389 * @param device Target device.390 * @param callid Initiating caller.391 * @param call Initiating call.392 * @param direction Transfer direction (read ~ in, write ~ out).393 * @param transfer_in_func Transfer function for control read (might be NULL).394 * @param transfer_out_func Transfer function for control write (might be NULL).395 */396 static void remote_usbhc_status_transfer(device_t *device,397 ipc_callid_t callid, ipc_call_t *call,398 usb_direction_t direction,399 int (*transfer_in_func)(device_t *, usb_target_t,400 usbhc_iface_transfer_in_callback_t, void *),401 int (*transfer_out_func)(device_t *, usb_target_t,402 usbhc_iface_transfer_out_callback_t, void *))403 {404 switch (direction) {405 case USB_DIRECTION_IN:406 if (!transfer_in_func) {407 async_answer_0(callid, ENOTSUP);408 return;409 }410 break;411 case USB_DIRECTION_OUT:412 if (!transfer_out_func) {413 async_answer_0(callid, ENOTSUP);414 return;415 }416 break;417 default:418 assert(false && "unreachable code");419 break;420 }421 422 usb_target_t target = {423 .address = DEV_IPC_GET_ARG1(*call),424 .endpoint = DEV_IPC_GET_ARG2(*call)425 };426 427 async_transaction_t *trans = async_transaction_create(callid);428 if (trans == NULL) {429 async_answer_0(callid, ENOMEM);430 return;431 }432 433 int rc;434 switch (direction) {435 case USB_DIRECTION_IN:436 rc = transfer_in_func(device, target,437 callback_in, trans);438 break;439 case USB_DIRECTION_OUT:440 rc = transfer_out_func(device, target,441 callback_out, trans);442 break;443 default:444 assert(false && "unreachable code");445 break;446 }447 448 if (rc != EOK) {449 async_answer_0(callid, rc);450 async_transaction_destroy(trans);451 }452 }453 454 455 373 void remote_usbhc_interrupt_out(device_t *device, void *iface, 456 374 ipc_callid_t callid, ipc_call_t *call) … … 471 389 return remote_usbhc_in_transfer(device, callid, call, 472 390 usb_iface->interrupt_in); 473 }474 475 void remote_usbhc_control_write_setup(device_t *device, void *iface,476 ipc_callid_t callid, ipc_call_t *call)477 {478 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;479 assert(usb_iface != NULL);480 481 return remote_usbhc_out_transfer(device, callid, call,482 usb_iface->control_write_setup);483 }484 485 void remote_usbhc_control_write_data(device_t *device, void *iface,486 ipc_callid_t callid, ipc_call_t *call)487 {488 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;489 assert(usb_iface != NULL);490 491 return remote_usbhc_out_transfer(device, callid, call,492 usb_iface->control_write_data);493 }494 495 void remote_usbhc_control_write_status(device_t *device, void *iface,496 ipc_callid_t callid, ipc_call_t *call)497 {498 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;499 assert(usb_iface != NULL);500 501 return remote_usbhc_status_transfer(device, callid, call,502 USB_DIRECTION_IN, usb_iface->control_write_status, NULL);503 }504 505 void remote_usbhc_control_read_setup(device_t *device, void *iface,506 ipc_callid_t callid, ipc_call_t *call)507 {508 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;509 assert(usb_iface != NULL);510 511 return remote_usbhc_out_transfer(device, callid, call,512 usb_iface->control_read_setup);513 }514 515 void remote_usbhc_control_read_data(device_t *device, void *iface,516 ipc_callid_t callid, ipc_call_t *call)517 {518 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;519 assert(usb_iface != NULL);520 521 return remote_usbhc_in_transfer(device, callid, call,522 usb_iface->control_read_data);523 }524 525 void remote_usbhc_control_read_status(device_t *device, void *iface,526 ipc_callid_t callid, ipc_call_t *call)527 {528 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;529 assert(usb_iface != NULL);530 531 return remote_usbhc_status_transfer(device, callid, call,532 USB_DIRECTION_OUT, NULL, usb_iface->control_read_status);533 391 } 534 392 … … 549 407 }; 550 408 size_t data_buffer_len = DEV_IPC_GET_ARG3(*call); 409 size_t max_packet_size = DEV_IPC_GET_ARG4(*call); 551 410 552 411 int rc; … … 584 443 trans->size = data_buffer_len; 585 444 586 rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE,445 rc = usb_iface->control_write(device, target, max_packet_size, 587 446 setup_packet, setup_packet_len, 588 447 data_buffer, data_buffer_len, … … 611 470 .endpoint = DEV_IPC_GET_ARG2(*call) 612 471 }; 472 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 613 473 614 474 int rc; … … 648 508 } 649 509 650 rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE,510 rc = usb_iface->control_read(device, target, max_packet_size, 651 511 setup_packet, setup_packet_len, 652 512 trans->buffer, trans->size,
Note:
See TracChangeset
for help on using the changeset viewer.