Changeset 5514cf7 in mainline
- Timestamp:
- 2013-08-07T09:16:57Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3121b5f
- Parents:
- 4b8ecff
- Location:
- uspace/lib/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r4b8ecff r5514cf7 64 64 65 65 typedef enum { 66 IPC_M_USB_GET_MY_ADDRESS,67 66 IPC_M_USB_GET_MY_INTERFACE, 68 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE,69 67 IPC_M_USB_GET_DEVICE_HANDLE, 70 68 IPC_M_USB_RESERVE_DEFAULT_ADDRESS, … … 78 76 } usb_iface_funcs_t; 79 77 80 /** Tell USB address assigned to device.81 * @param exch Vaid IPC exchange82 * @param address Pointer to address storage place.83 * @return Error code.84 *85 * Exch param is an open communication to device implementing usb_iface.86 */87 int usb_get_my_address(async_exch_t *exch, usb_address_t *address)88 {89 sysarg_t addr;90 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),91 IPC_M_USB_GET_MY_ADDRESS, &addr);92 93 if (ret == EOK && address != NULL)94 *address = (usb_address_t) addr;95 return ret;96 }97 98 78 /** Tell interface number given device can use. 99 79 * @param[in] exch IPC communication exchange … … 111 91 if (ret == EOK && usb_iface) 112 92 *usb_iface = (int)iface_no; 113 return ret;114 }115 116 /** Tell devman handle of device host controller.117 * @param[in] exch IPC communication exchange118 * @param[out] hc_handle devman handle of the HC used by the target device.119 * @return Error code.120 */121 int usb_get_hc_handle(async_exch_t *exch, devman_handle_t *hc_handle)122 {123 if (!exch)124 return EBADMEM;125 devman_handle_t h;126 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),127 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);128 if (ret == EOK && hc_handle)129 *hc_handle = (devman_handle_t)h;130 93 return ret; 131 94 } … … 309 272 } 310 273 311 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);312 274 static void remote_usb_get_my_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 313 static void remote_usb_get_hc_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);314 275 static void remote_usb_get_device_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 315 316 276 static void remote_usb_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 317 277 static void remote_usb_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 321 281 static void remote_usb_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 322 282 static void remote_usb_read(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call); 323 324 283 static void remote_usb_write(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call); 325 284 326 285 /** Remote USB interface operations. */ 327 286 static remote_iface_func_ptr_t remote_usb_iface_ops [] = { 328 [IPC_M_USB_GET_MY_ADDRESS] = remote_usb_get_my_address,329 287 [IPC_M_USB_GET_MY_INTERFACE] = remote_usb_get_my_interface, 330 [IPC_M_USB_GET_HOST_CONTROLLER_HANDLE] = remote_usb_get_hc_handle,331 288 [IPC_M_USB_GET_DEVICE_HANDLE] = remote_usb_get_device_handle, 332 289 [IPC_M_USB_RESERVE_DEFAULT_ADDRESS] = remote_usb_reserve_default_address, … … 347 304 }; 348 305 349 350 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface,351 ipc_callid_t callid, ipc_call_t *call)352 {353 const usb_iface_t *usb_iface = (usb_iface_t *) iface;354 355 if (usb_iface->get_my_address == NULL) {356 async_answer_0(callid, ENOTSUP);357 return;358 }359 360 usb_address_t address;361 const int ret = usb_iface->get_my_address(fun, &address);362 if (ret != EOK) {363 async_answer_0(callid, ret);364 } else {365 async_answer_1(callid, EOK, address);366 }367 }368 369 306 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface, 370 307 ipc_callid_t callid, ipc_call_t *call) … … 386 323 } 387 324 388 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,389 ipc_callid_t callid, ipc_call_t *call)390 {391 const usb_iface_t *usb_iface = (usb_iface_t *) iface;392 393 if (usb_iface->get_hc_handle == NULL) {394 async_answer_0(callid, ENOTSUP);395 return;396 }397 398 devman_handle_t handle;399 const int ret = usb_iface->get_hc_handle(fun, &handle);400 if (ret != EOK) {401 async_answer_0(callid, ret);402 }403 404 async_answer_1(callid, EOK, (sysarg_t) handle);405 }406 407 325 void remote_usb_get_device_handle(ddf_fun_t *fun, void *iface, 408 326 ipc_callid_t callid, ipc_call_t *call) -
uspace/lib/drv/include/usb_iface.h
r4b8ecff r5514cf7 52 52 void usb_dev_disconnect(usb_dev_session_t *); 53 53 54 int usb_get_my_address(async_exch_t *, usb_address_t *);55 54 int usb_get_my_interface(async_exch_t *, int *); 56 int usb_get_hc_handle(async_exch_t *, devman_handle_t *);57 55 int usb_get_device_handle(async_exch_t *, devman_handle_t *); 58 56 … … 77 75 /** USB device communication interface. */ 78 76 typedef struct { 79 int (*get_my_address)(ddf_fun_t *, usb_address_t *);80 77 int (*get_my_interface)(ddf_fun_t *, int *); 81 int (*get_hc_handle)(ddf_fun_t *, devman_handle_t *);82 83 78 int (*get_device_handle)(ddf_fun_t *, devman_handle_t *); 84 79 85 80 int (*reserve_default_address)(ddf_fun_t *, usb_speed_t); 86 81 int (*release_default_address)(ddf_fun_t *); 82 87 83 int (*device_enumerate)(ddf_fun_t *, usb_device_handle_t *); 88 84 int (*device_remove)(ddf_fun_t *, usb_device_handle_t); 85 89 86 int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t, 90 87 usb_transfer_type_t, usb_direction_t, size_t, unsigned); 91 88 int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_t, 92 89 usb_direction_t); 90 93 91 int (*read)(ddf_fun_t *, usb_endpoint_t, uint64_t, uint8_t *, size_t, 94 92 usbhc_iface_transfer_in_callback_t, void *);
Note:
See TracChangeset
for help on using the changeset viewer.