Changeset fa2a361 in mainline
- Timestamp:
- 2010-10-26T21:38:59Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aab02fb
- Parents:
- 56cb9bd
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/hcd.c
r56cb9bd rfa2a361 40 40 #include <errno.h> 41 41 42 /** Information about pending transaction on HC. */ 42 43 typedef struct { 44 /** Phone to host controller driver. */ 43 45 int phone; 46 /** Data buffer. */ 44 47 void *buffer; 48 /** Buffer size. */ 45 49 size_t size; 50 /** Storage for actual number of bytes transferred. */ 46 51 size_t *size_transferred; 52 /** Initial call replay data. */ 47 53 ipc_call_t reply; 54 /** Initial call identifier. */ 48 55 aid_t request; 49 56 } transfer_info_t; … … 355 362 * ================= 356 363 */ 357 364 365 /** Send data to HCD. 366 * 367 * @param phone Opened phone to HCD. 368 * @param method Method used for calling. 369 * @param target Target device. 370 * @param buffer Data buffer (NULL to skip data transfer phase). 371 * @param size Buffer size (must be zero when @p buffer is NULL). 372 * @param handle Storage for transaction handle (cannot be NULL). 373 * @return Error status. 374 * @retval EINVAL Invalid parameter. 375 * @retval ENOMEM Not enough memory to complete the operation. 376 */ 358 377 static int async_send_buffer(int phone, int method, 359 378 usb_target_t target, … … 405 424 } 406 425 426 /** Prepare data retrieval. 427 * 428 * @param phone Opened phone to HCD. 429 * @param method Method used for calling. 430 * @param target Target device. 431 * @param buffer Buffer where to store retrieved data 432 * (NULL to skip data transfer phase). 433 * @param size Buffer size (must be zero when @p buffer is NULL). 434 * @param actual_size Storage where actual number of bytes transferred will 435 * be stored. 436 * @param handle Storage for transaction handle (cannot be NULL). 437 * @return Error status. 438 * @retval EINVAL Invalid parameter. 439 * @retval ENOMEM Not enough memory to complete the operation. 440 */ 407 441 static int async_recv_buffer(int phone, int method, 408 442 usb_target_t target, … … 444 478 } 445 479 480 /** Read buffer from HCD. 481 * 482 * @param phone Opened phone to HCD. 483 * @param hash Buffer hash (obtained after completing IN transaction). 484 * @param buffer Buffer where to store data data. 485 * @param size Buffer size. 486 * @param actual_size Storage where actual number of bytes transferred will 487 * be stored. 488 * @return Error status. 489 */ 446 490 static int read_buffer_in(int phone, ipcarg_t hash, 447 491 void *buffer, size_t size, size_t *actual_size) … … 475 519 } 476 520 477 521 /** Blocks caller until given USB transaction is finished. 522 * After the transaction is finished, the user can access all output data 523 * given to initial call function. 524 * 525 * @param handle Transaction handle. 526 * @return Error status. 527 * @retval EOK No error. 528 * @retval EBADMEM Invalid handle. 529 * @retval ENOENT Data buffer associated with transaction does not exist. 530 */ 478 531 int usb_hcd_async_wait_for(usb_handle_t handle) 479 532 { … … 528 581 } 529 582 583 /** Send interrupt data to device. */ 530 584 int usb_hcd_async_transfer_interrupt_out(int hcd_phone, 531 585 usb_target_t target, … … 540 594 } 541 595 596 /** Request interrupt data from device. */ 542 597 int usb_hcd_async_transfer_interrupt_in(int hcd_phone, 543 598 usb_target_t target, … … 552 607 } 553 608 609 /** Start WRITE control transfer. */ 554 610 int usb_hcd_async_transfer_control_write_setup(int hcd_phone, 555 611 usb_target_t target, … … 564 620 } 565 621 622 /** Send data during WRITE control transfer. */ 566 623 int usb_hcd_async_transfer_control_write_data(int hcd_phone, 567 624 usb_target_t target, … … 576 633 } 577 634 635 /** Terminate WRITE control transfer. */ 578 636 int usb_hcd_async_transfer_control_write_status(int hcd_phone, 579 637 usb_target_t target, … … 587 645 } 588 646 647 /** Start READ control transfer. */ 589 648 int usb_hcd_async_transfer_control_read_setup(int hcd_phone, 590 649 usb_target_t target, … … 599 658 } 600 659 660 /** Request data during READ control transfer. */ 601 661 int usb_hcd_async_transfer_control_read_data(int hcd_phone, 602 662 usb_target_t target, … … 611 671 } 612 672 673 /** Terminate READ control transfer. */ 613 674 int usb_hcd_async_transfer_control_read_status(int hcd_phone, 614 675 usb_target_t target, -
uspace/lib/usb/hcd.h
r56cb9bd rfa2a361 85 85 const char * usb_str_transaction_outcome(usb_transaction_outcome_t o); 86 86 87 /** IPC methods for HCD. */ 87 /** IPC methods for HCD. 88 * 89 * Notes for async methods: 90 * 91 * Methods for sending data to device (OUT transactions) 92 * - e.g. IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC - 93 * always use the same semantics: 94 * - first, IPC call with given method is made 95 * - argument #1 is target address 96 * - argument #2 is target endpoint 97 * - argument #3 is buffer size 98 * - this call is immediately followed by IPC data write (from caller) 99 * - the initial call (and the whole transaction) is answer after the 100 * transaction is scheduled by the HC and acknowledged by the device 101 * or immediatelly after error is detected 102 * - the answer carries only the error code 103 * 104 * Methods for retrieving data from device (IN transactions) 105 * - e.g. IPC_M_USB_HCD_INTERRUPT_IN_ASYNC - 106 * also use the same semantics: 107 * - first, IPC call with given method is made 108 * - argument #1 is target address 109 * - argument #2 is target endpoint 110 * - argument #3 is buffer size 111 * - the call is not answered until the device returns some data (or until 112 * error occurs) 113 * - if the call is answered with EOK, first argument of the answer is buffer 114 * hash that could be used to retrieve the actual data 115 * 116 * Some special methods (NO-DATA transactions) do not send any data. These 117 * might behave as both OUT or IN transactions because communication parts 118 * where actual buffers are exchanged are ommitted. 119 * 120 * The mentioned data retrieval can be done any time after receiving EOK 121 * answer to IN method. 122 * This retrieval is done using the IPC_M_USB_HCD_GET_BUFFER_ASYNC where 123 * the first argument is buffer hash from call answer. 124 * This call must be immediatelly followed by data read-in and after the 125 * data are transferred, the initial call (IPC_M_USB_HCD_GET_BUFFER_ASYNC) 126 * is answered. Each buffer can be retrieved only once. 127 * 128 * For all these methods, wrap functions exists. Important rule: functions 129 * for IN transactions have (as parameters) buffers where retrieved data 130 * will be stored. These buffers must be already allocated and shall not be 131 * touch until the transaction is completed 132 * (e.g. not before calling usb_hcd_async_wait_for() with appropriate handle). 133 * OUT transactions buffers can be freed immediatelly after call is dispatched 134 * (i.e. after return from wrapping function). 135 * 136 * Async methods for retrieving data from device: 137 */ 88 138 typedef enum { 89 139 /** Send data over USB to a function. … … 157 207 IPC_M_USB_HCD_CONTROL_READ_STATUS, 158 208 209 /* async methods */ 210 211 /** Asks for data buffer. 212 * See explanation at usb_hcd_method_t. 213 */ 159 214 IPC_M_USB_HCD_GET_BUFFER_ASYNC, 160 215 216 217 218 /** Send interrupt data to device. 219 * See explanation at usb_hcd_method_t (OUT transaction). 220 */ 161 221 IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC, 222 223 /** Get interrupt data from device. 224 * See explanation at usb_hcd_method_t (IN transaction). 225 */ 162 226 IPC_M_USB_HCD_INTERRUPT_IN_ASYNC, 163 227 228 229 /** Start WRITE control transfer. 230 * See explanation at usb_hcd_method_t (OUT transaction). 231 */ 164 232 IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC, 233 234 /** Send control-transfer data to device. 235 * See explanation at usb_hcd_method_t (OUT transaction). 236 */ 165 237 IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC, 238 239 /** Terminate WRITE control transfer. 240 * See explanation at usb_hcd_method_t (NO-DATA transaction). 241 */ 166 242 IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC, 167 243 244 245 246 /** Start READ control transfer. 247 * See explanation at usb_hcd_method_t (OUT transaction). 248 */ 168 249 IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC, 250 251 /** Get control-transfer data from device. 252 * See explanation at usb_hcd_method_t (IN transaction). 253 */ 169 254 IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC, 255 256 /** Terminate READ control transfer. 257 * See explanation at usb_hcd_method_t (NO-DATA transaction). 258 */ 170 259 IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC, 260 261 171 262 /* IPC_M_USB_HCD_ */ 172 263 } usb_hcd_method_t;
Note:
See TracChangeset
for help on using the changeset viewer.