Changeset 26e7d6d in mainline for uspace/lib/usbdev/src/pipesio.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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/usbdev/src/pipesio.c
r3842a955 r26e7d6d 65 65 void *buffer, size_t size, size_t *size_transfered) 66 66 { 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 } 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 }}; 83 74 84 75 /* Ensure serialization over the phone. */ … … 89 80 * Make call identifying target USB device and type of transfer. 90 81 */ 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);82 aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 83 IPC_M_USBHC_READ, target.packed, NULL); 93 84 94 85 if (opening_request == 0) { … … 213 204 void *buffer, size_t size) 214 205 { 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 } 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 }}; 231 213 232 214 /* Ensure serialization over the phone. */ … … 238 220 */ 239 221 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 240 ipc_method, pipe->wire->address, pipe->endpoint_no, NULL);222 IPC_M_USBHC_WRITE, target.packed, size, NULL); 241 223 242 224 if (opening_request == 0) { … … 352 334 pipe_start_transaction(pipe); 353 335 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); 354 342 /* 355 343 * Make call identifying target USB device and control transfer type. 356 344 */ 357 345 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 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 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 362 350 if (opening_request == 0) { 363 351 async_exchange_end(exch); 364 352 return ENOMEM; 365 353 } 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 354 378 355 /* 379 356 * Retrieve the data. … … 498 475 pipe_start_transaction(pipe); 499 476 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 500 483 /* 501 484 * Make call identifying target USB device and control transfer type. 502 485 */ 503 486 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 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);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); 507 490 508 491 if (opening_request == 0) { … … 511 494 return ENOMEM; 512 495 } 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 496 525 497 /* 526 498 * Send the data (if any). 527 499 */ 528 500 if (data_buffer_size > 0) { 529 rc = async_data_write_start(exch, data_buffer, data_buffer_size);501 int rc = async_data_write_start(exch, data_buffer, data_buffer_size); 530 502 531 503 /* All data sent, pipe can be released. */
Note:
See TracChangeset
for help on using the changeset viewer.