Changeset 56bdd9a4 in mainline for uspace/lib/drv
- Timestamp:
- 2011-11-25T15:20:04Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 02fc5c4
- Parents:
- 317a463
- Location:
- uspace/lib/drv
- Files:
-
- 2 edited
-
generic/remote_usb.c (modified) (6 diffs)
-
include/usb_iface.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r317a463 r56bdd9a4 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 39 40 #include "ddf/driver.h" 40 41 42 typedef enum { 43 IPC_M_USB_GET_MY_ADDRESS, 44 IPC_M_USB_GET_MY_INTERFACE, 45 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, 46 } usb_iface_funcs_t; 47 48 /** Tell USB address assigned to device. 49 * @param exch Vaid IPC exchange 50 * @param address Pointer to address storage place. 51 * @return Error code. 52 * 53 * Exch param is an open communication to device implementing usb_iface. 54 */ 55 int usb_get_my_address(async_exch_t *exch, usb_address_t *address) 56 { 57 if (!exch) 58 return EINVAL; 59 sysarg_t addr; 60 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 61 IPC_M_USB_GET_MY_ADDRESS, &addr); 62 63 if (ret == EOK && address != NULL) 64 *address = (usb_address_t) addr; 65 return ret; 66 } 67 /*----------------------------------------------------------------------------*/ 68 /** Tell interface number given device can use. 69 * @param[in] exch IPC communication exchange 70 * @param[in] handle Id of the device 71 * @param[out] usb_iface Assigned USB interface 72 * @return Error code. 73 */ 74 int usb_get_my_interface(async_exch_t *exch, int *usb_iface) 75 { 76 if (!exch) 77 return EINVAL; 78 sysarg_t iface_no; 79 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 80 IPC_M_USB_GET_MY_INTERFACE, &iface_no); 81 if (ret == EOK && usb_iface) 82 *usb_iface = (int)iface_no; 83 return ret; 84 } 85 /*----------------------------------------------------------------------------*/ 86 /** Tell devman handle of device host controller. 87 * @param[in] exch IPC communication exchange 88 * @param[out] hc_handle devman handle of the HC used by the target device. 89 * @return Error code. 90 */ 91 int usb_get_hc_handle(async_exch_t *exch, devman_handle_t *hc_handle) 92 { 93 if (!exch) 94 return EINVAL; 95 devman_handle_t h; 96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 97 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 98 if (ret == EOK && hc_handle) 99 *hc_handle = (devman_handle_t)h; 100 return ret; 101 } 102 41 103 42 104 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 59 121 }; 60 122 61 123 /*----------------------------------------------------------------------------*/ 62 124 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface, 63 125 ipc_callid_t callid, ipc_call_t *call) 64 126 { 65 usb_iface_t *usb_iface = (usb_iface_t *) iface;127 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 66 128 67 129 if (usb_iface->get_my_address == NULL) { … … 71 133 72 134 usb_address_t address; 73 int rc= usb_iface->get_my_address(fun, &address);74 if (r c!= EOK) {75 async_answer_0(callid, r c);135 const int ret = usb_iface->get_my_address(fun, &address); 136 if (ret != EOK) { 137 async_answer_0(callid, ret); 76 138 } else { 77 139 async_answer_1(callid, EOK, address); 78 140 } 79 141 } 80 142 /*----------------------------------------------------------------------------*/ 81 143 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface, 82 144 ipc_callid_t callid, ipc_call_t *call) 83 145 { 84 usb_iface_t *usb_iface = (usb_iface_t *) iface;146 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 85 147 86 148 if (usb_iface->get_my_interface == NULL) { … … 90 152 91 153 int iface_no; 92 int rc= usb_iface->get_my_interface(fun, &iface_no);93 if (r c!= EOK) {94 async_answer_0(callid, r c);154 const int ret = usb_iface->get_my_interface(fun, &iface_no); 155 if (ret != EOK) { 156 async_answer_0(callid, ret); 95 157 } else { 96 158 async_answer_1(callid, EOK, iface_no); 97 159 } 98 160 } 99 161 /*----------------------------------------------------------------------------*/ 100 162 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface, 101 163 ipc_callid_t callid, ipc_call_t *call) 102 164 { 103 usb_iface_t *usb_iface = (usb_iface_t *) iface;165 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 104 166 105 167 if (usb_iface->get_hc_handle == NULL) { … … 109 171 110 172 devman_handle_t handle; 111 int rc= usb_iface->get_hc_handle(fun, &handle);112 if (r c!= EOK) {113 async_answer_0(callid, r c);173 const int ret = usb_iface->get_hc_handle(fun, &handle); 174 if (ret != EOK) { 175 async_answer_0(callid, ret); 114 176 } 115 177 116 178 async_answer_1(callid, EOK, (sysarg_t) handle); 117 179 } 118 119 120 121 180 /** 122 181 * @} -
uspace/lib/drv/include/usb_iface.h
r317a463 r56bdd9a4 39 39 40 40 #include "ddf/driver.h" 41 #include <async.h> 41 42 #include <usb/usb.h> 42 typedef enum {43 /** Tell USB address assigned to device.44 * Parameters:45 * - devman handle id46 * Answer:47 * - EINVAL - unknown handle or handle not managed by this driver48 * - ENOTSUP - operation not supported (shall not happen)49 * - arbitrary error code if returned by remote implementation50 * - EOK - handle found, first parameter contains the USB address51 *52 * The handle must be the one used for binding USB address with53 * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller54 * (that this request would eventually reach) would not be able55 * to find it.56 * The problem is that this handle is actually assigned to the57 * function inside driver of the parent device (usually hub driver).58 * To bypass this problem, the initial caller specify handle as59 * zero and the first parent assigns the actual value.60 * See usb_iface_get_address_hub_child_impl() implementation61 * that could be assigned to device ops of a child device of in a62 * hub driver.63 * For example, the USB multi interface device driver (MID)64 * passes this initial zero without any modification because the65 * handle must be resolved by its parent.66 */67 IPC_M_USB_GET_MY_ADDRESS,68 43 69 /** Tell interface number given device can use. 70 * Parameters 71 * - devman handle id of the device 72 * Answer: 73 * - ENOTSUP - operation not supported (can also mean any interface) 74 * - EOK - operation okay, first parameter contains interface number 75 */ 76 IPC_M_USB_GET_MY_INTERFACE, 77 78 /** Tell devman handle of device host controller. 79 * Parameters: 80 * - none 81 * Answer: 82 * - EOK - request processed without errors 83 * - ENOTSUP - this indicates invalid USB driver 84 * Parameters of the answer: 85 * - devman handle of HC caller is physically connected to 86 */ 87 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE 88 } usb_iface_funcs_t; 44 int usb_get_my_address(async_exch_t *, usb_address_t *); 45 int usb_get_my_interface(async_exch_t *, int *); 46 int usb_get_hc_handle(async_exch_t *, devman_handle_t *); 89 47 90 48 /** USB device communication interface. */ … … 95 53 } usb_iface_t; 96 54 97 98 55 #endif 99 56 /**
Note:
See TracChangeset
for help on using the changeset viewer.
