Changeset 374552ef in mainline for uspace/lib/drv
- Timestamp:
- 2011-02-18T20:22:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 423e8c81, 6edc69a, fbf0589
- Parents:
- b6c7da6 (diff), b36e5de2 (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. - Location:
- uspace/lib/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
rb6c7da6 r374552ef 46 46 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 47 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); 48 static void remote_usbhc_control_write_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);49 static void remote_usbhc_control_write_data(device_t *, void *, ipc_callid_t, ipc_call_t *);50 static void remote_usbhc_control_write_status(device_t *, void *, ipc_callid_t, ipc_call_t *);51 static void remote_usbhc_control_read_setup(device_t *, void *, ipc_callid_t, ipc_call_t *);52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *);53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *);54 48 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 49 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 75 69 remote_usbhc_interrupt_in, 76 70 77 remote_usbhc_control_write_setup,78 remote_usbhc_control_write_data,79 remote_usbhc_control_write_status,80 81 remote_usbhc_control_read_setup,82 remote_usbhc_control_read_data,83 remote_usbhc_control_read_status,84 85 71 remote_usbhc_control_write, 86 72 remote_usbhc_control_read … … 297 283 } 298 284 299 size_t expected_len= DEV_IPC_GET_ARG3(*call);285 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 300 286 usb_target_t target = { 301 287 .address = DEV_IPC_GET_ARG1(*call), … … 305 291 size_t len = 0; 306 292 void *buffer = NULL; 307 if (expected_len > 0) { 308 int rc = async_data_write_accept(&buffer, false, 309 1, USB_MAX_PAYLOAD_SIZE, 310 0, &len); 311 312 if (rc != EOK) { 313 async_answer_0(callid, rc); 314 return; 315 } 293 294 int rc = async_data_write_accept(&buffer, false, 295 1, USB_MAX_PAYLOAD_SIZE, 296 0, &len); 297 298 if (rc != EOK) { 299 async_answer_0(callid, rc); 300 return; 316 301 } 317 302 … … 328 313 trans->size = len; 329 314 330 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE,315 rc = transfer_func(device, target, max_packet_size, 331 316 buffer, len, 332 317 callback_out, trans); … … 354 339 } 355 340 356 size_t len= DEV_IPC_GET_ARG3(*call);341 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 357 342 usb_target_t target = { 358 343 .address = DEV_IPC_GET_ARG1(*call), … … 360 345 }; 361 346 347 size_t len; 362 348 ipc_callid_t data_callid; 363 349 if (!async_data_read_receive(&data_callid, &len)) { … … 375 361 trans->size = len; 376 362 377 int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN,363 int rc = transfer_func(device, target, max_packet_size, 378 364 trans->buffer, len, 379 365 callback_in, trans); … … 385 371 } 386 372 387 /** Process status part of control transfer.388 *389 * @param device Target device.390 * @param callid Initiating caller.391 * @param call Initiating call.392 * @param direction Transfer direction (read ~ in, write ~ out).393 * @param transfer_in_func Transfer function for control read (might be NULL).394 * @param transfer_out_func Transfer function for control write (might be NULL).395 */396 static void remote_usbhc_status_transfer(device_t *device,397 ipc_callid_t callid, ipc_call_t *call,398 usb_direction_t direction,399 int (*transfer_in_func)(device_t *, usb_target_t,400 usbhc_iface_transfer_in_callback_t, void *),401 int (*transfer_out_func)(device_t *, usb_target_t,402 usbhc_iface_transfer_out_callback_t, void *))403 {404 switch (direction) {405 case USB_DIRECTION_IN:406 if (!transfer_in_func) {407 async_answer_0(callid, ENOTSUP);408 return;409 }410 break;411 case USB_DIRECTION_OUT:412 if (!transfer_out_func) {413 async_answer_0(callid, ENOTSUP);414 return;415 }416 break;417 default:418 assert(false && "unreachable code");419 break;420 }421 422 usb_target_t target = {423 .address = DEV_IPC_GET_ARG1(*call),424 .endpoint = DEV_IPC_GET_ARG2(*call)425 };426 427 async_transaction_t *trans = async_transaction_create(callid);428 if (trans == NULL) {429 async_answer_0(callid, ENOMEM);430 return;431 }432 433 int rc;434 switch (direction) {435 case USB_DIRECTION_IN:436 rc = transfer_in_func(device, target,437 callback_in, trans);438 break;439 case USB_DIRECTION_OUT:440 rc = transfer_out_func(device, target,441 callback_out, trans);442 break;443 default:444 assert(false && "unreachable code");445 break;446 }447 448 if (rc != EOK) {449 async_answer_0(callid, rc);450 async_transaction_destroy(trans);451 }452 }453 454 455 373 void remote_usbhc_interrupt_out(device_t *device, void *iface, 456 374 ipc_callid_t callid, ipc_call_t *call) … … 471 389 return remote_usbhc_in_transfer(device, callid, call, 472 390 usb_iface->interrupt_in); 473 }474 475 void remote_usbhc_control_write_setup(device_t *device, void *iface,476 ipc_callid_t callid, ipc_call_t *call)477 {478 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;479 assert(usb_iface != NULL);480 481 return remote_usbhc_out_transfer(device, callid, call,482 usb_iface->control_write_setup);483 }484 485 void remote_usbhc_control_write_data(device_t *device, void *iface,486 ipc_callid_t callid, ipc_call_t *call)487 {488 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;489 assert(usb_iface != NULL);490 491 return remote_usbhc_out_transfer(device, callid, call,492 usb_iface->control_write_data);493 }494 495 void remote_usbhc_control_write_status(device_t *device, void *iface,496 ipc_callid_t callid, ipc_call_t *call)497 {498 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;499 assert(usb_iface != NULL);500 501 return remote_usbhc_status_transfer(device, callid, call,502 USB_DIRECTION_IN, usb_iface->control_write_status, NULL);503 }504 505 void remote_usbhc_control_read_setup(device_t *device, void *iface,506 ipc_callid_t callid, ipc_call_t *call)507 {508 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;509 assert(usb_iface != NULL);510 511 return remote_usbhc_out_transfer(device, callid, call,512 usb_iface->control_read_setup);513 }514 515 void remote_usbhc_control_read_data(device_t *device, void *iface,516 ipc_callid_t callid, ipc_call_t *call)517 {518 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;519 assert(usb_iface != NULL);520 521 return remote_usbhc_in_transfer(device, callid, call,522 usb_iface->control_read_data);523 }524 525 void remote_usbhc_control_read_status(device_t *device, void *iface,526 ipc_callid_t callid, ipc_call_t *call)527 {528 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;529 assert(usb_iface != NULL);530 531 return remote_usbhc_status_transfer(device, callid, call,532 USB_DIRECTION_OUT, NULL, usb_iface->control_read_status);533 391 } 534 392 … … 549 407 }; 550 408 size_t data_buffer_len = DEV_IPC_GET_ARG3(*call); 409 size_t max_packet_size = DEV_IPC_GET_ARG4(*call); 551 410 552 411 int rc; … … 584 443 trans->size = data_buffer_len; 585 444 586 rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE,445 rc = usb_iface->control_write(device, target, max_packet_size, 587 446 setup_packet, setup_packet_len, 588 447 data_buffer, data_buffer_len, … … 611 470 .endpoint = DEV_IPC_GET_ARG2(*call) 612 471 }; 472 size_t max_packet_size = DEV_IPC_GET_ARG3(*call); 613 473 614 474 int rc; … … 648 508 } 649 509 650 rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE,510 rc = usb_iface->control_read(device, target, max_packet_size, 651 511 setup_packet, setup_packet_len, 652 512 trans->buffer, trans->size, -
uspace/lib/drv/include/usbhc_iface.h
rb6c7da6 r374552ef 53 53 * - argument #1 is target address 54 54 * - argument #2 is target endpoint 55 * - argument #3 is buffer size55 * - argument #3 is max packet size of the endpoint 56 56 * - this call is immediately followed by IPC data write (from caller) 57 57 * - the initial call (and the whole transaction) is answer after the … … 66 66 * - argument #1 is target address 67 67 * - argument #2 is target endpoint 68 * - argument #3 is buffer size68 * - argument #3 is max packet size of the endpoint 69 69 * - this call is immediately followed by IPC data read (async version) 70 70 * - the call is not answered until the device returns some data (or until … … 153 153 IPC_M_USBHC_INTERRUPT_IN, 154 154 155 156 /** Start WRITE control transfer.157 * See explanation at usb_iface_funcs_t (OUT transaction).158 */159 IPC_M_USBHC_CONTROL_WRITE_SETUP,160 161 /** Send control-transfer data to device.162 * See explanation at usb_iface_funcs_t (OUT transaction).163 */164 IPC_M_USBHC_CONTROL_WRITE_DATA,165 166 /** Terminate WRITE control transfer.167 * See explanation at usb_iface_funcs_t (NO-DATA transaction).168 */169 IPC_M_USBHC_CONTROL_WRITE_STATUS,170 171 172 173 /** Start READ control transfer.174 * See explanation at usb_iface_funcs_t (OUT transaction).175 */176 IPC_M_USBHC_CONTROL_READ_SETUP,177 178 /** Get control-transfer data from device.179 * See explanation at usb_iface_funcs_t (IN transaction).180 */181 IPC_M_USBHC_CONTROL_READ_DATA,182 183 /** Terminate READ control transfer.184 * See explanation at usb_iface_funcs_t (NO-DATA transaction).185 */186 IPC_M_USBHC_CONTROL_READ_STATUS,187 188 155 /** Issue control WRITE transfer. 189 156 * See explanation at usb_iface_funcs_t (OUT transaction) for … … 194 161 IPC_M_USBHC_CONTROL_WRITE, 195 162 196 /** Issue control WRITEtransfer.163 /** Issue control READ transfer. 197 164 * See explanation at usb_iface_funcs_t (IN transaction) for 198 165 * call parameters. 199 * This call is immediately followed by IPC data read from the caller 200 * (setup packet). 201 * Actual data are retrieved through IPC_M_USBHC_GET_BUFFER. 166 * This call is immediately followed by IPC data write from the caller 167 * (setup packet) and IPC data read (buffer that was read). 202 168 */ 203 169 IPC_M_USBHC_CONTROL_READ, … … 241 207 usbhc_iface_transfer_in_t interrupt_in; 242 208 243 usbhc_iface_transfer_setup_t control_write_setup;244 usbhc_iface_transfer_out_t control_write_data;245 int (*control_write_status)(device_t *, usb_target_t,246 usbhc_iface_transfer_in_callback_t, void *);247 248 usbhc_iface_transfer_setup_t control_read_setup;249 usbhc_iface_transfer_in_t control_read_data;250 int (*control_read_status)(device_t *, usb_target_t,251 usbhc_iface_transfer_out_callback_t, void *);252 253 209 int (*control_write)(device_t *, usb_target_t, 254 210 size_t,
Note:
See TracChangeset
for help on using the changeset viewer.