Changeset 710f518 in mainline for uspace/lib/usb/src/remotedrv.c
- Timestamp:
- 2010-11-28T17:43:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36bcf84f, fb1dca09
- Parents:
- a3dfb2e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/remotedrv.c
ra3dfb2e r710f518 42 42 43 43 static int remote_get_address(device_t *, devman_handle_t, usb_address_t *); 44 44 45 static int remote_interrupt_out(device_t *, usb_target_t, void *, size_t, 45 46 usbhc_iface_transfer_out_callback_t, void *); … … 47 48 usbhc_iface_transfer_in_callback_t, void *); 48 49 50 static int remote_control_write_setup(device_t *, usb_target_t, 51 void *, size_t, 52 usbhc_iface_transfer_out_callback_t, void *); 53 static int remote_control_write_data(device_t *, usb_target_t, 54 void *, size_t, 55 usbhc_iface_transfer_out_callback_t, void *); 56 static int remote_control_write_status(device_t *, usb_target_t, 57 usbhc_iface_transfer_in_callback_t, void *); 58 59 static int remote_control_read_setup(device_t *, usb_target_t, 60 void *, size_t, 61 usbhc_iface_transfer_out_callback_t, void *); 62 static int remote_control_read_data(device_t *, usb_target_t, 63 void *, size_t, 64 usbhc_iface_transfer_in_callback_t, void *); 65 static int remote_control_read_status(device_t *, usb_target_t, 66 usbhc_iface_transfer_out_callback_t, void *); 67 49 68 /** Implementation of USB HC interface. */ 50 69 usbhc_iface_t usbhc_interface = { 51 70 .tell_address = remote_get_address, 52 71 .interrupt_out = remote_interrupt_out, 53 .interrupt_in = remote_interrupt_in 72 .interrupt_in = remote_interrupt_in, 73 .control_write_setup = remote_control_write_setup, 74 .control_write_data = remote_control_write_data, 75 .control_write_status = remote_control_write_status, 76 .control_read_setup = remote_control_read_setup, 77 .control_read_data = remote_control_read_data, 78 .control_read_status = remote_control_read_status 54 79 }; 55 80 … … 224 249 } 225 250 226 /** Callback for IN transfers. 227 * This callback is called by implementation of HC operations. 228 * 229 * @param hc Host controller that processed the transfer. 230 * @param outcome Transfer outcome. 231 * @param actual_size Size of actually received data. 232 * @param arg Custom argument. 233 */ 234 static void remote_in_callback(usb_hc_device_t *hc, 235 usb_transaction_outcome_t outcome, size_t actual_size, void *arg) 236 { 237 transfer_info_t *transfer = (transfer_info_t *) arg; 238 transfer->in_callback(hc->generic, outcome, actual_size, transfer->arg); 239 240 transfer_info_destroy(transfer); 241 } 242 243 /** Start an IN transfer. 251 /** Start a SETUP transfer. 244 252 * 245 253 * @param dev Device that shall process the transfer. … … 252 260 * @return Error code. 253 261 */ 262 static int remote_setup_transfer(device_t *dev, usb_target_t target, 263 usb_transfer_type_t transfer_type, void *data, size_t size, 264 usbhc_iface_transfer_out_callback_t callback, void *arg) 265 { 266 usb_hc_device_t *hc = (usb_hc_device_t *) dev->driver_data; 267 268 if ((hc->transfer_ops == NULL) 269 || (hc->transfer_ops->transfer_setup == NULL)) { 270 return ENOTSUP; 271 } 272 273 transfer_info_t *transfer = transfer_info_create( 274 create_attached_device_info(target.address), 275 create_endpoint_info(target.endpoint, 276 USB_DIRECTION_OUT, transfer_type), 277 arg); 278 transfer->out_callback = callback; 279 280 int rc = hc->transfer_ops->transfer_setup(hc, 281 transfer->device, transfer->endpoint, 282 data, size, 283 remote_out_callback, transfer); 284 285 if (rc != EOK) { 286 transfer_info_destroy(transfer); 287 return rc; 288 } 289 290 return EOK; 291 } 292 293 /** Callback for IN transfers. 294 * This callback is called by implementation of HC operations. 295 * 296 * @param hc Host controller that processed the transfer. 297 * @param outcome Transfer outcome. 298 * @param actual_size Size of actually received data. 299 * @param arg Custom argument. 300 */ 301 static void remote_in_callback(usb_hc_device_t *hc, 302 usb_transaction_outcome_t outcome, size_t actual_size, void *arg) 303 { 304 transfer_info_t *transfer = (transfer_info_t *) arg; 305 transfer->in_callback(hc->generic, outcome, actual_size, transfer->arg); 306 307 transfer_info_destroy(transfer); 308 } 309 310 /** Start an IN transfer. 311 * 312 * @param dev Device that shall process the transfer. 313 * @param target Target device for the data. 314 * @param transfer_type Transfer type. 315 * @param data Data buffer. 316 * @param size Size of data buffer. 317 * @param callback Callback after transfer is complete. 318 * @param arg Custom argument to the callback. 319 * @return Error code. 320 */ 254 321 static int remote_in_transfer(device_t *dev, usb_target_t target, 255 322 usb_transfer_type_t transfer_type, void *data, size_t size, … … 320 387 321 388 389 int remote_control_write_setup(device_t *device, usb_target_t target, 390 void *buffer, size_t size, 391 usbhc_iface_transfer_out_callback_t callback, void *arg) 392 { 393 return remote_setup_transfer(device, target, USB_TRANSFER_CONTROL, 394 buffer, size, callback, arg); 395 } 396 397 int remote_control_write_data(device_t *device, usb_target_t target, 398 void *buffer, size_t size, 399 usbhc_iface_transfer_out_callback_t callback, void *arg) 400 { 401 return remote_out_transfer(device, target, USB_TRANSFER_CONTROL, 402 buffer, size, callback, arg); 403 } 404 405 int remote_control_write_status(device_t *device, usb_target_t target, 406 usbhc_iface_transfer_in_callback_t callback, void *arg) 407 { 408 return remote_in_transfer(device, target, USB_TRANSFER_CONTROL, 409 NULL, 0, callback, arg); 410 } 411 412 int remote_control_read_setup(device_t *device, usb_target_t target, 413 void *buffer, size_t size, 414 usbhc_iface_transfer_out_callback_t callback, void *arg) 415 { 416 return remote_setup_transfer(device, target, USB_TRANSFER_CONTROL, 417 buffer, size, callback, arg); 418 } 419 420 int remote_control_read_data(device_t *dev, usb_target_t target, 421 void *buffer, size_t size, 422 usbhc_iface_transfer_in_callback_t callback, void *arg) 423 { 424 return remote_in_transfer(dev, target, USB_TRANSFER_CONTROL, 425 buffer, size, callback, arg); 426 } 427 428 int remote_control_read_status(device_t *device, usb_target_t target, 429 usbhc_iface_transfer_out_callback_t callback, void *arg) 430 { 431 return remote_out_transfer(device, target, USB_TRANSFER_CONTROL, 432 NULL, 0, callback, arg); 433 } 434 322 435 /** 323 436 * @}
Note:
See TracChangeset
for help on using the changeset viewer.