Changeset ffe3fe1 in mainline
- Timestamp:
- 2011-09-13T10:52:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a00ac07
- Parents:
- 5ec492b
- Location:
- uspace/lib/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r5ec492b rffe3fe1 41 41 42 42 #define USB_MAX_PAYLOAD_SIZE 1020 43 #define HACK_MAX_PACKET_SIZE 844 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 445 43 46 44 static void remote_usbhc_interrupt_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 56 54 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 55 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 56 static void remote_usbhc_data_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 57 static void remote_usbhc_data_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 58 58 //static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 59 59 60 60 /** Remote USB host controller interface operations. */ 61 static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = { 62 remote_usbhc_request_address, 63 remote_usbhc_bind_address, 64 remote_usbhc_find_by_address, 65 remote_usbhc_release_address, 66 67 remote_usbhc_interrupt_out, 68 remote_usbhc_interrupt_in, 69 70 remote_usbhc_bulk_out, 71 remote_usbhc_bulk_in, 72 73 remote_usbhc_control_write, 74 remote_usbhc_control_read, 75 76 remote_usbhc_register_endpoint, 77 remote_usbhc_unregister_endpoint 61 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = { 62 [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address, 63 [IPC_M_USBHC_BIND_ADDRESS] = remote_usbhc_bind_address, 64 [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_find_by_address, 65 [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address, 66 67 [IPC_M_USBHC_INTERRUPT_OUT] = remote_usbhc_interrupt_out, 68 [IPC_M_USBHC_INTERRUPT_IN] = remote_usbhc_interrupt_in, 69 70 [IPC_M_USBHC_BULK_OUT] = remote_usbhc_bulk_out, 71 [IPC_M_USBHC_BULK_IN] = remote_usbhc_bulk_in, 72 73 [IPC_M_USBHC_CONTROL_WRITE] = remote_usbhc_control_write, 74 [IPC_M_USBHC_CONTROL_READ] = remote_usbhc_control_read, 75 76 [IPC_M_USBHC_REGISTER_ENDPOINT] = remote_usbhc_register_endpoint, 77 [IPC_M_USBHC_UNREGISTER_ENDPOINT] = remote_usbhc_unregister_endpoint, 78 79 [IPC_M_USBHC_DATA_READ] = remote_usbhc_data_read, 80 [IPC_M_USBHC_DATA_WRITE] = remote_usbhc_data_write, 78 81 }; 79 82 … … 135 138 return; 136 139 } 137 140 138 141 usb_speed_t speed = DEV_IPC_GET_ARG1(*call); 139 142 … … 578 581 } 579 582 583 static void remote_usbhc_data_read( 584 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 585 { 586 assert(fun); 587 assert(iface); 588 assert(call); 589 590 const usbhc_iface_t *hc_iface = iface; 591 592 if (!hc_iface->read) { 593 async_answer_0(callid, ENOTSUP); 594 return; 595 } 596 597 const usb_target_t target = { 598 .address = DEV_IPC_GET_ARG1(*call), 599 .endpoint = DEV_IPC_GET_ARG2(*call) 600 }; 601 602 603 async_transaction_t *trans = async_transaction_create(callid); 604 if (trans == NULL) { 605 async_answer_0(callid, ENOMEM); 606 return; 607 } 608 609 if (!async_data_read_receive(&trans->data_caller, &trans->size)) { 610 async_answer_0(callid, EPARTY); 611 return; 612 } 613 614 trans->buffer = malloc(trans->size); 615 if (trans->buffer == NULL) { 616 async_answer_0(trans->data_caller, ENOMEM); 617 async_answer_0(callid, ENOMEM); 618 async_transaction_destroy(trans); 619 } 620 621 const int rc = hc_iface->read( 622 fun, target, 0, trans->buffer, trans->size, callback_in, trans); 623 624 if (rc != EOK) { 625 async_answer_0(trans->data_caller, rc); 626 async_answer_0(callid, rc); 627 async_transaction_destroy(trans); 628 } 629 } 630 631 static void remote_usbhc_data_write( 632 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 633 { 634 assert(fun); 635 assert(iface); 636 assert(call); 637 638 const usbhc_iface_t *hc_iface = iface; 639 640 if (!hc_iface->write) { 641 async_answer_0(callid, ENOTSUP); 642 return; 643 } 644 645 const usb_target_t target = { 646 .address = DEV_IPC_GET_ARG1(*call), 647 .endpoint = DEV_IPC_GET_ARG2(*call) 648 }; 649 650 651 async_transaction_t *trans = async_transaction_create(callid); 652 if (trans == NULL) { 653 async_answer_0(callid, ENOMEM); 654 return; 655 } 656 657 int rc = async_data_write_accept(&trans->buffer, false, 658 1, USB_MAX_PAYLOAD_SIZE, 659 0, &trans->size); 660 661 if (rc != EOK) { 662 async_answer_0(callid, rc); 663 async_transaction_destroy(trans); 664 return; 665 } 666 667 rc = hc_iface->write( 668 fun, target, 0, trans->buffer, trans->size, callback_out, trans); 669 670 if (rc != EOK) { 671 async_answer_0(callid, rc); 672 async_transaction_destroy(trans); 673 } 674 } 675 580 676 581 677 /** -
uspace/lib/drv/include/usbhc_iface.h
r5ec492b rffe3fe1 185 185 * - ENOENT - unknown endpoint 186 186 */ 187 IPC_M_USBHC_UNREGISTER_ENDPOINT 187 IPC_M_USBHC_UNREGISTER_ENDPOINT, 188 189 IPC_M_USBHC_DATA_READ, 190 191 IPC_M_USBHC_DATA_WRITE, 188 192 } usbhc_iface_funcs_t; 189 193 … … 236 240 void *, size_t, void *, size_t, 237 241 usbhc_iface_transfer_in_callback_t, void *); 242 243 int (*read)(ddf_fun_t *, usb_target_t, uint64_t, uint8_t *, size_t, 244 usbhc_iface_transfer_in_callback_t, void *); 245 246 int (*write)(ddf_fun_t *, usb_target_t, uint64_t, const uint8_t *, 247 size_t, usbhc_iface_transfer_out_callback_t, void *); 238 248 } usbhc_iface_t; 239 249
Note:
See TracChangeset
for help on using the changeset viewer.