Changeset 79ae36dd in mainline for uspace/lib/usbdev/src/pipesio.c
- Timestamp:
- 2011-06-08T19:01:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipesio.c
r764d71e r79ae36dd 44 44 * obviously). 45 45 */ 46 46 47 #include <usb/usb.h> 47 48 #include <usb/dev/pipes.h> … … 50 51 #include <usbhc_iface.h> 51 52 #include <usb/dev/request.h> 53 #include <async.h> 52 54 #include "pipepriv.h" 53 55 … … 79 81 return ENOTSUP; 80 82 } 81 83 82 84 /* Ensure serialization over the phone. */ 83 85 pipe_start_transaction(pipe); 84 86 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 87 85 88 /* 86 89 * Make call identifying target USB device and type of transfer. 87 90 */ 88 aid_t opening_request = async_send_3(pipe->hc_phone, 89 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 90 pipe->wire->address, pipe->endpoint_no, 91 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); 93 92 94 if (opening_request == 0) { 95 async_exchange_end(exch); 93 96 pipe_end_transaction(pipe); 94 97 return ENOMEM; 95 98 } 96 99 97 100 /* 98 101 * Retrieve the data. 99 102 */ 100 103 ipc_call_t data_request_call; 101 aid_t data_request = async_data_read( pipe->hc_phone, buffer, size,104 aid_t data_request = async_data_read(exch, buffer, size, 102 105 &data_request_call); 103 106 104 107 /* 105 108 * Since now on, someone else might access the backing phone 106 109 * without breaking the transfer IPC protocol. 107 110 */ 111 async_exchange_end(exch); 108 112 pipe_end_transaction(pipe); 109 113 110 114 if (data_request == 0) { 111 115 /* … … 116 120 return ENOMEM; 117 121 } 118 122 119 123 /* 120 124 * Wait for the answer. … … 124 128 async_wait_for(data_request, &data_request_rc); 125 129 async_wait_for(opening_request, &opening_request_rc); 126 130 127 131 if (data_request_rc != EOK) { 128 132 /* Prefer the return code of the opening request. */ … … 136 140 return (int) opening_request_rc; 137 141 } 138 142 139 143 *size_transfered = IPC_GET_ARG2(data_request_call); 140 144 141 145 return EOK; 142 146 } … … 228 232 /* Ensure serialization over the phone. */ 229 233 pipe_start_transaction(pipe); 230 234 async_exch_t *exch = async_exchange_begin(pipe->hc_sess); 235 231 236 /* 232 237 * Make call identifying target USB device and type of transfer. 233 238 */ 234 aid_t opening_request = async_send_3(pipe->hc_phone, 235 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 236 pipe->wire->address, pipe->endpoint_no, 237 NULL); 239 aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 240 ipc_method, pipe->wire->address, pipe->endpoint_no, NULL); 241 238 242 if (opening_request == 0) { 243 async_exchange_end(exch); 239 244 pipe_end_transaction(pipe); 240 245 return ENOMEM; 241 246 } 242 247 243 248 /* 244 249 * Send the data. 245 250 */ 246 int rc = async_data_write_start( pipe->hc_phone, buffer, size);247 251 int rc = async_data_write_start(exch, buffer, size); 252 248 253 /* 249 254 * Since now on, someone else might access the backing phone 250 255 * without breaking the transfer IPC protocol. 251 256 */ 257 async_exchange_end(exch); 252 258 pipe_end_transaction(pipe); 253 259 254 260 if (rc != EOK) { 255 261 async_wait_for(opening_request, NULL); 256 262 return rc; 257 263 } 258 264 259 265 /* 260 266 * Wait for the answer. … … 262 268 sysarg_t opening_request_rc; 263 269 async_wait_for(opening_request, &opening_request_rc); 264 270 265 271 return (int) opening_request_rc; 266 272 } … … 349 355 * Make call identifying target USB device and control transfer type. 350 356 */ 351 a id_t opening_request = async_send_3(pipe->hc_phone,352 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ,353 pipe->wire->address, pipe->endpoint_no,357 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, 354 360 NULL); 361 355 362 if (opening_request == 0) { 363 async_exchange_end(exch); 356 364 return ENOMEM; 357 365 } 358 366 359 367 /* 360 368 * Send the setup packet. 361 369 */ 362 int rc = async_data_write_start( pipe->hc_phone,363 setup_buffer, setup_buffer_size);364 if (rc != EOK) {370 int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 371 if (rc != EOK) { 372 async_exchange_end(exch); 365 373 pipe_end_transaction(pipe); 366 374 async_wait_for(opening_request, NULL); 367 375 return rc; 368 376 } 369 377 370 378 /* 371 379 * Retrieve the data. 372 380 */ 373 381 ipc_call_t data_request_call; 374 aid_t data_request = async_data_read(pipe->hc_phone, 375 data_buffer, data_buffer_size, 376 &data_request_call); 377 382 aid_t data_request = async_data_read(exch, data_buffer, 383 data_buffer_size, &data_request_call); 384 378 385 /* 379 386 * Since now on, someone else might access the backing phone 380 387 * without breaking the transfer IPC protocol. 381 388 */ 389 async_exchange_end(exch); 382 390 pipe_end_transaction(pipe); 383 384 391 385 392 if (data_request == 0) { 386 393 async_wait_for(opening_request, NULL); … … 494 501 * Make call identifying target USB device and control transfer type. 495 502 */ 496 a id_t opening_request = async_send_4(pipe->hc_phone,497 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE,498 pipe->wire->address, pipe->endpoint_no,499 data_buffer_size, 500 NULL);503 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); 507 501 508 if (opening_request == 0) { 509 async_exchange_end(exch); 502 510 pipe_end_transaction(pipe); 503 511 return ENOMEM; 504 512 } 505 513 506 514 /* 507 515 * Send the setup packet. 508 516 */ 509 int rc = async_data_write_start( pipe->hc_phone,510 setup_buffer, setup_buffer_size);511 if (rc != EOK) {517 int rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 518 if (rc != EOK) { 519 async_exchange_end(exch); 512 520 pipe_end_transaction(pipe); 513 521 async_wait_for(opening_request, NULL); 514 522 return rc; 515 523 } 516 524 517 525 /* 518 526 * Send the data (if any). 519 527 */ 520 528 if (data_buffer_size > 0) { 521 rc = async_data_write_start(pipe->hc_phone, 522 data_buffer, data_buffer_size); 523 529 rc = async_data_write_start(exch, data_buffer, data_buffer_size); 530 524 531 /* All data sent, pipe can be released. */ 532 async_exchange_end(exch); 525 533 pipe_end_transaction(pipe); 526 534 527 535 if (rc != EOK) { 528 536 async_wait_for(opening_request, NULL); … … 531 539 } else { 532 540 /* No data to send, we can release the pipe for others. */ 541 async_exchange_end(exch); 533 542 pipe_end_transaction(pipe); 534 543 } 535 544 536 545 /* 537 546 * Wait for the answer.
Note:
See TracChangeset
for help on using the changeset viewer.