Changeset e50cd7f in mainline for uspace/lib/usb/src/pipesio.c
- Timestamp:
- 2011-04-17T19:17:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63517c2, cfbbe1d3
- Parents:
- ef354b6 (diff), 8595577b (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/usb/src/pipesio.c
ref354b6 re50cd7f 49 49 #include <assert.h> 50 50 #include <usbhc_iface.h> 51 #include <usb/request.h> 52 #include "pipepriv.h" 51 53 52 54 /** Request an in transfer, no checking of input parameters. … … 78 80 } 79 81 82 /* Ensure serialization over the phone. */ 83 pipe_start_transaction(pipe); 84 80 85 /* 81 86 * Make call identifying target USB device and type of transfer. 82 87 */ 83 aid_t opening_request = async_send_ 4(pipe->hc_phone,88 aid_t opening_request = async_send_3(pipe->hc_phone, 84 89 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 85 90 pipe->wire->address, pipe->endpoint_no, 86 pipe->max_packet_size,87 91 NULL); 88 92 if (opening_request == 0) { 93 pipe_end_transaction(pipe); 89 94 return ENOMEM; 90 95 } … … 96 101 aid_t data_request = async_data_read(pipe->hc_phone, buffer, size, 97 102 &data_request_call); 103 104 /* 105 * Since now on, someone else might access the backing phone 106 * without breaking the transfer IPC protocol. 107 */ 108 pipe_end_transaction(pipe); 98 109 99 110 if (data_request == 0) { … … 146 157 147 158 if (buffer == NULL) { 148 159 return EINVAL; 149 160 } 150 161 151 162 if (size == 0) { 152 163 return EINVAL; 153 }154 155 if (!usb_pipe_is_session_started(pipe)) {156 return EBADF;157 164 } 158 165 … … 165 172 } 166 173 174 int rc; 175 rc = pipe_add_ref(pipe); 176 if (rc != EOK) { 177 return rc; 178 } 179 180 167 181 size_t act_size = 0; 168 int rc;169 182 170 183 rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size); 184 185 pipe_drop_ref(pipe); 186 171 187 if (rc != EOK) { 172 188 return rc; … … 210 226 } 211 227 228 /* Ensure serialization over the phone. */ 229 pipe_start_transaction(pipe); 230 212 231 /* 213 232 * Make call identifying target USB device and type of transfer. 214 233 */ 215 aid_t opening_request = async_send_ 4(pipe->hc_phone,234 aid_t opening_request = async_send_3(pipe->hc_phone, 216 235 DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method, 217 236 pipe->wire->address, pipe->endpoint_no, 218 pipe->max_packet_size,219 237 NULL); 220 238 if (opening_request == 0) { 239 pipe_end_transaction(pipe); 221 240 return ENOMEM; 222 241 } … … 226 245 */ 227 246 int rc = async_data_write_start(pipe->hc_phone, buffer, size); 247 248 /* 249 * Since now on, someone else might access the backing phone 250 * without breaking the transfer IPC protocol. 251 */ 252 pipe_end_transaction(pipe); 253 228 254 if (rc != EOK) { 229 255 async_wait_for(opening_request, NULL); … … 260 286 } 261 287 262 if (!usb_pipe_is_session_started(pipe)) {263 return EBADF;264 }265 266 288 if (pipe->direction != USB_DIRECTION_OUT) { 267 289 return EBADF; … … 272 294 } 273 295 274 int rc = usb_pipe_write_no_check(pipe, buffer, size); 296 int rc; 297 298 rc = pipe_add_ref(pipe); 299 if (rc != EOK) { 300 return rc; 301 } 302 303 rc = usb_pipe_write_no_check(pipe, buffer, size); 304 305 pipe_drop_ref(pipe); 275 306 276 307 return rc; 308 } 309 310 /** Try to clear endpoint halt of default control pipe. 311 * 312 * @param pipe Pipe for control endpoint zero. 313 */ 314 static void clear_self_endpoint_halt(usb_pipe_t *pipe) 315 { 316 assert(pipe != NULL); 317 318 if (!pipe->auto_reset_halt || (pipe->endpoint_no != 0)) { 319 return; 320 } 321 322 323 /* Prevent indefinite recursion. */ 324 pipe->auto_reset_halt = false; 325 usb_request_clear_endpoint_halt(pipe, 0); 326 pipe->auto_reset_halt = true; 277 327 } 278 328 … … 293 343 void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size) 294 344 { 345 /* Ensure serialization over the phone. */ 346 pipe_start_transaction(pipe); 347 295 348 /* 296 349 * Make call identifying target USB device and control transfer type. 297 350 */ 298 aid_t opening_request = async_send_ 4(pipe->hc_phone,351 aid_t opening_request = async_send_3(pipe->hc_phone, 299 352 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ, 300 353 pipe->wire->address, pipe->endpoint_no, 301 pipe->max_packet_size,302 354 NULL); 303 355 if (opening_request == 0) { … … 311 363 setup_buffer, setup_buffer_size); 312 364 if (rc != EOK) { 365 pipe_end_transaction(pipe); 313 366 async_wait_for(opening_request, NULL); 314 367 return rc; … … 322 375 data_buffer, data_buffer_size, 323 376 &data_request_call); 377 378 /* 379 * Since now on, someone else might access the backing phone 380 * without breaking the transfer IPC protocol. 381 */ 382 pipe_end_transaction(pipe); 383 384 324 385 if (data_request == 0) { 325 386 async_wait_for(opening_request, NULL); … … 379 440 } 380 441 381 if (!usb_pipe_is_session_started(pipe)) {382 return EBADF;383 }384 385 442 if ((pipe->direction != USB_DIRECTION_BOTH) 386 443 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 388 445 } 389 446 447 int rc; 448 449 rc = pipe_add_ref(pipe); 450 if (rc != EOK) { 451 return rc; 452 } 453 390 454 size_t act_size = 0; 391 intrc = usb_pipe_control_read_no_check(pipe,455 rc = usb_pipe_control_read_no_check(pipe, 392 456 setup_buffer, setup_buffer_size, 393 457 data_buffer, data_buffer_size, &act_size); 458 459 if (rc == ESTALL) { 460 clear_self_endpoint_halt(pipe); 461 } 462 463 pipe_drop_ref(pipe); 394 464 395 465 if (rc != EOK) { … … 418 488 void *data_buffer, size_t data_buffer_size) 419 489 { 490 /* Ensure serialization over the phone. */ 491 pipe_start_transaction(pipe); 492 420 493 /* 421 494 * Make call identifying target USB device and control transfer type. 422 495 */ 423 aid_t opening_request = async_send_ 5(pipe->hc_phone,496 aid_t opening_request = async_send_4(pipe->hc_phone, 424 497 DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE, 425 498 pipe->wire->address, pipe->endpoint_no, 426 499 data_buffer_size, 427 pipe->max_packet_size,428 500 NULL); 429 501 if (opening_request == 0) { 502 pipe_end_transaction(pipe); 430 503 return ENOMEM; 431 504 } … … 437 510 setup_buffer, setup_buffer_size); 438 511 if (rc != EOK) { 512 pipe_end_transaction(pipe); 439 513 async_wait_for(opening_request, NULL); 440 514 return rc; … … 447 521 rc = async_data_write_start(pipe->hc_phone, 448 522 data_buffer, data_buffer_size); 523 524 /* All data sent, pipe can be released. */ 525 pipe_end_transaction(pipe); 526 449 527 if (rc != EOK) { 450 528 async_wait_for(opening_request, NULL); 451 529 return rc; 452 530 } 531 } else { 532 /* No data to send, we can release the pipe for others. */ 533 pipe_end_transaction(pipe); 453 534 } 454 535 … … 491 572 } 492 573 493 if (!usb_pipe_is_session_started(pipe)) {494 return EBADF;495 }496 497 574 if ((pipe->direction != USB_DIRECTION_BOTH) 498 575 || (pipe->transfer_type != USB_TRANSFER_CONTROL)) { … … 500 577 } 501 578 502 int rc = usb_pipe_control_write_no_check(pipe, 579 int rc; 580 581 rc = pipe_add_ref(pipe); 582 if (rc != EOK) { 583 return rc; 584 } 585 586 rc = usb_pipe_control_write_no_check(pipe, 503 587 setup_buffer, setup_buffer_size, data_buffer, data_buffer_size); 588 589 if (rc == ESTALL) { 590 clear_self_endpoint_halt(pipe); 591 } 592 593 pipe_drop_ref(pipe); 504 594 505 595 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.