Changes in uspace/app/usbinfo/info.c [9d58539:e2dfa86] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
r9d58539 re2dfa86 37 37 #include <str_error.h> 38 38 #include <errno.h> 39 #include <usb/debug.h> 39 40 #include <usb/dev/pipes.h> 40 41 #include <usb/dev/recognise.h> … … 44 45 #include "usbinfo.h" 45 46 46 void dump_short_device_identification(usb info_device_t *dev)47 void dump_short_device_identification(usb_device_t *usb_dev) 47 48 { 48 49 printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0), 49 (int) dev->device_descriptor.product_id,50 (int) dev->device_descriptor.vendor_id);50 usb_device_descriptors(usb_dev)->device.product_id, 51 usb_device_descriptors(usb_dev)->device.vendor_id); 51 52 } 52 53 … … 66 67 } 67 68 68 usbinfo_device_t *dev = (usbinfo_device_t *) arg; 69 usb_device_t *usb_dev = arg; 70 assert(usb_dev); 69 71 70 72 usb_standard_interface_descriptor_t *iface … … 80 82 match_id_list_t matches; 81 83 init_match_ids(&matches); 82 usb_device_create_match_ids_from_interface( &dev->device_descriptor,83 iface, &matches);84 usb_device_create_match_ids_from_interface( 85 &usb_device_descriptors(usb_dev)->device, iface, &matches); 84 86 dump_match_ids(&matches, get_indent(1)); 85 87 clean_match_ids(&matches); 86 88 } 87 89 88 void dump_device_match_ids(usb info_device_t *dev)90 void dump_device_match_ids(usb_device_t *usb_dev) 89 91 { 90 92 match_id_list_t matches; 91 93 init_match_ids(&matches); 92 94 usb_device_create_match_ids_from_device_descriptor( 93 &dev->device_descriptor, &matches);95 &usb_device_descriptors(usb_dev)->device, &matches); 94 96 printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0), 95 (int) dev->device_descriptor.product_id,96 (int) dev->device_descriptor.vendor_id,97 usb_str_class( dev->device_descriptor.device_class));97 usb_device_descriptors(usb_dev)->device.product_id, 98 usb_device_descriptors(usb_dev)->device.vendor_id, 99 usb_str_class(usb_device_descriptors(usb_dev)->device.device_class)); 98 100 dump_match_ids(&matches, get_indent(1)); 99 101 clean_match_ids(&matches); 100 102 101 usb_dp_walk_simple(dev->full_configuration_descriptor, 102 dev->full_configuration_descriptor_size, 103 usb_dp_walk_simple( 104 usb_device_descriptors(usb_dev)->full_config, 105 usb_device_descriptors(usb_dev)->full_config_size, 103 106 usb_dp_standard_descriptor_nesting, 104 dump_match_ids_from_interface, 105 dev); 107 dump_match_ids_from_interface, usb_dev); 106 108 } 107 109 … … 224 226 } 225 227 226 void dump_descriptor_tree_brief(usbinfo_device_t *dev) 227 { 228 dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor, 228 void dump_descriptor_tree_brief(usb_device_t *usb_dev) 229 { 230 dump_descriptor_tree_callback( 231 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 229 232 (size_t) -1, NULL); 230 usb_dp_walk_simple(dev->full_configuration_descriptor, 231 dev->full_configuration_descriptor_size, 233 234 usb_dp_walk_simple( 235 usb_device_descriptors(usb_dev)->full_config, 236 usb_device_descriptors(usb_dev)->full_config_size, 232 237 usb_dp_standard_descriptor_nesting, 233 dump_descriptor_tree_callback, 234 NULL); 235 } 236 237 void dump_descriptor_tree_full(usbinfo_device_t *dev) 238 { 239 dump_descriptor_tree_callback((uint8_t *)&dev->device_descriptor, 240 (size_t) -1, dev); 241 usb_dp_walk_simple(dev->full_configuration_descriptor, 242 dev->full_configuration_descriptor_size, 238 dump_descriptor_tree_callback, NULL); 239 } 240 241 void dump_descriptor_tree_full(usb_device_t *usb_dev) 242 { 243 dump_descriptor_tree_callback( 244 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 245 (size_t) -1, usb_dev); 246 247 usb_dp_walk_simple( 248 usb_device_descriptors(usb_dev)->full_config, 249 usb_device_descriptors(usb_dev)->full_config_size, 243 250 usb_dp_standard_descriptor_nesting, 244 dump_descriptor_tree_callback, 245 dev); 251 dump_descriptor_tree_callback, usb_dev); 246 252 } 247 253 … … 285 291 286 292 287 void dump_strings(usb info_device_t *dev)293 void dump_strings(usb_device_t *usb_dev) 288 294 { 289 295 /* Find used indexes. Devices with more than 64 strings are very rare.*/ 290 296 uint64_t str_mask = 0; 291 find_string_indexes_callback((uint8_t *)&dev->device_descriptor, 0, 297 find_string_indexes_callback( 298 (const uint8_t *)&usb_device_descriptors(usb_dev)->device, 0, 292 299 &str_mask); 293 usb_dp_walk_simple(dev->full_configuration_descriptor, 294 dev->full_configuration_descriptor_size, 300 301 usb_dp_walk_simple( 302 usb_device_descriptors(usb_dev)->full_config, 303 usb_device_descriptors(usb_dev)->full_config_size, 295 304 usb_dp_standard_descriptor_nesting, 296 find_string_indexes_callback, 297 &str_mask); 305 find_string_indexes_callback, &str_mask); 298 306 299 307 if (str_mask == 0) { … … 305 313 l18_win_locales_t *langs; 306 314 size_t langs_count; 307 int rc = usb_request_get_supported_languages( &dev->ctrl_pipe,308 &langs, &langs_count);315 int rc = usb_request_get_supported_languages( 316 usb_device_get_default_pipe(usb_dev), &langs, &langs_count); 309 317 if (rc != EOK) { 310 318 fprintf(stderr, … … 334 342 } 335 343 char *string = NULL; 336 rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang, 344 rc = usb_request_get_string( 345 usb_device_get_default_pipe(usb_dev), idx, lang, 337 346 &string); 338 347 if ((rc != EOK) && (rc != EEMPTY)) { … … 351 360 352 361 353 void dump_status(usb info_device_t *dev)362 void dump_status(usb_device_t *usb_dev) 354 363 { 355 364 int rc; 356 uint16_t device_status = 0; 357 uint16_t ctrl_pipe_status = 0; 365 uint16_t status = 0; 358 366 359 367 /* Device status first. */ 360 rc = usb_request_get_status(&dev->ctrl_pipe, 361 USB_REQUEST_RECIPIENT_DEVICE, 0, 362 &device_status); 368 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 369 USB_REQUEST_RECIPIENT_DEVICE, 0, &status); 363 370 if (rc != EOK) { 364 371 printf("%sFailed to get device status: %s.\n", 365 372 get_indent(0), str_error(rc)); 366 goto try_ctrl_pipe_status; 367 } 368 369 printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n", 370 get_indent(0), 371 device_status, 372 device_status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus", 373 device_status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no"); 373 } else { 374 printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n", 375 get_indent(0), status, 376 status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus", 377 status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no"); 378 } 374 379 375 380 /* Interface is not interesting, skipping ;-). */ 376 381 377 382 /* Control endpoint zero. */ 378 try_ctrl_pipe_status: 379 rc = usb_request_get_status(&dev->ctrl_pipe, 380 USB_REQUEST_RECIPIENT_ENDPOINT, 0, 381 &ctrl_pipe_status); 383 status = 0; 384 rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev), 385 USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status); 382 386 if (rc != EOK) { 383 387 printf("%sFailed to get control endpoint status: %s.\n", 384 388 get_indent(0), str_error(rc)); 385 goto leave; 386 } 387 388 printf("%sControl endpoint zero status %04X: halted=%s.\n", 389 get_indent(0), 390 ctrl_pipe_status, 391 ctrl_pipe_status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no"); 392 393 leave: 394 return; 389 } else { 390 printf("%sControl endpoint zero status %04X: halted=%s.\n", 391 get_indent(0), status, 392 status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no"); 393 } 395 394 } 396 395
Note:
See TracChangeset
for help on using the changeset viewer.