Changeset c9256c5 in mainline for uspace/lib/usb/src/hc.c
- Timestamp:
- 2011-05-20T20:37:06Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1889786, fcbcaae9
- Parents:
- 74b1e40 (diff), e8f826b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hc.c
r74b1e40 rc9256c5 27 27 */ 28 28 29 /** @addtogroup libusb dev29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * General communication between device drivers and host controller driver.33 * General communication with host controller driver (implementation). 34 34 */ 35 35 #include <devman.h> 36 36 #include <async.h> 37 #include <dev_iface.h> 37 38 #include <usb_iface.h> 38 #include <usb /dev/hc.h>39 #include <usb/ driver.h>39 #include <usbhc_iface.h> 40 #include <usb/hc.h> 40 41 #include <usb/debug.h> 41 42 #include <errno.h> … … 143 144 } 144 145 146 /** Get handle of USB device with given address. 147 * 148 * @param[in] connection Opened connection to host controller. 149 * @param[in] address Address of device in question. 150 * @param[out] handle Where to write the device handle. 151 * @return Error code. 152 */ 153 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection, 154 usb_address_t address, devman_handle_t *handle) 155 { 156 if (!usb_hc_connection_is_opened(connection)) { 157 return ENOENT; 158 } 159 160 sysarg_t tmp; 161 int rc = async_req_2_1(connection->hc_phone, 162 DEV_IFACE_ID(USBHC_DEV_IFACE), 163 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 164 address, &tmp); 165 if ((rc == EOK) && (handle != NULL)) { 166 *handle = tmp; 167 } 168 169 return rc; 170 } 171 172 /** Tell USB address assigned to device with given handle. 173 * 174 * @param dev_handle Devman handle of the USB device in question. 175 * @return USB address or negative error code. 176 */ 177 usb_address_t usb_hc_get_address_by_handle(devman_handle_t dev_handle) 178 { 179 int parent_phone = devman_parent_device_connect(dev_handle, 180 IPC_FLAG_BLOCKING); 181 if (parent_phone < 0) { 182 return parent_phone; 183 } 184 185 sysarg_t address; 186 187 int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 188 IPC_M_USB_GET_ADDRESS, 189 dev_handle, &address); 190 191 if (rc != EOK) { 192 return rc; 193 } 194 195 async_hangup(parent_phone); 196 197 return (usb_address_t) address; 198 } 199 200 201 /** Get host controller handle by its class index. 202 * 203 * @param class_index Class index for the host controller. 204 * @param hc_handle Where to store the HC handle 205 * (can be NULL for existence test only). 206 * @return Error code. 207 */ 208 int usb_ddf_get_hc_handle_by_class(size_t class_index, 209 devman_handle_t *hc_handle) 210 { 211 char *class_index_str; 212 devman_handle_t hc_handle_tmp; 213 int rc; 214 215 rc = asprintf(&class_index_str, "%zu", class_index); 216 if (rc < 0) { 217 return ENOMEM; 218 } 219 rc = devman_device_get_handle_by_class("usbhc", class_index_str, 220 &hc_handle_tmp, 0); 221 free(class_index_str); 222 if (rc != EOK) { 223 return rc; 224 } 225 226 if (hc_handle != NULL) { 227 *hc_handle = hc_handle_tmp; 228 } 229 230 return EOK; 231 } 232 233 /** Find host controller handle that is ancestor of given device. 234 * 235 * @param[in] device_handle Device devman handle. 236 * @param[out] hc_handle Where to store handle of host controller 237 * controlling device with @p device_handle handle. 238 * @return Error code. 239 */ 240 int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle) 241 { 242 int parent_phone = devman_parent_device_connect(device_handle, 243 IPC_FLAG_BLOCKING); 244 if (parent_phone < 0) { 245 return parent_phone; 246 } 247 248 devman_handle_t h; 249 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 250 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 251 252 async_hangup(parent_phone); 253 254 if (rc != EOK) { 255 return rc; 256 } 257 258 if (hc_handle != NULL) { 259 *hc_handle = h; 260 } 261 262 return EOK; 263 } 264 145 265 /** 146 266 * @}
Note:
See TracChangeset
for help on using the changeset viewer.