Changeset 79ae36dd in mainline for uspace/drv/vhc
- Timestamp:
- 2011-06-08T19:01:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/drv/vhc
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/conndev.c
r764d71e r79ae36dd 38 38 #include <ddf/driver.h> 39 39 #include <usbvirt/ipc.h> 40 #include <async.h> 40 41 #include "conn.h" 41 42 … … 44 45 static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>"; 45 46 47 #if 0 46 48 /** Receive device name. 47 49 * 48 50 * @warning Errors are silently ignored. 49 51 * 50 * @param phone Phone to the virtual device. 52 * @param sess Session to the virtual device. 53 * 51 54 */ 52 static void receive_device_name( int phone)55 static void receive_device_name(async_sess_t *sess) 53 56 { 54 aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL); 57 async_exch_t *exch = async_exchange_begin(sess); 58 59 aid_t opening_request = async_send_0(exch, IPC_M_USBVIRT_GET_NAME, NULL); 55 60 if (opening_request == 0) { 61 async_exchange_end(exch); 56 62 return; 57 63 } 58 59 64 60 65 ipc_call_t data_request_call; 61 aid_t data_request = async_data_read(phone, 62 plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN, 63 &data_request_call); 64 66 aid_t data_request = async_data_read(exch, plugged_device_name, 67 PLUGGED_DEVICE_NAME_MAXLEN, &data_request_call); 68 69 async_exchange_end(exch); 70 65 71 if (data_request == 0) { 66 72 async_wait_for(opening_request, NULL); 67 73 return; 68 74 } 69 75 70 76 sysarg_t data_request_rc; 71 77 sysarg_t opening_request_rc; 72 78 async_wait_for(data_request, &data_request_rc); 73 79 async_wait_for(opening_request, &opening_request_rc); 74 75 if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {80 81 if ((data_request_rc != EOK) || (opening_request_rc != EOK)) 76 82 return; 77 } 78 83 79 84 size_t len = IPC_GET_ARG2(data_request_call); 80 85 plugged_device_name[len] = 0; 81 86 } 87 #endif 82 88 83 89 /** Default handler for IPC methods not handled by DDF. … … 90 96 ipc_callid_t icallid, ipc_call_t *icall) 91 97 { 98 // FIXME: 99 // This code needs to be refactored since the async 100 // framework does not support automatic callback connections 101 // yet. 102 103 #if 0 92 104 vhc_data_t *vhc = fun->dev->driver_data; 93 105 sysarg_t method = IPC_GET_IMETHOD(*icall); … … 112 124 return; 113 125 } 126 #endif 114 127 115 128 async_answer_0(icallid, EINVAL); -
uspace/drv/vhc/devconn.c
r764d71e r79ae36dd 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 1 29 #include <errno.h> 2 30 #include "vhcd.h" … … 11 39 } 12 40 dev->address = 0; 13 dev->dev_ phone = -1;41 dev->dev_sess = NULL; 14 42 dev->dev_local = NULL; 15 43 dev->plugged = true; … … 22 50 23 51 static int vhc_virtdev_plug_generic(vhc_data_t *vhc, 24 int phone, usbvirt_device_t *virtdev,52 async_sess_t *sess, usbvirt_device_t *virtdev, 25 53 uintptr_t *handle, bool connect) 26 54 { … … 30 58 } 31 59 32 dev->dev_ phone = phone;60 dev->dev_sess = sess; 33 61 dev->dev_local = virtdev; 34 62 … … 56 84 } 57 85 58 int vhc_virtdev_plug(vhc_data_t *vhc, int phone, uintptr_t *handle)86 int vhc_virtdev_plug(vhc_data_t *vhc, async_sess_t *sess, uintptr_t *handle) 59 87 { 60 return vhc_virtdev_plug_generic(vhc, phone, NULL, handle, true);88 return vhc_virtdev_plug_generic(vhc, sess, NULL, handle, true); 61 89 } 62 90 63 91 int vhc_virtdev_plug_local(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle) 64 92 { 65 return vhc_virtdev_plug_generic(vhc, -1, dev, handle, true);93 return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, true); 66 94 } 67 95 68 96 int vhc_virtdev_plug_hub(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle) 69 97 { 70 return vhc_virtdev_plug_generic(vhc, -1, dev, handle, false);98 return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, false); 71 99 } 72 100 -
uspace/drv/vhc/hub.c
r764d71e r79ae36dd 33 33 * @brief Virtual USB hub. 34 34 */ 35 35 36 #include <usb/classes/classes.h> 36 37 #include <usbvirt/device.h> 37 38 #include <errno.h> 39 #include <async.h> 38 40 #include <str_error.h> 39 41 #include <stdlib.h> … … 44 46 45 47 #include "hub.h" 46 //#include "hub/virthub.h"47 48 #include "vhcd.h" 48 49 #include "conn.h" … … 97 98 * Wait until parent device is properly initialized. 98 99 */ 99 int phone;100 async_sess_t *sess; 100 101 do { 101 phone = devman_device_connect(hc_dev->handle, 0);102 } while ( phone < 0);103 async_hangup( phone);102 sess = devman_device_connect(EXCHANGE_SERIALIZE, hc_dev->handle, 0); 103 } while (!sess); 104 async_hangup(sess); 104 105 105 106 int rc; … … 129 130 return 0; 130 131 } 131 132 132 133 133 /** -
uspace/drv/vhc/hub.h
r764d71e r79ae36dd 33 33 * @brief Virtual USB hub. 34 34 */ 35 35 36 #ifndef VHCD_HUB_H_ 36 37 #define VHCD_HUB_H_ -
uspace/drv/vhc/main.c
r764d71e r79ae36dd 29 29 /** @addtogroup drvusbvhc 30 30 * @{ 31 */ 31 */ 32 32 /** @file 33 33 * Virtual host controller. -
uspace/drv/vhc/transfer.c
r764d71e r79ae36dd 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 1 29 #include <errno.h> 2 30 #include <str_error.h> … … 123 151 124 152 static int process_transfer_remote(vhc_transfer_t *transfer, 125 int phone, size_t *actual_data_size)153 async_sess_t *sess, size_t *actual_data_size) 126 154 { 127 155 int rc; … … 129 157 if (transfer->transfer_type == USB_TRANSFER_CONTROL) { 130 158 if (transfer->direction == USB_DIRECTION_IN) { 131 rc = usbvirt_ipc_send_control_read( phone,132 transfer->setup_buffer, transfer->setup_buffer_size, 133 transfer->data_buffer, transfer->data_buffer_size, 134 actual_data_size); 135 } else { 136 assert(transfer->direction == USB_DIRECTION_OUT); 137 rc = usbvirt_ipc_send_control_write( phone,138 transfer->setup_buffer, transfer->setup_buffer_size, 139 transfer->data_buffer, transfer->data_buffer_size); 140 } 141 } else { 142 if (transfer->direction == USB_DIRECTION_IN) { 143 rc = usbvirt_ipc_send_data_in( phone, transfer->endpoint,159 rc = usbvirt_ipc_send_control_read(sess, 160 transfer->setup_buffer, transfer->setup_buffer_size, 161 transfer->data_buffer, transfer->data_buffer_size, 162 actual_data_size); 163 } else { 164 assert(transfer->direction == USB_DIRECTION_OUT); 165 rc = usbvirt_ipc_send_control_write(sess, 166 transfer->setup_buffer, transfer->setup_buffer_size, 167 transfer->data_buffer, transfer->data_buffer_size); 168 } 169 } else { 170 if (transfer->direction == USB_DIRECTION_IN) { 171 rc = usbvirt_ipc_send_data_in(sess, transfer->endpoint, 144 172 transfer->transfer_type, 145 173 transfer->data_buffer, transfer->data_buffer_size, … … 147 175 } else { 148 176 assert(transfer->direction == USB_DIRECTION_OUT); 149 rc = usbvirt_ipc_send_data_out( phone, transfer->endpoint,177 rc = usbvirt_ipc_send_data_out(sess, transfer->endpoint, 150 178 transfer->transfer_type, 151 179 transfer->data_buffer, transfer->data_buffer_size); … … 206 234 int rc = EOK; 207 235 size_t data_transfer_size = 0; 208 if (dev->dev_ phone > 0) {209 rc = process_transfer_remote(transfer, dev->dev_ phone,236 if (dev->dev_sess) { 237 rc = process_transfer_remote(transfer, dev->dev_sess, 210 238 &data_transfer_size); 211 239 } else if (dev->dev_local != NULL) { -
uspace/drv/vhc/vhcd.h
r764d71e r79ae36dd 41 41 #include <usb/host/device_keeper.h> 42 42 #include <usbhc_iface.h> 43 #include <async.h> 43 44 44 45 #define NAME "vhc" … … 46 47 typedef struct { 47 48 link_t link; 48 int dev_phone;49 async_sess_t *dev_sess; 49 50 usbvirt_device_t *dev_local; 50 51 bool plugged; … … 82 83 vhc_transfer_t *vhc_transfer_create(usb_address_t, usb_endpoint_t, 83 84 usb_direction_t, usb_transfer_type_t, ddf_fun_t *, void *); 84 int vhc_virtdev_plug(vhc_data_t *, int, uintptr_t *);85 int vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *); 85 86 int vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *); 86 87 int vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
Note:
See TracChangeset
for help on using the changeset viewer.
