Changeset 70a422b in mainline
- Timestamp:
- 2013-01-27T19:12:05Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d2cfe72
- Parents:
- 8582076
- Location:
- uspace/lib/drv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r8582076 r70a422b 74 74 IPC_M_USB_DEVICE_ENUMERATE, 75 75 IPC_M_USB_DEVICE_REMOVE, 76 IPC_M_USB_REGISTER_ENDPOINT, 77 IPC_M_USB_UNREGISTER_ENDPOINT, 76 78 } usb_iface_funcs_t; 77 79 … … 186 188 } 187 189 190 int usb_register_endpoint(async_exch_t *exch, usb_endpoint_t endpoint, 191 usb_transfer_type_t type, usb_direction_t direction, 192 size_t mps, unsigned interval) 193 { 194 if (!exch) 195 return EBADMEM; 196 #define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff)) 197 198 return async_req_4_0(exch, DEV_IFACE_ID(USB_DEV_IFACE), 199 IPC_M_USB_REGISTER_ENDPOINT, endpoint, 200 _PACK2(type, direction), _PACK2(mps, interval)); 201 202 #undef _PACK2 203 } 204 205 int usb_unregister_endpoint(async_exch_t *exch, usb_endpoint_t endpoint, 206 usb_direction_t direction) 207 { 208 if (!exch) 209 return EBADMEM; 210 return async_req_3_0(exch, DEV_IFACE_ID(USB_DEV_IFACE), 211 IPC_M_USB_UNREGISTER_ENDPOINT, endpoint, direction); 212 } 213 188 214 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 189 215 static void remote_usb_get_my_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 194 220 static void remote_usb_device_enumerate(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 195 221 static void remote_usb_device_remove(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 222 static void remote_usb_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 223 static void remote_usb_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 196 224 197 225 /** Remote USB interface operations. */ … … 204 232 [IPC_M_USB_DEVICE_ENUMERATE] = remote_usb_device_enumerate, 205 233 [IPC_M_USB_DEVICE_REMOVE] = remote_usb_device_remove, 234 [IPC_M_USB_REGISTER_ENDPOINT] = remote_usb_register_endpoint, 235 [IPC_M_USB_UNREGISTER_ENDPOINT] = remote_usb_unregister_endpoint, 206 236 }; 207 237 … … 333 363 async_answer_0(callid, ret); 334 364 } 365 366 static void remote_usb_register_endpoint(ddf_fun_t *fun, void *iface, 367 ipc_callid_t callid, ipc_call_t *call) 368 { 369 usb_iface_t *usb_iface = (usb_iface_t *) iface; 370 371 if (!usb_iface->register_endpoint) { 372 async_answer_0(callid, ENOTSUP); 373 return; 374 } 375 376 #define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \ 377 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) >> 16) 378 #define _INIT_FROM_LOW_DATA2(type, var, arg_no) \ 379 type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) & 0xffff) 380 381 const usb_endpoint_t endpoint = DEV_IPC_GET_ARG1(*call); 382 383 _INIT_FROM_HIGH_DATA2(usb_transfer_type_t, transfer_type, 2); 384 _INIT_FROM_LOW_DATA2(usb_direction_t, direction, 2); 385 386 _INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3); 387 _INIT_FROM_LOW_DATA2(unsigned int, interval, 3); 388 389 #undef _INIT_FROM_HIGH_DATA2 390 #undef _INIT_FROM_LOW_DATA2 391 392 const int ret = usb_iface->register_endpoint(fun, endpoint, 393 transfer_type, direction, max_packet_size, interval); 394 395 async_answer_0(callid, ret); 396 } 397 398 static void remote_usb_unregister_endpoint(ddf_fun_t *fun, void *iface, 399 ipc_callid_t callid, ipc_call_t *call) 400 { 401 usb_iface_t *usb_iface = (usb_iface_t *) iface; 402 403 if (!usb_iface->unregister_endpoint) { 404 async_answer_0(callid, ENOTSUP); 405 return; 406 } 407 408 usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG1(*call); 409 usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG2(*call); 410 411 int rc = usb_iface->unregister_endpoint(fun, endpoint, direction); 412 413 async_answer_0(callid, rc); 414 } 335 415 /** 336 416 * @} -
uspace/lib/drv/include/usb_iface.h
r8582076 r70a422b 62 62 int usb_device_remove(async_exch_t *, usb_device_handle_t); 63 63 64 int usb_register_endpoint(async_exch_t *, usb_endpoint_t, usb_transfer_type_t, 65 usb_direction_t, size_t, unsigned); 66 int usb_unregister_endpoint(async_exch_t *, usb_endpoint_t, usb_direction_t); 67 64 68 /** USB device communication interface. */ 65 69 typedef struct { … … 72 76 int (*device_enumerate)(ddf_fun_t *, usb_device_handle_t *); 73 77 int (*device_remove)(ddf_fun_t *, usb_device_handle_t); 78 int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t, 79 usb_transfer_type_t, usb_direction_t, size_t, unsigned); 80 int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_t, 81 usb_direction_t); 74 82 } usb_iface_t; 75 83
Note:
See TracChangeset
for help on using the changeset viewer.