Changeset 47e3a8e in mainline for uspace/srv/hw/bus/usb/hcd/virtual/devices.c
- Timestamp:
- 2010-10-15T16:32:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 186d630
- Parents:
- 73301a0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/usb/hcd/virtual/devices.c
r73301a0 r47e3a8e 44 44 45 45 #include <usbvirt/ids.h> 46 #include <usbvirt/hub.h> 46 47 47 48 #include "devices.h" … … 63 64 switch (id) { 64 65 case USBVIRT_DEV_KEYBOARD_ID: 65 dev = virtdev_add_device( 66 USBVIRT_DEV_KEYBOARD_ADDRESS, phone); 66 dev = virtdev_add_device(phone); 67 67 break; 68 68 default: … … 84 84 } 85 85 86 /** Find virtual device by its USB address.87 *88 * @retval NULL No virtual device at given address.89 */90 virtdev_connection_t *virtdev_find_by_address(usb_address_t address)91 {92 link_t *pos;93 list_foreach(pos, &devices) {94 virtdev_connection_t *dev95 = list_get_instance(pos, virtdev_connection_t, link);96 if (dev->address == address) {97 return dev;98 }99 }100 101 return NULL;102 }103 104 86 /** Create virtual device. 105 87 * … … 109 91 * @retval NULL Out of memory or address already occupied. 110 92 */ 111 virtdev_connection_t *virtdev_add_device( usb_address_t address,int phone)93 virtdev_connection_t *virtdev_add_device(int phone) 112 94 { 113 link_t *pos;114 list_foreach(pos, &devices) {115 virtdev_connection_t *dev116 = list_get_instance(pos, virtdev_connection_t, link);117 if (dev->address == address) {118 return NULL;119 }120 }121 122 95 virtdev_connection_t *dev = (virtdev_connection_t *) 123 96 malloc(sizeof(virtdev_connection_t)); 124 97 dev->phone = phone; 125 dev->address = address;126 98 list_append(&dev->link, &devices); 127 99 … … 137 109 } 138 110 111 /** Send data to all connected devices. 112 * 113 * @param transaction Transaction to be sent over the bus. 114 */ 115 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction) 116 { 117 link_t *pos; 118 list_foreach(pos, &devices) { 119 virtdev_connection_t *dev 120 = list_get_instance(pos, virtdev_connection_t, link); 121 122 ipc_call_t answer_data; 123 ipcarg_t answer_rc; 124 aid_t req; 125 int rc; 126 127 req = async_send_3(dev->phone, 128 IPC_M_USBVIRT_DATA_TO_DEVICE, 129 transaction->target.address, 130 transaction->target.endpoint, 131 transaction->type, 132 &answer_data); 133 134 rc = async_data_write_start(dev->phone, 135 transaction->buffer, transaction->len); 136 if (rc != EOK) { 137 async_wait_for(req, NULL); 138 } else { 139 async_wait_for(req, &answer_rc); 140 rc = (int)answer_rc; 141 } 142 } 143 144 /* 145 * TODO: maybe screw some transactions to get more 146 * real-life image. 147 */ 148 return USB_OUTCOME_OK; 149 } 150 139 151 /** 140 152 * @}
Note:
See TracChangeset
for help on using the changeset viewer.