Changes in uspace/lib/usbdev/src/pipesio.c [bbce2c2:79ae36dd] in mainline
- File:
-
- 1 edited
-
uspace/lib/usbdev/src/pipesio.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipesio.c
rbbce2c2 r79ae36dd 65 65 void *buffer, size_t size, size_t *size_transfered) 66 66 { 67 /* Only interrupt and bulk transfers are supported */ 68 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 69 pipe->transfer_type != USB_TRANSFER_BULK) 70 return ENOTSUP; 71 72 const usb_target_t target = 73 {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }}; 67 /* 68 * Get corresponding IPC method. 69 * In future, replace with static array of mappings 70 * transfer type -> method. 71 */ 72 usbhc_iface_funcs_t ipc_method; 73 switch (pipe->transfer_type) { 74 case USB_TRANSFER_INTERRUPT: 75 ipc_method = IPC_M_USBHC_INTERRUPT_IN; 76 break; 77 case USB_TRANSFER_BULK: 78 ipc_method = IPC_M_USBHC_BULK_IN; 79 break; 80 default: 81 return ENOTSUP; 82 } 74 83 75 84 /* Ensure serialization over the phone. */ … … 80 89 * Make call identifying target USB device and type of transfer. 81 90 */ 82 aid_t opening_request = async_send_ 2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),83 IPC_M_USBHC_READ, target.packed, NULL);91 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 92 ipc_method, pipe->wire->address, pipe->endpoint_no, NULL); 84 93 85 94 if (opening_request == 0) { … … 204 213 void *buffer, size_t size) 205 214 { 206 /* Only interrupt and bulk transfers are supported */ 207 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 208 pipe->transfer_type != USB_TRANSFER_BULK) 209 return ENOTSUP; 210 211 const usb_target_t target = 212 {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }}; 215 /* 216 * Get corresponding IPC method. 217 * In future, replace with static array of mappings 218 * transfer type -> method. 219 */ 220 usbhc_iface_funcs_t ipc_method; 221 switch (pipe->transfer_type) { 222 case USB_TRANSFER_INTERRUPT: 223 ipc_method = IPC_M_USBHC_INTERRUPT_OUT; 224 break; 225 case USB_TRANSFER_BULK: 226 ipc_method = IPC_M_USBHC_BULK_OUT; 227 break; 228 default: 229 return ENOTSUP; 230 } 213 231 214 232 /* Ensure serialization over the phone. */ … … 220 238 */ 221 239 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 222 IPC_M_USBHC_WRITE, target.packed, size, NULL);240 ipc_method, pipe->wire->address, pipe->endpoint_no, NULL); 223 241 224 242 if (opening_request == 0) { … … 334 352 pipe_start_transaction(pipe); 335 353 336 const usb_target_t target =337 {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};338 339 assert(setup_buffer_size == 8);340 uint64_t setup_packet;341 memcpy(&setup_packet, setup_buffer, 8);342 354 /* 343 355 * Make call identifying target USB device and control transfer type. 344 356 */ 345 357 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 346 aid_t opening_request = async_send_ 4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),347 IPC_M_USBHC_ READ, target.packed,348 (setup_packet & UINT32_MAX), (setup_packet >> 32),NULL);349 358 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 359 IPC_M_USBHC_CONTROL_READ, pipe->wire->address, pipe->endpoint_no, 360 NULL); 361 350 362 if (opening_request == 0) { 351 363 async_exchange_end(exch); 352 364 return ENOMEM; 353 365 } 354 366 367 /* 368 * Send the setup packet. 369 */ 370 int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 371 if (rc != EOK) { 372 async_exchange_end(exch); 373 pipe_end_transaction(pipe); 374 async_wait_for(opening_request, NULL); 375 return rc; 376 } 377 355 378 /* 356 379 * Retrieve the data. … … 475 498 pipe_start_transaction(pipe); 476 499 477 const usb_target_t target =478 {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};479 assert(setup_buffer_size == 8);480 uint64_t setup_packet;481 memcpy(&setup_packet, setup_buffer, 8);482 483 500 /* 484 501 * Make call identifying target USB device and control transfer type. 485 502 */ 486 503 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 487 aid_t opening_request = async_send_ 5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),488 IPC_M_USBHC_ WRITE, target.packed, data_buffer_size,489 (setup_packet & UINT32_MAX), (setup_packet >> 32), NULL);504 aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 505 IPC_M_USBHC_CONTROL_WRITE, pipe->wire->address, pipe->endpoint_no, 506 data_buffer_size, NULL); 490 507 491 508 if (opening_request == 0) { … … 494 511 return ENOMEM; 495 512 } 496 513 514 /* 515 * Send the setup packet. 516 */ 517 int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 518 if (rc != EOK) { 519 async_exchange_end(exch); 520 pipe_end_transaction(pipe); 521 async_wait_for(opening_request, NULL); 522 return rc; 523 } 524 497 525 /* 498 526 * Send the data (if any). 499 527 */ 500 528 if (data_buffer_size > 0) { 501 intrc = async_data_write_start(exch, data_buffer, data_buffer_size);529 rc = async_data_write_start(exch, data_buffer, data_buffer_size); 502 530 503 531 /* All data sent, pipe can be released. */
Note:
See TracChangeset
for help on using the changeset viewer.
