Changeset e27595b in mainline
- Timestamp:
- 2010-11-20T13:04:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0e126be7
- Parents:
- 7034be15
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/virtusbkbd.c
r7034be15 re27595b 58 58 #define NAME "virt-usb-kbd" 59 59 60 #define DEV_HCD_NAME "hcd-virt-dev"61 60 62 61 #define __QUOTEME(x) #x … … 216 215 217 216 218 int rc = usbvirt_connect(&keyboard_dev , DEV_HCD_NAME);217 int rc = usbvirt_connect(&keyboard_dev); 219 218 if (rc != EOK) { 220 printf("%s: Unable to start com unication with VHCD at usb://%s(%s).\n",221 NAME, DEV_HCD_NAME,str_error(rc));219 printf("%s: Unable to start communication with VHCD (%s).\n", 220 NAME, str_error(rc)); 222 221 return rc; 223 222 } -
uspace/drv/vhc/conn.h
r7034be15 re27595b 42 42 43 43 void connection_handler_host(ipcarg_t); 44 void connection_handler_device(ipcarg_t, virtdev_connection_t *); 44 45 45 usb_hcd_transfer_ops_t vhc_transfer_ops; 46 47 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); 48 46 49 47 50 #endif -
uspace/drv/vhc/conndev.c
r7034be15 re27595b 74 74 } 75 75 76 /** Connection handler for communcation with virtual device.76 /** Default handler for IPC methods not handled by DDF. 77 77 * 78 * This function also takes care of proper phone hung-up. 79 * 80 * @param phone_hash Incoming phone hash. 81 * @param dev Virtual device handle. 78 * @param dev Device handling the call. 79 * @param icallid Call id. 80 * @param icall Call data. 82 81 */ 83 void connection_handler_device(ipcarg_t phone_hash, virtdev_connection_t *dev) 82 void default_connection_handler(device_t *dev, 83 ipc_callid_t icallid, ipc_call_t *icall) 84 84 { 85 assert(dev != NULL); 86 87 char devname[DEVICE_NAME_MAXLENGTH + 1]; 88 int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH); 89 90 dprintf(0, "virtual device connected (phone: %#x, name: %s)", 91 phone_hash, rc == EOK ? devname : "<unknown>"); 92 93 94 while (true) { 95 ipc_callid_t callid; 96 ipc_call_t call; 97 98 callid = async_get_call(&call); 99 100 switch (IPC_GET_METHOD(call)) { 101 case IPC_M_PHONE_HUNGUP: 102 ipc_hangup(dev->phone); 103 ipc_answer_0(callid, EOK); 104 dprintf(0, "phone%#x: device hung-up", 105 phone_hash); 106 return; 107 108 case IPC_M_CONNECT_TO_ME: 109 ipc_answer_0(callid, ELIMIT); 110 break; 111 112 default: 113 dprintf_inval_call(2, call, phone_hash); 114 ipc_answer_0(callid, EINVAL); 115 break; 85 ipcarg_t method = IPC_GET_METHOD(*icall); 86 87 if (method == IPC_M_CONNECT_TO_ME) { 88 int callback = IPC_GET_ARG5(*icall); 89 virtdev_connection_t *dev 90 = virtdev_add_device(callback); 91 if (!dev) { 92 ipc_answer_0(icallid, EEXISTS); 93 ipc_hangup(callback); 94 return; 116 95 } 96 ipc_answer_0(icallid, EOK); 97 98 char devname[DEVICE_NAME_MAXLENGTH + 1]; 99 int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH); 100 101 dprintf(0, "virtual device connected (name: %s)", 102 rc == EOK ? devname : "<unknown>"); 103 104 /* FIXME: destroy the device when the client disconnects. */ 105 106 return; 117 107 } 108 109 ipc_answer_0(icallid, EINVAL); 118 110 } 111 119 112 120 113 /** -
uspace/drv/vhc/devices.h
r7034be15 re27595b 50 50 51 51 virtdev_connection_t *virtdev_add_device(int); 52 virtdev_connection_t *virtdev_get_mine(void); 52 53 void virtdev_destroy_device(virtdev_connection_t *); 53 54 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *); -
uspace/drv/vhc/hcd.c
r7034be15 re27595b 52 52 #include "conn.h" 53 53 54 54 55 static int vhc_count = 0; 55 56 static int vhc_add_device(usb_hc_device_t *dev) 56 57 { 57 printf("%s: new device registered.\n", NAME);58 58 /* 59 59 * Currently, we know how to simulate only single HC. … … 66 66 67 67 dev->transfer_ops = &vhc_transfer_ops; 68 dev->generic->ops->default_handler = default_connection_handler; 68 69 69 70 /* … … 71 72 */ 72 73 usb_hcd_add_root_hub(dev); 74 75 printf("%s: virtual USB host controller ready.\n", NAME); 73 76 74 77 return EOK; … … 84 87 printf("%s: virtual USB host controller driver.\n", NAME); 85 88 89 debug_level = 5; 90 86 91 return usb_hcd_main(&vhc_driver); 87 92 } -
uspace/lib/usb/hcdhubd.c
r7034be15 re27595b 76 76 77 77 hc_dev->generic = dev; 78 dev->ops = &usb_device_ops; 79 hc_dev->generic->driver_data = hc_dev; 80 78 81 int rc = hc_driver->add_hc(hc_dev); 79 82 if (rc != EOK) { … … 81 84 return rc; 82 85 } 83 84 /*85 * Finish initialization of dev and hc_dev structures.86 */87 hc_dev->generic->driver_data = hc_dev;88 dev->ops = &usb_device_ops;89 86 90 87 /* -
uspace/lib/usbvirt/hub.h
r7034be15 re27595b 59 59 } usbvirt_device_method_t; 60 60 61 int usbvirt_connect(usbvirt_device_t * , const char *);61 int usbvirt_connect(usbvirt_device_t *); 62 62 int usbvirt_connect_local(usbvirt_device_t *); 63 63 int usbvirt_disconnect(usbvirt_device_t *dev); -
uspace/lib/usbvirt/main.c
r7034be15 re27595b 33 33 * @brief Device registration with virtual USB framework. 34 34 */ 35 #include <devmap.h> 36 #include <fcntl.h> 37 #include <vfs/vfs.h> 35 #include <devman.h> 38 36 #include <errno.h> 39 37 #include <stdlib.h> … … 181 179 return; 182 180 } 183 181 184 182 device_callback_connection(dev->device, iid, icall); 185 183 } … … 187 185 /** Create necessary phones for comunication with virtual HCD. 188 186 * This function wraps following calls: 189 * -# open <code>/dev/ usb/<i>hcd_path</i></code>for reading187 * -# open <code>/dev/devices/\\vhc for reading 190 188 * -# access phone of file opened in previous step 191 189 * -# create callback through just opened phone … … 202 200 * @return EOK on success or error code from errno.h. 203 201 */ 204 int usbvirt_connect(usbvirt_device_t *dev , const char *hcd_path)202 int usbvirt_connect(usbvirt_device_t *dev) 205 203 { 206 204 virtual_device_t *virtual_device = find_device(dev); … … 209 207 } 210 208 211 char dev_path[DEVMAP_NAME_MAXLEN + 1]; 212 snprintf(dev_path, DEVMAP_NAME_MAXLEN, 213 "/dev/%s/%s", NAMESPACE, hcd_path); 214 215 int fd = open(dev_path, O_RDONLY); 216 if (fd < 0) { 217 return fd; 218 } 219 220 int hcd_phone = fd_phone(fd); 209 const char *vhc_path = "/vhc"; 210 int rc; 211 devman_handle_t handle; 212 213 rc = devman_device_get_handle(vhc_path, &handle, 0); 214 if (rc != EOK) { 215 printf("devman_device_get_handle() failed\n"); 216 return rc; 217 } 218 219 int hcd_phone = devman_device_connect(handle, 0); 221 220 222 221 if (hcd_phone < 0) { 222 printf("devman_device_connect() failed\n"); 223 223 return hcd_phone; 224 224 } 225 225 226 226 ipcarg_t phonehash; 227 intrc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash);227 rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash); 228 228 if (rc != EOK) { 229 printf("ipc_connect_to_me() failed\n"); 229 230 return rc; 230 231 }
Note:
See TracChangeset
for help on using the changeset viewer.