Changeset beee81a in mainline for uspace/lib/usbvirt/src/ipc_dev.c
- Timestamp:
- 2011-05-07T09:35:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bc02b83, d38d830
- Parents:
- 42e2172
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbvirt/src/ipc_dev.c
r42e2172 rbeee81a 43 43 #include <usb/debug.h> 44 44 45 /** Handle VHC request for device name. 46 * 47 * @param dev Target virtual device. 48 * @param iid Caller id. 49 * @param icall The call with the request. 50 */ 45 51 static void ipc_get_name(usbvirt_device_t *dev, 46 52 ipc_callid_t iid, ipc_call_t *icall) … … 67 73 } 68 74 75 /** Handle VHC request for control read from the device. 76 * 77 * @param dev Target virtual device. 78 * @param iid Caller id. 79 * @param icall The call with the request. 80 */ 69 81 static void ipc_control_read(usbvirt_device_t *dev, 70 82 ipc_callid_t iid, ipc_call_t *icall) 71 83 { 72 //usb_endpoint_t endpoint = IPC_GET_ARG1(*icall);73 74 84 int rc; 75 85 … … 118 128 } 119 129 130 /** Handle VHC request for control write to the device. 131 * 132 * @param dev Target virtual device. 133 * @param iid Caller id. 134 * @param icall The call with the request. 135 */ 120 136 static void ipc_control_write(usbvirt_device_t *dev, 121 137 ipc_callid_t iid, ipc_call_t *icall) 122 138 { 123 size_t data_buffer_len = IPC_GET_ARG 2(*icall);139 size_t data_buffer_len = IPC_GET_ARG1(*icall); 124 140 int rc; 125 141 … … 129 145 130 146 rc = async_data_write_accept(&setup_packet, false, 131 1, 1024, 0, &setup_packet_len);147 1, 0, 0, &setup_packet_len); 132 148 if (rc != EOK) { 133 149 async_answer_0(iid, rc); … … 137 153 if (data_buffer_len > 0) { 138 154 rc = async_data_write_accept(&data_buffer, false, 139 1, 1024, 0, &data_buffer_len);155 1, 0, 0, &data_buffer_len); 140 156 if (rc != EOK) { 141 157 async_answer_0(iid, rc); … … 149 165 150 166 async_answer_0(iid, rc); 151 } 152 153 static void ipc_interrupt_in(usbvirt_device_t *dev, 167 168 free(setup_packet); 169 if (data_buffer != NULL) { 170 free(data_buffer); 171 } 172 } 173 174 /** Handle VHC request for data read from the device (in transfer). 175 * 176 * @param dev Target virtual device. 177 * @param iid Caller id. 178 * @param icall The call with the request. 179 */ 180 static void ipc_data_in(usbvirt_device_t *dev, 181 usb_transfer_type_t transfer_type, 154 182 ipc_callid_t iid, ipc_call_t *icall) 155 183 { 156 184 usb_endpoint_t endpoint = IPC_GET_ARG1(*icall); 157 usb_transfer_type_t transfer_type = IPC_GET_ARG2(*icall);158 185 159 186 int rc; … … 189 216 } 190 217 191 static void ipc_interrupt_out(usbvirt_device_t *dev, 218 /** Handle VHC request for data write to the device (out transfer). 219 * 220 * @param dev Target virtual device. 221 * @param iid Caller id. 222 * @param icall The call with the request. 223 */ 224 static void ipc_data_out(usbvirt_device_t *dev, 225 usb_transfer_type_t transfer_type, 192 226 ipc_callid_t iid, ipc_call_t *icall) 193 227 { 194 228 usb_endpoint_t endpoint = IPC_GET_ARG1(*icall); 195 usb_transfer_type_t transfer_type = IPC_GET_ARG2(*icall);196 229 197 230 void *data_buffer = NULL; … … 199 232 200 233 int rc = async_data_write_accept(&data_buffer, false, 201 1, 1024, 0, &data_buffer_size);234 1, 0, 0, &data_buffer_size); 202 235 if (rc != EOK) { 203 236 async_answer_0(iid, rc); … … 213 246 } 214 247 215 248 /** Handle incoming IPC call for virtual USB device. 249 * 250 * @param dev Target USB device. 251 * @param callid Caller id. 252 * @param call Incoming call. 253 * @return Whether the call was handled. 254 */ 216 255 bool usbvirt_ipc_handle_call(usbvirt_device_t *dev, 217 256 ipc_callid_t callid, ipc_call_t *call) 218 257 { 219 258 switch (IPC_GET_IMETHOD(*call)) { 220 case IPC_M_USBVIRT_GET_NAME: 221 ipc_get_name(dev, callid, call); 222 break; 223 224 case IPC_M_USBVIRT_CONTROL_READ: 225 ipc_control_read(dev, callid, call); 226 break; 227 228 case IPC_M_USBVIRT_CONTROL_WRITE: 229 ipc_control_write(dev, callid, call); 230 break; 231 232 case IPC_M_USBVIRT_INTERRUPT_IN: 233 ipc_interrupt_in(dev, callid, call); 234 break; 235 236 case IPC_M_USBVIRT_INTERRUPT_OUT: 237 ipc_interrupt_out(dev, callid, call); 238 break; 239 240 default: 241 return false; 259 case IPC_M_USBVIRT_GET_NAME: 260 ipc_get_name(dev, callid, call); 261 break; 262 263 case IPC_M_USBVIRT_CONTROL_READ: 264 ipc_control_read(dev, callid, call); 265 break; 266 267 case IPC_M_USBVIRT_CONTROL_WRITE: 268 ipc_control_write(dev, callid, call); 269 break; 270 271 case IPC_M_USBVIRT_INTERRUPT_IN: 272 ipc_data_in(dev, USB_TRANSFER_INTERRUPT, callid, call); 273 break; 274 275 case IPC_M_USBVIRT_BULK_IN: 276 ipc_data_in(dev, USB_TRANSFER_BULK, callid, call); 277 break; 278 279 case IPC_M_USBVIRT_INTERRUPT_OUT: 280 ipc_data_out(dev, USB_TRANSFER_INTERRUPT, callid, call); 281 break; 282 283 case IPC_M_USBVIRT_BULK_OUT: 284 ipc_data_out(dev, USB_TRANSFER_BULK, callid, call); 285 break; 286 287 288 default: 289 return false; 242 290 } 243 291
Note:
See TracChangeset
for help on using the changeset viewer.