Changeset 1537ba6 in mainline for uspace/lib
- Timestamp:
- 2011-02-02T10:19:13Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93f8da1
- Parents:
- 0b31409 (diff), b00849e (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
- Files:
-
- 4 added
- 8 edited
-
drv/generic/remote_usbhc.c (modified) (8 diffs)
-
drv/include/usbhc_iface.h (modified) (2 diffs)
-
usb/Makefile (modified) (1 diff)
-
usb/include/usb/classes/hid.h (modified) (2 diffs)
-
usb/include/usb/debug.h (modified) (1 diff)
-
usb/include/usb/pipes.h (added)
-
usb/include/usb/request.h (added)
-
usb/include/usb/usb.h (modified) (2 diffs)
-
usb/include/usb/usbdrv.h (modified) (3 diffs)
-
usb/src/pipes.c (added)
-
usb/src/request.c (added)
-
usb/src/usbdrv.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r0b31409 r1537ba6 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010-2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 52 52 static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *); 53 53 static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *); 54 56 static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 55 57 static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 81 83 remote_usbhc_control_read_setup, 82 84 remote_usbhc_control_read_data, 83 remote_usbhc_control_read_status 85 remote_usbhc_control_read_status, 86 87 remote_usbhc_control_write, 88 remote_usbhc_control_read 84 89 }; 85 90 … … 95 100 ipc_callid_t caller; 96 101 void *buffer; 102 void *setup_packet; 97 103 size_t size; 98 104 } async_transaction_t; … … 297 303 trans->caller = callid; 298 304 trans->buffer = buffer; 305 trans->setup_packet = NULL; 299 306 trans->size = len; 300 307 … … 336 343 trans->caller = callid; 337 344 trans->buffer = malloc(len); 345 trans->setup_packet = NULL; 338 346 trans->size = len; 339 347 … … 391 399 trans->caller = callid; 392 400 trans->buffer = NULL; 401 trans->setup_packet = NULL; 393 402 trans->size = 0; 394 403 … … 496 505 } 497 506 507 void remote_usbhc_control_write(device_t *device, void *iface, 508 ipc_callid_t callid, ipc_call_t *call) 509 { 510 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 511 assert(usb_iface != NULL); 512 513 if (!usb_iface->control_write) { 514 ipc_answer_0(callid, ENOTSUP); 515 return; 516 } 517 518 usb_target_t target = { 519 .address = DEV_IPC_GET_ARG1(*call), 520 .endpoint = DEV_IPC_GET_ARG2(*call) 521 }; 522 523 int rc; 524 525 void *setup_packet = NULL; 526 void *data_buffer = NULL; 527 size_t setup_packet_len = 0; 528 size_t data_buffer_len = 0; 529 530 rc = async_data_write_accept(&setup_packet, false, 531 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 532 if (rc != EOK) { 533 ipc_answer_0(callid, rc); 534 return; 535 } 536 rc = async_data_write_accept(&data_buffer, false, 537 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 538 if (rc != EOK) { 539 free(setup_packet); 540 ipc_answer_0(callid, rc); 541 return; 542 } 543 544 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 545 trans->caller = callid; 546 trans->setup_packet = setup_packet; 547 trans->buffer = data_buffer; 548 trans->size = data_buffer_len; 549 550 rc = usb_iface->control_write(device, target, 551 setup_packet, setup_packet_len, 552 data_buffer, data_buffer_len, 553 callback_out, trans); 554 555 if (rc != EOK) { 556 ipc_answer_0(callid, rc); 557 free(setup_packet); 558 free(data_buffer); 559 free(trans); 560 } 561 } 562 563 564 void remote_usbhc_control_read(device_t *device, void *iface, 565 ipc_callid_t callid, ipc_call_t *call) 566 { 567 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 568 assert(usb_iface != NULL); 569 570 if (!usb_iface->control_read) { 571 ipc_answer_0(callid, ENOTSUP); 572 return; 573 } 574 575 size_t data_len = DEV_IPC_GET_ARG3(*call); 576 usb_target_t target = { 577 .address = DEV_IPC_GET_ARG1(*call), 578 .endpoint = DEV_IPC_GET_ARG2(*call) 579 }; 580 581 int rc; 582 583 void *setup_packet = NULL; 584 size_t setup_packet_len = 0; 585 586 rc = async_data_write_accept(&setup_packet, false, 587 1, USB_MAX_PAYLOAD_SIZE, 0, &setup_packet_len); 588 if (rc != EOK) { 589 ipc_answer_0(callid, rc); 590 return; 591 } 592 593 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 594 trans->caller = callid; 595 trans->setup_packet = setup_packet; 596 trans->buffer = malloc(data_len); 597 trans->size = data_len; 598 599 rc = usb_iface->control_read(device, target, 600 setup_packet, setup_packet_len, 601 trans->buffer, trans->size, 602 callback_in, trans); 603 604 if (rc != EOK) { 605 ipc_answer_0(callid, rc); 606 free(setup_packet); 607 free(trans->buffer); 608 free(trans); 609 } 610 } 611 498 612 499 613 -
uspace/lib/drv/include/usbhc_iface.h
r0b31409 r1537ba6 201 201 IPC_M_USBHC_CONTROL_READ_STATUS, 202 202 203 /** Issue control WRITE transfer. 204 * See explanation at usb_iface_funcs_t (OUT transaction) for 205 * call parameters. 206 * This call is immediately followed by two IPC data writes 207 * from the caller (setup packet and actual data). 208 */ 209 IPC_M_USBHC_CONTROL_WRITE, 210 211 /** Issue control WRITE transfer. 212 * See explanation at usb_iface_funcs_t (IN transaction) for 213 * call parameters. 214 * This call is immediately followed by IPC data read from the caller 215 * (setup packet). 216 * Actual data are retrieved through IPC_M_USBHC_GET_BUFFER. 217 */ 218 IPC_M_USBHC_CONTROL_READ, 203 219 204 220 /* IPC_M_USB_ */ … … 249 265 int (*control_read_status)(device_t *, usb_target_t, 250 266 usbhc_iface_transfer_out_callback_t, void *); 267 268 int (*control_write)(device_t *, usb_target_t, 269 void *, size_t, void *, size_t, 270 usbhc_iface_transfer_out_callback_t, void *); 271 272 int (*control_read)(device_t *, usb_target_t, 273 void *, size_t, void *, size_t, 274 usbhc_iface_transfer_in_callback_t, void *); 251 275 } usbhc_iface_t; 252 276 -
uspace/lib/usb/Makefile
r0b31409 r1537ba6 43 43 src/hidparser.c \ 44 44 src/localdrv.c \ 45 src/pipes.c \ 45 46 src/recognise.c \ 46 47 src/remotedrv.c \ 48 src/request.c \ 47 49 src/usb.c \ 48 50 src/usbdrvreq.c \ -
uspace/lib/usb/include/usb/classes/hid.h
r0b31409 r1537ba6 37 37 38 38 #include <usb/usb.h> 39 #include <driver.h>40 39 #include <usb/classes/hidparser.h> 41 40 #include <usb/descriptor.h> … … 101 100 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 102 101 103 /**104 *105 */106 typedef struct {107 usb_standard_interface_descriptor_t iface_desc;108 usb_standard_endpoint_descriptor_t *endpoints;109 usb_standard_hid_descriptor_t hid_desc;110 uint8_t *report_desc;111 //usb_standard_hid_class_descriptor_info_t *class_desc_info;112 //uint8_t **class_descs;113 } usb_hid_iface_t;114 115 /**116 *117 */118 typedef struct {119 usb_standard_configuration_descriptor_t config_descriptor;120 usb_hid_iface_t *interfaces;121 } usb_hid_configuration_t;122 123 /**124 * @brief USB/HID keyboard device type.125 *126 * Quite dummy right now.127 */128 typedef struct {129 device_t *device;130 usb_hid_configuration_t *conf;131 usb_address_t address;132 usb_endpoint_t poll_endpoint;133 usb_hid_report_parser_t *parser;134 } usb_hid_dev_kbd_t;135 136 // TODO: more configurations!137 102 138 103 #endif -
uspace/lib/usb/include/usb/debug.h
r0b31409 r1537ba6 47 47 /** Logging level. */ 48 48 typedef enum { 49 USB_LOG_LEVEL_FATAL, 50 USB_LOG_LEVEL_ERROR, 51 USB_LOG_LEVEL_WARNING, 52 USB_LOG_LEVEL_INFO, 53 USB_LOG_LEVEL_DEBUG, 54 USB_LOG_LEVEL_DEBUG2 49 USB_LOG_LEVEL_FATAL, 50 USB_LOG_LEVEL_ERROR, 51 USB_LOG_LEVEL_WARNING, 52 USB_LOG_LEVEL_INFO, 53 USB_LOG_LEVEL_DEBUG, 54 USB_LOG_LEVEL_DEBUG2, 55 USB_LOG_LEVEL_MAX 55 56 } usb_log_level_t; 56 57 -
uspace/lib/usb/include/usb/usb.h
r0b31409 r1537ba6 37 37 38 38 #include <sys/types.h> 39 #include <byteorder.h> 39 40 #include <ipc/ipc.h> 41 42 /** Convert 16bit value from native (host) endianness to USB endianness. */ 43 #define uint16_host2usb(n) host2uint16_t_le((n)) 44 45 /** Convert 32bit value from native (host) endianness to USB endianness. */ 46 #define uint32_host2usb(n) host2uint32_t_le((n)) 47 48 /** Convert 16bit value from USB endianness into native (host) one. */ 49 #define uint16_usb2host(n) uint16_t_le2host((n)) 50 51 /** Convert 32bit value from USB endianness into native (host) one. */ 52 #define uint32_usb2host(n) uint32_t_le2host((n)) 53 40 54 41 55 /** USB transfer type. */ … … 52 66 typedef enum { 53 67 USB_DIRECTION_IN, 54 USB_DIRECTION_OUT 68 USB_DIRECTION_OUT, 69 USB_DIRECTION_BOTH 55 70 } usb_direction_t; 56 71 -
uspace/lib/usb/include/usb/usbdrv.h
r0b31409 r1537ba6 70 70 usb_handle_t *); 71 71 72 int usb_drv_async_control_write(int, usb_target_t, 73 void *, size_t, void *, size_t, usb_handle_t *); 74 72 75 int usb_drv_psync_control_write_setup(int, usb_target_t, void *, size_t); 73 76 int usb_drv_psync_control_write_data(int, usb_target_t, void *, size_t); … … 77 80 void *, size_t, void *, size_t); 78 81 79 80 82 int usb_drv_async_control_read_setup(int, usb_target_t, 81 83 void *, size_t, usb_handle_t *); … … 84 86 int usb_drv_async_control_read_status(int, usb_target_t, 85 87 usb_handle_t *); 88 89 int usb_drv_async_control_read(int, usb_target_t, 90 void *, size_t, void *, size_t, size_t *, usb_handle_t *); 86 91 87 92 int usb_drv_psync_control_read_setup(int, usb_target_t, void *, size_t); -
uspace/lib/usb/src/usbdrv.c
r0b31409 r1537ba6 495 495 } 496 496 497 /** Issue whole control write transfer. */ 498 int usb_drv_async_control_write(int phone, usb_target_t target, 499 void *setup_packet, size_t setup_packet_size, 500 void *buffer, size_t buffer_size, 501 usb_handle_t *handle) 502 { 503 // FIXME - check input parameters instead of asserting them 504 assert(phone > 0); 505 assert(setup_packet != NULL); 506 assert(setup_packet_size > 0); 507 assert(buffer != NULL); 508 assert(buffer_size > 0); 509 assert(handle != NULL); 510 511 transfer_info_t *transfer 512 = (transfer_info_t *) malloc(sizeof(transfer_info_t)); 513 if (transfer == NULL) { 514 return ENOMEM; 515 } 516 517 transfer->size_transferred = NULL; 518 transfer->buffer = NULL; 519 transfer->size = 0; 520 transfer->phone = phone; 521 522 int rc; 523 524 transfer->request = async_send_3(phone, 525 DEV_IFACE_ID(USBHC_DEV_IFACE), 526 IPC_M_USBHC_CONTROL_WRITE, 527 target.address, target.endpoint, 528 &transfer->reply); 529 530 rc = async_data_write_start(phone, setup_packet, setup_packet_size); 531 if (rc != EOK) { 532 async_wait_for(transfer->request, NULL); 533 return rc; 534 } 535 536 rc = async_data_write_start(phone, buffer, buffer_size); 537 if (rc != EOK) { 538 async_wait_for(transfer->request, NULL); 539 return rc; 540 } 541 542 *handle = (usb_handle_t) transfer; 543 544 return EOK; 545 } 546 497 547 /** Start control read transfer. */ 498 548 int usb_drv_async_control_read_setup(int phone, usb_target_t target, … … 530 580 } 531 581 582 /** Issue whole control read transfer. */ 583 int usb_drv_async_control_read(int phone, usb_target_t target, 584 void *setup_packet, size_t setup_packet_size, 585 void *buffer, size_t buffer_size, size_t *actual_size, 586 usb_handle_t *handle) 587 { 588 // FIXME - check input parameters instead of asserting them 589 assert(phone > 0); 590 assert(setup_packet != NULL); 591 assert(setup_packet_size > 0); 592 assert(buffer != NULL); 593 assert(buffer_size > 0); 594 assert(handle != NULL); 595 596 transfer_info_t *transfer 597 = (transfer_info_t *) malloc(sizeof(transfer_info_t)); 598 if (transfer == NULL) { 599 return ENOMEM; 600 } 601 602 transfer->size_transferred = actual_size; 603 transfer->buffer = buffer; 604 transfer->size = buffer_size; 605 transfer->phone = phone; 606 607 int rc; 608 609 transfer->request = async_send_4(phone, 610 DEV_IFACE_ID(USBHC_DEV_IFACE), 611 IPC_M_USBHC_CONTROL_READ, 612 target.address, target.endpoint, 613 buffer_size, 614 &transfer->reply); 615 616 rc = async_data_write_start(phone, setup_packet, setup_packet_size); 617 if (rc != EOK) { 618 async_wait_for(transfer->request, NULL); 619 return rc; 620 } 621 622 *handle = (usb_handle_t) transfer; 623 624 return EOK; 625 } 626 532 627 /** 533 628 * @}
Note:
See TracChangeset
for help on using the changeset viewer.
