Changeset b0fc92c in mainline
- Timestamp:
- 2013-07-26T13:29:05Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 059d507
- Parents:
- f3922c2
- Location:
- uspace/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
rf3922c2 rb0fc92c 84 84 */ 85 85 typedef enum { 86 /** Get handle binded with given USB address.87 * Parameters88 * - USB address89 * Answer:90 * - EOK - address binded, first parameter is the devman handle91 * - ENOENT - address is not in use at the moment92 */93 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,94 95 86 /** Register endpoint attributes at host controller. 96 87 * This is used to reserve portion of USB bandwidth. … … 131 122 } usbhc_iface_funcs_t; 132 123 133 134 135 int usbhc_get_handle(async_exch_t *exch, usb_address_t address,136 devman_handle_t *handle)137 {138 if (!exch)139 return EBADMEM;140 sysarg_t h;141 const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),142 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, address, &h);143 if (ret == EOK && handle)144 *handle = (devman_handle_t)h;145 return ret;146 }147 148 124 int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address, 149 125 usb_endpoint_t endpoint, usb_transfer_type_t type, … … 265 241 266 242 267 static void remote_usbhc_get_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);268 243 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 269 244 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 274 249 /** Remote USB host controller interface operations. */ 275 250 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = { 276 [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_get_handle,277 278 251 [IPC_M_USBHC_REGISTER_ENDPOINT] = remote_usbhc_register_endpoint, 279 252 [IPC_M_USBHC_UNREGISTER_ENDPOINT] = remote_usbhc_unregister_endpoint, … … 322 295 return trans; 323 296 } 324 325 326 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,327 ipc_callid_t callid, ipc_call_t *call)328 {329 const usbhc_iface_t *usb_iface = iface;330 331 if (!usb_iface->get_handle) {332 async_answer_0(callid, ENOTSUP);333 return;334 }335 336 const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);337 devman_handle_t handle;338 const int ret = usb_iface->get_handle(fun, address, &handle);339 340 if (ret == EOK) {341 async_answer_1(callid, ret, handle);342 } else {343 async_answer_0(callid, ret);344 }345 }346 347 297 348 298 static void callback_out(int outcome, void *arg) -
uspace/lib/drv/include/usbhc_iface.h
rf3922c2 rb0fc92c 44 44 #include <stdbool.h> 45 45 46 int usbhc_get_handle(async_exch_t *, usb_address_t, devman_handle_t *);47 46 int usbhc_register_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t, 48 47 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); … … 62 61 /** USB host controller communication interface. */ 63 62 typedef struct { 64 int (*get_handle)(ddf_fun_t *, usb_address_t, devman_handle_t *);65 66 63 int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t, 67 64 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); … … 71 68 int (*read)(ddf_fun_t *, usb_target_t, uint64_t, uint8_t *, size_t, 72 69 usbhc_iface_transfer_in_callback_t, void *); 73 74 70 int (*write)(ddf_fun_t *, usb_target_t, uint64_t, const uint8_t *, 75 71 size_t, usbhc_iface_transfer_out_callback_t, void *); -
uspace/lib/usb/include/usb/hc.h
rf3922c2 rb0fc92c 84 84 int usb_hc_connection_close(usb_hc_connection_t *); 85 85 86 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,87 devman_handle_t *);88 89 86 int usb_hc_read(usb_hc_connection_t *, usb_address_t, usb_endpoint_t, 90 87 uint64_t, void *, size_t, size_t *); -
uspace/lib/usb/src/hc.c
rf3922c2 rb0fc92c 144 144 } 145 145 146 147 /** Get handle of USB device with given address.148 *149 * @param[in] connection Opened connection to host controller.150 * @param[in] address Address of device in question.151 * @param[out] handle Where to write the device handle.152 * @return Error code.153 */154 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,155 usb_address_t address, devman_handle_t *handle)156 {157 async_exch_t *exch;158 EXCH_INIT(connection, exch);159 160 const int ret = usbhc_get_handle(exch, address, handle);161 162 EXCH_FINI(connection, exch);163 return ret;164 }165 166 146 int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address, 167 147 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, -
uspace/lib/usbhost/src/iface.c
rf3922c2 rb0fc92c 41 41 #include <usb/host/hcd.h> 42 42 #include "ddf_helpers.h" 43 44 /** Find device handle by address interface function.45 *46 * @param[in] fun DDF function that was called.47 * @param[in] address Address in question.48 * @param[out] handle Where to store device handle if found.49 * @return Error code.50 */51 static int find_by_address(ddf_fun_t *fun, usb_address_t address,52 devman_handle_t *handle)53 {54 assert(fun);55 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));56 assert(hcd);57 return usb_device_manager_get_info_by_address(58 &hcd->dev_manager, address, handle, NULL);59 }60 43 61 44 /** Register endpoint interface function. … … 148 131 /** usbhc Interface implementation using hcd_t from libusbhost library. */ 149 132 usbhc_iface_t hcd_iface = { 150 .get_handle = find_by_address,151 152 133 .register_endpoint = register_endpoint, 153 134 .unregister_endpoint = unregister_endpoint,
Note:
See TracChangeset
for help on using the changeset viewer.