Changeset 6967c14 in mainline
- Timestamp:
- 2011-01-25T17:44:06Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 875e7227
- Parents:
- afc4fbb
- Location:
- uspace/drv/vhc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/conn.h
rafc4fbb r6967c14 51 51 52 52 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); 53 void on_client_close(device_t *); 53 54 54 55 -
uspace/drv/vhc/conndev.c
rafc4fbb r6967c14 88 88 int callback = IPC_GET_ARG5(*icall); 89 89 virtdev_connection_t *dev 90 = virtdev_add_device(callback );90 = virtdev_add_device(callback, (sysarg_t)fibril_get_id()); 91 91 if (!dev) { 92 92 ipc_answer_0(icallid, EEXISTS); … … 99 99 int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH); 100 100 101 dprintf(0, "virtual device connected (name: %s)", 102 rc == EOK ? devname : "<unknown>"); 103 104 /* FIXME: destroy the device when the client disconnects. */ 101 dprintf(0, "virtual device connected (name: %s, id: %x)", 102 rc == EOK ? devname : "<unknown>", dev->id); 105 103 106 104 return; … … 110 108 } 111 109 110 /** Callback for DDF when client disconnects. 111 * 112 * @param d Device the client was connected to. 113 */ 114 void on_client_close(device_t *d) 115 { 116 /* 117 * Maybe a virtual device is being unplugged. 118 */ 119 virtdev_connection_t *dev = virtdev_find((sysarg_t)fibril_get_id()); 120 if (dev == NULL) { 121 return; 122 } 123 124 dprintf(0, "virtual device disconnected (id: %x)", dev->id); 125 virtdev_destroy_device(dev); 126 } 127 112 128 113 129 /** -
uspace/drv/vhc/devices.c
rafc4fbb r6967c14 59 59 * 60 60 * @param phone Callback phone. 61 * @param id Device id. 61 62 * @return New device. 62 63 * @retval NULL Out of memory. 63 64 */ 64 virtdev_connection_t *virtdev_add_device(int phone )65 virtdev_connection_t *virtdev_add_device(int phone, sysarg_t id) 65 66 { 66 67 virtdev_connection_t *dev = (virtdev_connection_t *) … … 71 72 72 73 dev->phone = phone; 74 dev->id = id; 73 75 list_append(&dev->link, &devices); 74 76 … … 76 78 77 79 return dev; 80 } 81 82 /** Find virtual device by id. 83 * 84 * @param id Device id. 85 * @return Device with given id. 86 * @retval NULL No such device. 87 */ 88 virtdev_connection_t *virtdev_find(sysarg_t id) 89 { 90 link_t *pos; 91 list_foreach(pos, &devices) { 92 virtdev_connection_t *dev 93 = list_get_instance(pos, virtdev_connection_t, link); 94 if (dev->id == id) { 95 return dev; 96 } 97 } 98 99 return NULL; 78 100 } 79 101 -
uspace/drv/vhc/devices.h
rafc4fbb r6967c14 45 45 /** Phone used when sending data to device. */ 46 46 int phone; 47 /** Unique identification. */ 48 sysarg_t id; 47 49 /** Linked-list handle. */ 48 50 link_t link; 49 51 } virtdev_connection_t; 50 52 51 virtdev_connection_t *virtdev_add_device(int );52 virtdev_connection_t *virtdev_ get_mine(void);53 virtdev_connection_t *virtdev_add_device(int, sysarg_t); 54 virtdev_connection_t *virtdev_find(sysarg_t); 53 55 void virtdev_destroy_device(virtdev_connection_t *); 54 56 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *); -
uspace/drv/vhc/hcd.c
rafc4fbb r6967c14 69 69 .interfaces[USBHC_DEV_IFACE] = &vhc_iface, 70 70 .interfaces[USB_DEV_IFACE] = &hc_usb_iface, 71 .close = on_client_close, 71 72 .default_handler = default_connection_handler 72 73 };
Note:
See TracChangeset
for help on using the changeset viewer.