Changeset 511cfc8 in mainline
- Timestamp:
- 2011-05-08T19:06:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23f40280, ebf6a40
- Parents:
- 11349a85 (diff), 7b6f116 (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. - Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/lsusb/main.c
r11349a85 r511cfc8 44 44 #include <devman.h> 45 45 #include <devmap.h> 46 #include <usb/hub.h> 46 47 #include <usb/host.h> 47 48 48 49 #define NAME "lsusb" 49 50 50 #define MAX_FAILED_ATTEMPTS 451 #define MAX_FAILED_ATTEMPTS 10 51 52 #define MAX_PATH_LENGTH 1024 53 54 static void print_found_hc(size_t class_index, const char *path) 55 { 56 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 57 printf("Bus %02zu: %s\n", class_index, path); 58 } 59 static void print_found_dev(usb_address_t addr, const char *path) 60 { 61 // printf(NAME ": device with address %d is `%s'.\n", addr, path); 62 printf(" Device %02d: %s\n", addr, path); 63 } 64 65 static void print_hc_devices(devman_handle_t hc_handle) 66 { 67 int rc; 68 usb_hc_connection_t conn; 69 70 usb_hc_connection_initialize(&conn, hc_handle); 71 rc = usb_hc_connection_open(&conn); 72 if (rc != EOK) { 73 printf(NAME ": failed to connect to HC: %s.\n", 74 str_error(rc)); 75 return; 76 } 77 usb_address_t addr; 78 for (addr = 1; addr < 5; addr++) { 79 devman_handle_t dev_handle; 80 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle); 81 if (rc != EOK) { 82 continue; 83 } 84 char path[MAX_PATH_LENGTH]; 85 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH); 86 if (rc != EOK) { 87 continue; 88 } 89 print_found_dev(addr, path); 90 } 91 usb_hc_connection_close(&conn); 92 } 52 93 53 94 int main(int argc, char *argv[]) … … 69 110 continue; 70 111 } 71 print f(NAME ": host controller %zu is `%s'.\n",72 class_index, path);112 print_found_hc(class_index, path); 113 print_hc_devices(hc_handle); 73 114 } 74 115 -
uspace/drv/ehci-hcd/hc_iface.c
r11349a85 r511cfc8 106 106 } 107 107 108 /** Find device handle by USB address. 109 * 110 * @param[in] fun DDF function that was called. 111 * @param[in] address Address in question. 112 * @param[out] handle Where to store device handle if found. 113 * @return Error code. 114 */ 115 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 116 devman_handle_t *handle) 117 { 118 UNSUPPORTED("find_by_address"); 119 120 return ENOTSUP; 121 } 122 108 123 /** Release previously requested address. 109 124 * … … 321 336 .request_address = request_address, 322 337 .bind_address = bind_address, 338 .find_by_address = find_by_address, 323 339 .release_address = release_address, 324 340 -
uspace/drv/ohci/iface.c
r11349a85 r511cfc8 122 122 return EOK; 123 123 } 124 125 126 /** Find device handle by address interface function. 127 * 128 * @param[in] fun DDF function that was called. 129 * @param[in] address Address in question. 130 * @param[out] handle Where to store device handle if found. 131 * @return Error code. 132 */ 133 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 134 devman_handle_t *handle) 135 { 136 assert(fun); 137 hc_t *hc = fun_to_hc(fun); 138 assert(hc); 139 bool found = 140 usb_device_keeper_find_by_address(&hc->manager, address, handle); 141 return found ? EOK : ENOENT; 142 } 143 124 144 /*----------------------------------------------------------------------------*/ 125 145 /** Release address interface function … … 402 422 .request_address = request_address, 403 423 .bind_address = bind_address, 424 .find_by_address = find_by_address, 404 425 .release_address = release_address, 405 426 -
uspace/drv/ohci/root_hub.c
r11349a85 r511cfc8 237 237 return ENOMEM; 238 238 239 usb_log_info("OHCI root hub with % dports initialized.\n",239 usb_log_info("OHCI root hub with %zu ports initialized.\n", 240 240 instance->port_count); 241 241 -
uspace/drv/uhci-hcd/iface.c
r11349a85 r511cfc8 122 122 return EOK; 123 123 } 124 125 /** Find device handle by address interface function. 126 * 127 * @param[in] fun DDF function that was called. 128 * @param[in] address Address in question. 129 * @param[out] handle Where to store device handle if found. 130 * @return Error code. 131 */ 132 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 133 devman_handle_t *handle) 134 { 135 assert(fun); 136 hc_t *hc = fun_to_hc(fun); 137 assert(hc); 138 bool found = 139 usb_device_keeper_find_by_address(&hc->manager, address, handle); 140 return found ? EOK : ENOENT; 141 } 142 124 143 /*----------------------------------------------------------------------------*/ 125 144 /** Release address interface function … … 352 371 .request_address = request_address, 353 372 .bind_address = bind_address, 373 .find_by_address = find_by_address, 354 374 .release_address = release_address, 355 375 -
uspace/drv/vhc/connhost.c
r11349a85 r511cfc8 94 94 } 95 95 96 /** Find device handle by address interface function. 97 * 98 * @param[in] fun DDF function that was called. 99 * @param[in] address Address in question. 100 * @param[out] handle Where to store device handle if found. 101 * @return Error code. 102 */ 103 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 104 devman_handle_t *handle) 105 { 106 VHC_DATA(vhc, fun); 107 bool found = 108 usb_device_keeper_find_by_address(&vhc->dev_keeper, address, handle); 109 return found ? EOK : ENOENT; 110 } 111 96 112 /** Release previously requested address. 97 113 * … … 444 460 .request_address = request_address, 445 461 .bind_address = bind_address, 462 .find_by_address = find_by_address, 446 463 .release_address = release_address, 447 464 -
uspace/lib/drv/generic/remote_usbhc.c
r11349a85 r511cfc8 52 52 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 53 53 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 static void remote_usbhc_find_by_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 54 55 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 55 56 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 61 62 remote_usbhc_request_address, 62 63 remote_usbhc_bind_address, 64 remote_usbhc_find_by_address, 63 65 remote_usbhc_release_address, 64 66 … … 161 163 162 164 async_answer_0(callid, rc); 165 } 166 167 void remote_usbhc_find_by_address(ddf_fun_t *fun, void *iface, 168 ipc_callid_t callid, ipc_call_t *call) 169 { 170 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 171 172 if (!usb_iface->find_by_address) { 173 async_answer_0(callid, ENOTSUP); 174 return; 175 } 176 177 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 178 devman_handle_t handle; 179 int rc = usb_iface->find_by_address(fun, address, &handle); 180 181 if (rc == EOK) { 182 async_answer_1(callid, EOK, handle); 183 } else { 184 async_answer_0(callid, rc); 185 } 163 186 } 164 187 -
uspace/lib/drv/include/usb_iface.h
r11349a85 r511cfc8 49 49 * - arbitrary error code if returned by remote implementation 50 50 * - EOK - handle found, first parameter contains the USB address 51 * 52 * The handle must be the one used for binding USB address with 53 * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller 54 * (that this request would eventually reach) would not be able 55 * to find it. 56 * The problem is that this handle is actually assigned to the 57 * function inside driver of the parent device (usually hub driver). 58 * To bypass this problem, the initial caller specify handle as 59 * zero and the first parent assigns the actual value. 60 * See usb_iface_get_address_hub_child_impl() implementation 61 * that could be assigned to device ops of a child device of in a 62 * hub driver. 63 * For example, the USB multi interface device driver (MID) 64 * passes this initial zero without any modification because the 65 * handle must be resolved by its parent. 51 66 */ 52 67 IPC_M_USB_GET_ADDRESS, -
uspace/lib/drv/include/usbhc_iface.h
r11349a85 r511cfc8 105 105 IPC_M_USBHC_BIND_ADDRESS, 106 106 107 /** Get handle binded with given USB address. 108 * Parameters 109 * - USB address 110 * Answer: 111 * - EOK - address binded, first parameter is the devman handle 112 * - ENOENT - address is not in use at the moment 113 */ 114 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 115 107 116 /** Release address in use. 108 117 * Arguments: … … 207 216 int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *); 208 217 int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t); 218 int (*find_by_address)(ddf_fun_t *, usb_address_t, devman_handle_t *); 209 219 int (*release_address)(ddf_fun_t *, usb_address_t); 210 220 -
uspace/lib/usb/include/usb/host/device_keeper.h
r11349a85 r511cfc8 80 80 devman_handle_t handle); 81 81 82 bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance, 83 usb_address_t address, devman_handle_t *handle); 84 82 85 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 83 86 usb_address_t address); -
uspace/lib/usb/include/usb/hub.h
r11349a85 r511cfc8 63 63 const usb_hc_attached_device_t *); 64 64 int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t); 65 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t, 66 devman_handle_t *); 65 67 66 68 #endif -
uspace/lib/usb/src/host/device_keeper.c
r11349a85 r511cfc8 157 157 return ENOENT; 158 158 } 159 160 /** Find devman handled assigned to USB address. 161 * 162 * @param[in] instance Device keeper structure to use. 163 * @param[in] address Address the caller wants to find. 164 * @param[out] handle Where to store found handle. 165 * @return Whether such address is currently occupied. 166 */ 167 bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance, 168 usb_address_t address, devman_handle_t *handle) 169 { 170 assert(instance); 171 fibril_mutex_lock(&instance->guard); 172 if ((address < 0) || (address >= USB_ADDRESS_COUNT)) { 173 fibril_mutex_unlock(&instance->guard); 174 return false; 175 } 176 if (!instance->devices[address].occupied) { 177 fibril_mutex_unlock(&instance->guard); 178 return false; 179 } 180 181 if (handle != NULL) { 182 *handle = instance->devices[address].handle; 183 } 184 185 fibril_mutex_unlock(&instance->guard); 186 return true; 187 } 188 159 189 /*----------------------------------------------------------------------------*/ 160 190 /** Get speed associated with the address -
uspace/lib/usb/src/hub.c
r11349a85 r511cfc8 117 117 DEV_IFACE_ID(USBHC_DEV_IFACE), 118 118 IPC_M_USBHC_RELEASE_ADDRESS, address); 119 } 120 121 /** Get handle of USB device with given address. 122 * 123 * @param[in] connection Opened connection to host controller. 124 * @param[in] address Address of device in question. 125 * @param[out] handle Where to write the device handle. 126 * @return Error code. 127 */ 128 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection, 129 usb_address_t address, devman_handle_t *handle) 130 { 131 CHECK_CONNECTION(connection); 132 133 sysarg_t tmp; 134 int rc = async_req_2_1(connection->hc_phone, 135 DEV_IFACE_ID(USBHC_DEV_IFACE), 136 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 137 address, &tmp); 138 if ((rc == EOK) && (handle != NULL)) { 139 *handle = tmp; 140 } 141 142 return rc; 119 143 } 120 144
Note:
See TracChangeset
for help on using the changeset viewer.