Changes in uspace/app/usbinfo/info.c [5ccb15c:b1c6e58] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
r5ccb15c rb1c6e58 27 27 */ 28 28 29 /** @addtogroup usb 29 /** @addtogroup usbinfo 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief34 * Dumping of generic device properties. 35 35 */ 36 36 #include <stdio.h> 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include <usb/usbdrv.h> 39 #include <usb/pipes.h> 40 #include <usb/recognise.h> 41 #include <usb/request.h> 40 42 #include "usbinfo.h" 41 43 42 int dump_device( int hc_phone, usb_address_t address)44 int dump_device(devman_handle_t hc_handle, usb_address_t address) 43 45 { 46 int rc; 47 usb_device_connection_t wire; 48 usb_endpoint_pipe_t ctrl_pipe; 49 50 /* 51 * Initialize pipes. 52 */ 53 rc = usb_device_connection_initialize(&wire, hc_handle, address); 54 if (rc != EOK) { 55 fprintf(stderr, 56 NAME ": failed to create connection to the device: %s.\n", 57 str_error(rc)); 58 goto leave; 59 } 60 rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire); 61 if (rc != EOK) { 62 fprintf(stderr, 63 NAME ": failed to create default control pipe: %s.\n", 64 str_error(rc)); 65 goto leave; 66 } 67 rc = usb_endpoint_pipe_start_session(&ctrl_pipe); 68 if (rc != EOK) { 69 fprintf(stderr, 70 NAME ": failed to start session on control pipe: %s.\n", 71 str_error(rc)); 72 goto leave; 73 } 74 44 75 /* 45 76 * Dump information about possible match ids. … … 47 78 match_id_list_t match_id_list; 48 79 init_match_ids(&match_id_list); 49 int rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);80 rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list); 50 81 if (rc != EOK) { 51 82 fprintf(stderr, 52 83 NAME ": failed to fetch match ids of the device: %s.\n", 53 84 str_error(rc)); 54 return rc;85 goto leave; 55 86 } 56 87 dump_match_ids(&match_id_list); … … 60 91 */ 61 92 usb_standard_device_descriptor_t device_descriptor; 62 usb_dprintf(NAME, 1, 63 "usb_drv_req_get_device_descriptor(%d, %d, %p)\n", 64 hc_phone, (int) address, &device_descriptor); 65 66 rc = usb_drv_req_get_device_descriptor(hc_phone, address, 67 &device_descriptor); 93 rc = usb_request_get_device_descriptor(&ctrl_pipe, &device_descriptor); 68 94 if (rc != EOK) { 69 95 fprintf(stderr, 70 96 NAME ": failed to fetch standard device descriptor: %s.\n", 71 97 str_error(rc)); 72 return rc;73 } 74 dump_ standard_device_descriptor(&device_descriptor);98 goto leave; 99 } 100 dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor)); 75 101 76 102 /* … … 79 105 usb_standard_configuration_descriptor_t config_descriptor; 80 106 int config_index = 0; 81 usb_dprintf(NAME, 1, 82 "usb_drv_req_get_bare_configuration_descriptor(%d, %d, %d, %p)\n", 83 hc_phone, (int) address, config_index, &config_descriptor); 84 85 rc = usb_drv_req_get_bare_configuration_descriptor(hc_phone, address, 86 config_index, &config_descriptor ); 107 rc = usb_request_get_bare_configuration_descriptor(&ctrl_pipe, 108 config_index, &config_descriptor); 87 109 if (rc != EOK) { 88 110 fprintf(stderr, 89 111 NAME ": failed to fetch standard configuration descriptor: %s.\n", 90 112 str_error(rc)); 91 return rc; 92 } 93 dump_standard_configuration_descriptor(config_index, 94 &config_descriptor); 113 goto leave; 114 } 115 //dump_standard_configuration_descriptor(config_index, &config_descriptor); 95 116 96 117 void *full_config_descriptor = malloc(config_descriptor.total_length); 97 usb_dprintf(NAME, 1, 98 "usb_drv_req_get_full_configuration_descriptor(%d, %d, %d, %p, %zu)\n", 99 hc_phone, (int) address, config_index, 100 full_config_descriptor, config_descriptor.total_length); 101 102 rc = usb_drv_req_get_full_configuration_descriptor(hc_phone, address, 118 rc = usb_request_get_full_configuration_descriptor(&ctrl_pipe, 103 119 config_index, 104 120 full_config_descriptor, config_descriptor.total_length, NULL); … … 107 123 NAME ": failed to fetch full configuration descriptor: %s.\n", 108 124 str_error(rc)); 109 return rc; 110 } 111 dump_buffer("Full configuration descriptor:", 112 full_config_descriptor, config_descriptor.total_length); 125 goto leave; 126 } 113 127 114 128 dump_descriptor_tree(full_config_descriptor, 115 129 config_descriptor.total_length); 116 130 117 return EOK; 131 /* 132 * Get supported languages of STRING descriptors. 133 */ 134 l18_win_locales_t *langs; 135 size_t langs_count; 136 rc = usb_request_get_supported_languages(&ctrl_pipe, 137 &langs, &langs_count); 138 if (rc != EOK) { 139 fprintf(stderr, 140 NAME ": failed to get list of supported languages: %s.\n", 141 str_error(rc)); 142 goto skip_strings; 143 } 144 145 printf("String languages (%zu):", langs_count); 146 size_t i; 147 for (i = 0; i < langs_count; i++) { 148 printf(" 0x%04x", (int) langs[i]); 149 } 150 printf(".\n"); 151 152 /* 153 * Dump all strings in all available langages; 154 */ 155 for (i = 0; i < langs_count; i++) { 156 l18_win_locales_t lang = langs[i]; 157 158 printf("%sStrings for language 0x%04x:\n", get_indent(0), 159 (int) lang); 160 161 /* 162 * Try all indexes - we will see what pops-up ;-). 163 * However, to speed things up, we will stop after 164 * encountering several broken (or nonexistent ones) 165 * descriptors in line. 166 */ 167 size_t idx; 168 size_t failed_count = 0; 169 for (idx = 1; idx < 0xFF; idx++) { 170 char *string; 171 rc = usb_request_get_string(&ctrl_pipe, idx, lang, 172 &string); 173 if (rc != EOK) { 174 failed_count++; 175 if (failed_count > 3) { 176 break; 177 } 178 continue; 179 } 180 printf("%sString #%zu: \"%s\"\n", get_indent(1), 181 idx, string); 182 free(string); 183 failed_count = 0; /* Reset failed counter. */ 184 } 185 } 186 187 188 skip_strings: 189 190 rc = EOK; 191 192 leave: 193 /* Ignoring errors here. */ 194 usb_endpoint_pipe_end_session(&ctrl_pipe); 195 196 return rc; 118 197 } 119 198
Note:
See TracChangeset
for help on using the changeset viewer.